@@ -448,62 +448,86 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
448448 }
449449
450450 // Ignore null sources
451- if ( this . texture . valid )
451+ if ( ! this . texture . valid )
452452 {
453- var resolution = this . texture . baseTexture . resolution / renderSession . resolution ;
454-
455- renderSession . context . globalAlpha = this . worldAlpha ;
453+ // Update the children and leave
454+ for ( var i = 0 ; i < this . children . length ; i ++ )
455+ {
456+ this . children [ i ] . _renderCanvas ( renderSession ) ;
457+ }
456458
457- // If smoothingEnabled is supported and we need to change the smoothing property for this texture
458- if ( renderSession . smoothProperty && renderSession . scaleMode !== this . texture . baseTexture . scaleMode )
459+ if ( this . _mask )
459460 {
460- renderSession . scaleMode = this . texture . baseTexture . scaleMode ;
461- renderSession . context [ renderSession . smoothProperty ] = ( renderSession . scaleMode === PIXI . scaleModes . LINEAR ) ;
461+ renderSession . maskManager . popMask ( renderSession ) ;
462462 }
463463
464- // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
465- var dx = ( this . texture . trim ) ? this . texture . trim . x - this . anchor . x * this . texture . trim . width : this . anchor . x * - this . texture . frame . width ;
466- var dy = ( this . texture . trim ) ? this . texture . trim . y - this . anchor . y * this . texture . trim . height : this . anchor . y * - this . texture . frame . height ;
464+ return ;
465+ }
467466
468- var tx = ( wt . tx * renderSession . resolution ) + renderSession . shakeX ;
469- var ty = ( wt . ty * renderSession . resolution ) + renderSession . shakeY ;
467+ var resolution = this . texture . baseTexture . resolution / renderSession . resolution ;
470468
471- // Allow for pixel rounding
472- if ( renderSession . roundPixels )
473- {
474- renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , tx | 0 , ty | 0 ) ;
475- dx |= 0 ;
476- dy |= 0 ;
477- }
478- else
479- {
480- renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , tx , ty ) ;
481- }
469+ renderSession . context . globalAlpha = this . worldAlpha ;
482470
483- var cw = this . texture . crop . width ;
484- var ch = this . texture . crop . height ;
471+ // If smoothingEnabled is supported and we need to change the smoothing property for this texture
472+ if ( renderSession . smoothProperty && renderSession . scaleMode !== this . texture . baseTexture . scaleMode )
473+ {
474+ renderSession . scaleMode = this . texture . baseTexture . scaleMode ;
475+ renderSession . context [ renderSession . smoothProperty ] = ( renderSession . scaleMode === PIXI . scaleModes . LINEAR ) ;
476+ }
485477
486- dx /= resolution ;
487- dy /= resolution ;
478+ // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
479+ var dx = ( this . texture . trim ) ? this . texture . trim . x - this . anchor . x * this . texture . trim . width : this . anchor . x * - this . texture . frame . width ;
480+ var dy = ( this . texture . trim ) ? this . texture . trim . y - this . anchor . y * this . texture . trim . height : this . anchor . y * - this . texture . frame . height ;
488481
489- if ( this . tint !== 0xFFFFFF )
490- {
491- if ( this . texture . requiresReTint || this . cachedTint !== this . tint )
492- {
493- this . tintedTexture = PIXI . CanvasTinter . getTintedTexture ( this , this . tint ) ;
482+ var tx = ( wt . tx * renderSession . resolution ) + renderSession . shakeX ;
483+ var ty = ( wt . ty * renderSession . resolution ) + renderSession . shakeY ;
494484
495- this . cachedTint = this . tint ;
496- this . texture . requiresReTint = false ;
497- }
485+ // Allow for pixel rounding
486+ if ( renderSession . roundPixels )
487+ {
488+ renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , tx | 0 , ty | 0 ) ;
489+ dx |= 0 ;
490+ dy |= 0 ;
491+ }
492+ else
493+ {
494+ renderSession . context . setTransform ( wt . a , wt . b , wt . c , wt . d , tx , ty ) ;
495+ }
498496
499- renderSession . context . drawImage ( this . tintedTexture , 0 , 0 , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
500- }
501- else
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+
510+ dx /= resolution ;
511+ dy /= resolution ;
512+
513+ if ( this . tint !== 0xFFFFFF )
514+ {
515+ if ( this . texture . requiresReTint || this . cachedTint !== this . tint )
502516 {
503- var cx = this . texture . crop . x ;
504- var cy = this . texture . crop . y ;
505- renderSession . context . drawImage ( this . texture . baseTexture . source , cx , cy , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
517+ this . tintedTexture = PIXI . CanvasTinter . getTintedTexture ( this , this . tint ) ;
518+
519+ this . cachedTint = this . tint ;
520+ this . texture . requiresReTint = false ;
506521 }
522+
523+ renderSession . context . drawImage ( this . tintedTexture , 0 , 0 , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
524+ }
525+ else
526+ {
527+ var cx = this . texture . crop . x ;
528+ var cy = this . texture . crop . y ;
529+
530+ renderSession . context . drawImage ( this . texture . baseTexture . source , cx , cy , cw , ch , dx , dy , cw / resolution , ch / resolution ) ;
507531 }
508532
509533 for ( var i = 0 ; i < this . children . length ; i ++ )
0 commit comments