Merge pull request from adroitwhiz/fix-resize

Call draw() after resizing canvas
This commit is contained in:
DD Liu 2020-04-27 13:38:25 -04:00 committed by GitHub
commit b6424a2f80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -220,9 +220,20 @@ class RenderWebGL extends EventEmitter {
* @param {int} pixelsTall The desired height in device-independent pixels.
*/
resize (pixelsWide, pixelsTall) {
const {canvas} = this._gl;
const pixelRatio = window.devicePixelRatio || 1;
this._gl.canvas.width = pixelsWide * pixelRatio;
this._gl.canvas.height = pixelsTall * pixelRatio;
const newWidth = pixelsWide * pixelRatio;
const newHeight = pixelsTall * pixelRatio;
// Certain operations, such as moving the color picker, call `resize` once per frame, even though the canvas
// size doesn't change. To avoid unnecessary canvas updates, check that we *really* need to resize the canvas.
if (canvas.width !== newWidth || canvas.height !== newHeight) {
canvas.width = newWidth;
canvas.height = newHeight;
// Resizing the canvas causes it to be cleared, so redraw it.
this.draw();
}
}
/**
@ -1762,6 +1773,10 @@ class RenderWebGL extends EventEmitter {
*/
_getConvexHullPointsForDrawable (drawableID) {
const drawable = this._allDrawables[drawableID];
drawable.updateMatrix();
drawable.skin.updateSilhouette(this._getDrawableScreenSpaceScale(drawable));
const [width, height] = drawable.skin.size;
// No points in the hull if invisible or size is 0.
if (!drawable.getVisible() || width === 0 || height === 0) {