Bring back accidentally removed support for pixelRatio in CanvasProvider.

This commit is contained in:
Jürg Lehni 2014-03-18 12:42:28 +01:00
parent 09d90a21bc
commit 3dae48acf4

View file

@ -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.