@@ -337,11 +337,14 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession, matrix)
337337PIXI . Sprite . prototype . _renderCanvas = function ( renderSession , matrix )
338338{
339339 // If the sprite is not visible or the alpha is 0 then no need to render this element
340- if ( this . visible === false || this . alpha === 0 || this . renderable === false || this . texture . crop . width <= 0 || this . texture . crop . height <= 0 ) return ;
340+ if ( this . visible === false || this . alpha === 0 || this . renderable === false || this . texture . crop . width <= 0 || this . texture . crop . height <= 0 )
341+ {
342+ return ;
343+ }
341344
342- // They provided an alternative rendering matrix, so use it
343345 var wt = this . worldTransform ;
344346
347+ // If they provided an alternative rendering matrix then use it
345348 if ( matrix )
346349 {
347350 wt = matrix ;
@@ -388,6 +391,12 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
388391 renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , wt . tx * renderSession . resolution , wt . ty * renderSession . resolution ) ;
389392 }
390393
394+ var cw = this . texture . crop . width ;
395+ var ch = this . texture . crop . height ;
396+
397+ dx /= resolution ;
398+ dy /= resolution ;
399+
391400 if ( this . tint !== 0xFFFFFF )
392401 {
393402 if ( this . cachedTint !== this . tint )
@@ -396,29 +405,13 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
396405 this . tintedTexture = PIXI . CanvasTinter . getTintedTexture ( this , this . tint ) ;
397406 }
398407
399- renderSession . context . drawImage (
400- this . tintedTexture ,
401- 0 ,
402- 0 ,
403- this . texture . crop . width ,
404- this . texture . crop . height ,
405- dx / resolution ,
406- dy / resolution ,
407- this . texture . crop . width / resolution ,
408- this . texture . crop . height / resolution ) ;
408+ renderSession . context . drawImage ( this . tintedTexture , 0 , 0 , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
409409 }
410410 else
411411 {
412- renderSession . context . drawImage (
413- this . texture . baseTexture . source ,
414- this . texture . crop . x ,
415- this . texture . crop . y ,
416- this . texture . crop . width ,
417- this . texture . crop . height ,
418- dx / resolution ,
419- dy / resolution ,
420- this . texture . crop . width / resolution ,
421- this . texture . crop . height / resolution ) ;
412+ var cx = this . texture . crop . x ;
413+ var cy = this . texture . crop . y ;
414+ renderSession . context . drawImage ( this . texture . baseTexture . source , cx , cy , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
422415 }
423416 }
424417
@@ -431,6 +424,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
431424 {
432425 renderSession . maskManager . popMask ( renderSession ) ;
433426 }
427+
434428} ;
435429
436430// some helper functions..
0 commit comments