Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions browser/src/slideshow/LayerDrawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,12 @@ class LayerDrawing {
}

private computeInitialResolution() {
const viewWidth = window.screen.width;
const viewHeight = window.screen.height;
// window.screen dimensions are in CSS pixels; multiply by DPR so the
// tier selection matches the display's physical pixels and the canvas
// backing store isn't upscaled by CSS on HiDPI screens.
const dpr = window.devicePixelRatio || 1;
const viewWidth = window.screen.width * dpr;
const viewHeight = window.screen.height * dpr;
this.computeResolution(viewWidth, viewHeight);
}

Expand Down
4 changes: 3 additions & 1 deletion browser/src/slideshow/LayerRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,12 @@ class LayerRendererGl implements LayerRenderer {
// app.console.debug(`LayerDrawing.drawBitmap: cache hit: key: ${textureKey}`);
} else {
if (imageInfo instanceof ImageBitmap) {
texture = this.glContext.loadTexture(imageInfo);
texture = this.glContext.loadTexture(imageInfo, false, true);
} else {
texture = this.glContext.loadTexture(
imageInfo.data as HTMLImageElement,
false,
true,
);
}
this.textureCache.set(textureKey, texture);
Expand Down
2 changes: 1 addition & 1 deletion browser/src/slideshow/LayersCompositor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class LayersCompositor extends SlideCompositor {
if (slideRatio > resolutionRatio) {
height = Math.trunc((width * slideHeight) / slideWidth);
} else if (slideRatio < resolutionRatio) {
width = Math.trunc((height * slideWidth) / slideHeight);
width = Math.ceil((height * slideWidth) / slideHeight);
}
return [width, height];
}
Expand Down
8 changes: 6 additions & 2 deletions browser/src/slideshow/RenderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ abstract class RenderContext {
public abstract loadTexture(
image: HTMLImageElement,
isMipMapEnable?: boolean,
nearestFiltering?: boolean,
): WebGLTexture | ImageBitmap;

public abstract deleteTexture(texture: WebGLTexture | ImageBitmap): void;
Expand Down Expand Up @@ -109,6 +110,7 @@ class RenderContextGl extends RenderContext {
public loadTexture(
image: HTMLImageElement | ImageBitmap,
isMipMapEnable: boolean = false,
nearestFiltering: boolean = false,
): WebGLTexture | ImageBitmap {
if (this.isDisposed()) return null;

Expand All @@ -128,6 +130,7 @@ class RenderContextGl extends RenderContext {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

const filter = nearestFiltering ? gl.NEAREST : gl.LINEAR;
if (isMipMapEnable) {
gl.generateMipmap(gl.TEXTURE_2D);
gl.texParameteri(
Expand All @@ -136,10 +139,10 @@ class RenderContextGl extends RenderContext {
gl.LINEAR_MIPMAP_LINEAR,
);
} else {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
}

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);

if (image instanceof HTMLImageElement)
app.console.debug(`Texture loaded successfully`);
Expand Down Expand Up @@ -277,6 +280,7 @@ class RenderContext2d extends RenderContext {
public loadTexture(
image: HTMLImageElement,
isMipMapEnable: boolean = false,
nearestFiltering: boolean = false,
): WebGLTexture | ImageBitmap {
return image;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading