From 3dae48acf43f8ce1d41ccb6163599ed72b3e9582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 18 Mar 2014 12:42:28 +0100 Subject: [PATCH] Bring back accidentally removed support for pixelRatio in CanvasProvider. --- src/canvas/CanvasProvider.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/canvas/CanvasProvider.js b/src/canvas/CanvasProvider.js index adaf8148..04e8ed5f 100644 --- a/src/canvas/CanvasProvider.js +++ b/src/canvas/CanvasProvider.js @@ -15,13 +15,20 @@ var CanvasProvider = { canvases: [], - getCanvas: function(width, height) { + getCanvas: function(width, height, pixelRatio) { var canvas, init = true; if (typeof width === 'object') { + pixelRatio = height; height = width.height; width = width.width; } + if (!pixelRatio) { + pixelRatio = 1; + } else if (pixelRatio !== 1) { + width *= pixelRatio; + height *= pixelRatio; + } if (this.canvases.length) { canvas = this.canvases.pop(); } else { @@ -45,11 +52,13 @@ var CanvasProvider = { } // We save on retrieval and restore on release. ctx.save(); + if (pixelRatio !== 1) + ctx.scale(pixelRatio, pixelRatio); return canvas; }, - getContext: function(width, height) { - return this.getCanvas(width, height).getContext('2d'); + getContext: function(width, height, pixelRatio) { + return this.getCanvas(width, height, pixelRatio).getContext('2d'); }, // release can receive either a canvas or a context.