@@ -482,6 +482,33 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
482482 var tx = ( wt . tx * renderSession . resolution ) + renderSession . shakeX ;
483483 var ty = ( wt . ty * renderSession . resolution ) + renderSession . shakeY ;
484484
485+ var cw = this . texture . crop . width ;
486+ var ch = this . texture . crop . height ;
487+
488+ if ( this . texture . rotated )
489+ {
490+ var a = wt . a ;
491+ var b = wt . b ;
492+ var c = wt . c ;
493+ var d = wt . d ;
494+ var e = cw ;
495+
496+ // Offset before rotating
497+ tx = wt . c * ch + tx ;
498+ ty = wt . d * ch + ty ;
499+
500+ // Rotate matrix by 90 degrees
501+ // We use precalculated values for sine and cosine of rad(90)
502+ wt . a = a * 6.123233995736766e-17 + - c ;
503+ wt . b = b * 6.123233995736766e-17 + - d ;
504+ wt . c = a + c * 6.123233995736766e-17 ;
505+ wt . d = b + d * 6.123233995736766e-17 ;
506+
507+ // Update cropping dimensions.
508+ cw = ch ;
509+ ch = e ;
510+ }
511+
485512 // Allow for pixel rounding
486513 if ( renderSession . roundPixels )
487514 {
@@ -494,19 +521,6 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
494521 renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , tx , ty ) ;
495522 }
496523
497- var cw = this . texture . crop . width ;
498- var ch = this . texture . crop . height ;
499-
500- if ( this . texture . rotated )
501- {
502- // 90 degree coordinate rotation
503- cw = ch ;
504- ch = this . texture . crop . width ;
505-
506- renderSession . context . translate ( 0 , cw ) ;
507- renderSession . context . rotate ( - 1.5707963267948966 ) ;
508- }
509-
510524 dx /= resolution ;
511525 dy /= resolution ;
512526
0 commit comments