Skip to content

Commit ebcdfc3

Browse files
yaustarsteveny-sc
andauthored
Revert "Remove gl canvas dependency resize (playcanvas#3124)" (playcanvas#3146)
This reverts commit b2aaa7b. Co-authored-by: Steven Yau <syau@snapchat.com>
1 parent 707c1f2 commit ebcdfc3

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/framework/application.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,11 @@ class Application extends EventHandler {
13901390
this.graphicsDevice.canvas.style.width = width + 'px';
13911391
this.graphicsDevice.canvas.style.height = height + 'px';
13921392

1393+
// In AUTO mode the resolution is changed to match the canvas size
1394+
if (this._resolutionMode === RESOLUTION_AUTO) {
1395+
this.setCanvasResolution(RESOLUTION_AUTO);
1396+
}
1397+
13931398
// return the final values calculated for width and height
13941399
return {
13951400
width: width,
@@ -2141,13 +2146,6 @@ var makeTick = function (_app) {
21412146
application.fire("framerender");
21422147

21432148
if (application.autoRender || application.renderNextFrame) {
2144-
// In AUTO mode the resolution is changed to match the canvas size
2145-
if (application._resolutionMode === RESOLUTION_AUTO) {
2146-
// Check if the canvas DOM has changed size
2147-
const canvas = application.graphicsDevice.canvas;
2148-
application.graphicsDevice.resizeCanvas(canvas.clientWidth, canvas.clientHeight);
2149-
}
2150-
21512149
application.render();
21522150
application.renderNextFrame = false;
21532151
}

src/graphics/graphics-device.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,7 +3482,6 @@ class GraphicsDevice extends EventHandler {
34823482
}
34833483

34843484
/**
3485-
* @private
34863485
* @function
34873486
* @name GraphicsDevice#resizeCanvas
34883487
* @description Sets the width and height of the canvas, then fires the 'resizecanvas' event.
@@ -3497,8 +3496,8 @@ class GraphicsDevice extends EventHandler {
34973496
this._height = height;
34983497

34993498
var ratio = Math.min(this._maxPixelRatio, window.devicePixelRatio);
3500-
width = Math.floor(width * ratio);
3501-
height = Math.floor(height * ratio);
3499+
width *= ratio;
3500+
height *= ratio;
35023501

35033502
if (this.canvas.width === width && this.canvas.height === height)
35043503
return;

0 commit comments

Comments
 (0)