Fix texture scaling in canvas renderer

This commit is contained in:
Chad Engler 2014-01-23 08:05:51 -08:00
parent cef2ceb286
commit a31137a2aa
2 changed files with 19 additions and 22 deletions

View file

@ -323,11 +323,10 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
//if smoothingEnabled is supported and we need to change the smoothing property for this texture
// if(this.smoothProperty && this.scaleMode !== displayObject.texture.baseTexture.scaleMode) {
// this.scaleMode = displayObject.texture.baseTexture.scaleMode;
// context[this.smoothProperty] = (this.scaleMode === PIXI.BaseTexture.SCALE_MODE.LINEAR);
//}
if(renderSession.smoothProperty && renderSession.scaleMode !== displayObject.texture.baseTexture.scaleMode) {
renderSession.scaleMode = this.texture.baseTexture.scaleMode;
context[renderSession.smoothProperty] = (renderSession.scaleMode === PIXI.BaseTexture.SCALE_MODE.LINEAR);
}
if(this.tint !== 0xFFFFFF)
{

View file

@ -100,19 +100,6 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
* @type Canvas 2d Context
*/
this.context = this.view.getContext( "2d", { alpha: this.transparent } );
//some filter variables
this.smoothProperty = null;
if("imageSmoothingEnabled" in this.context)
this.smoothProperty = "imageSmoothingEnabled";
else if("webkitImageSmoothingEnabled" in this.context)
this.smoothProperty = "webkitImageSmoothingEnabled";
else if("mozImageSmoothingEnabled" in this.context)
this.smoothProperty = "mozImageSmoothingEnabled";
else if("oImageSmoothingEnabled" in this.context)
this.smoothProperty = "oImageSmoothingEnabled";
this.scaleMode = null;
this.refresh = true;
// hack to enable some hardware acceleration!
@ -124,10 +111,21 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
this.maskManager = new PIXI.CanvasMaskManager();
this.renderSession = {};
this.renderSession.context = this.context;
this.renderSession.maskManager = this.maskManager;
this.renderSession = {
context: this.context,
maskManager: this.maskManager,
scaleMode: null,
smoothProperty: null
};
if("imageSmoothingEnabled" in this.context)
this.renderSession.smoothProperty = "imageSmoothingEnabled";
else if("webkitImageSmoothingEnabled" in this.context)
this.renderSession.smoothProperty = "webkitImageSmoothingEnabled";
else if("mozImageSmoothingEnabled" in this.context)
this.renderSession.smoothProperty = "mozImageSmoothingEnabled";
else if("oImageSmoothingEnabled" in this.context)
this.renderSession.smoothProperty = "oImageSmoothingEnabled";
};
// constructor