diff --git a/src/core/helpers/hidpi.js b/src/core/helpers/hidpi.js index 88eae7d67612c9f8e7a91b6a013172d3932bf8da..0c131d1042b3ed645a63f5b3ce8102dad03f17ed 100644 --- a/src/core/helpers/hidpi.js +++ b/src/core/helpers/hidpi.js @@ -38,6 +38,24 @@ const ratioArgs = { } const proto = CanvasRenderingContext2D.prototype + +proto.drawImageByCanvas = (function (_super) { + return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { + if (!this.__hidpi__) { + return _super.apply(this, arguments) + } + srcx *= pixelRatio + srcy *= pixelRatio + srcw *= pixelRatio + srch *= pixelRatio + desx *= pixelRatio + desy *= pixelRatio + desw = isScale ? desw * pixelRatio : desw + desh = isScale ? desh * pixelRatio : desh + _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh) + } +})(proto.drawImage) + if (pixelRatio !== 1) { forEach(ratioArgs, function (value, key) { proto[key] = (function (_super) { @@ -141,23 +159,6 @@ if (pixelRatio !== 1) { })(proto.drawImage) } -proto.drawImageByCanvas = (function (_super) { - return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { - if (!this.__hidpi__) { - return _super.apply(this, arguments) - } - srcx *= pixelRatio - srcy *= pixelRatio - srcw *= pixelRatio - srch *= pixelRatio - desx *= pixelRatio - desy *= pixelRatio - desw = isScale ? desw * pixelRatio : desw - desh = isScale ? desh * pixelRatio : desh - _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh) - } -})(proto.drawImage) - export function wrapper (canvas) { canvas.width = canvas.offsetWidth * pixelRatio canvas.height = canvas.offsetHeight * pixelRatio