@@ -626,7 +626,10 @@ class RenderWebGL extends EventEmitter {
626
626
gl . clearColor . apply ( gl , this . _backgroundColor ) ;
627
627
gl . clear ( gl . COLOR_BUFFER_BIT ) ;
628
628
629
- this . _drawThese ( this . _drawList , ShaderManager . DRAW_MODE . default , this . _projection ) ;
629
+ this . _drawThese ( this . _drawList , ShaderManager . DRAW_MODE . default , this . _projection , {
630
+ framebufferWidth : gl . canvas . width ,
631
+ framebufferHeight : gl . canvas . height
632
+ } ) ;
630
633
if ( this . _snapshotCallbacks . length > 0 ) {
631
634
const snapshot = gl . canvas . toDataURL ( ) ;
632
635
this . _snapshotCallbacks . forEach ( cb => cb ( snapshot ) ) ;
@@ -1674,13 +1677,20 @@ class RenderWebGL extends EventEmitter {
1674
1677
* @param {object.<string,*> } opts.extraUniforms Extra uniforms for the shaders.
1675
1678
* @param {int } opts.effectMask Bitmask for effects to allow
1676
1679
* @param {boolean } opts.ignoreVisibility Draw all, despite visibility (e.g. stamping, touching color)
1680
+ * @param {int } opts.framebufferWidth The width of the framebuffer being drawn onto. Defaults to "native" width
1681
+ * @param {int } opts.framebufferHeight The height of the framebuffer being drawn onto. Defaults to "native" height
1677
1682
* @private
1678
1683
*/
1679
1684
_drawThese ( drawables , drawMode , projection , opts = { } ) {
1680
1685
1681
1686
const gl = this . _gl ;
1682
1687
let currentShader = null ;
1683
1688
1689
+ const framebufferSpaceScaleDiffers = (
1690
+ opts . framebufferWidth && opts . framebufferHeight &&
1691
+ opts . framebufferWidth !== this . _nativeSize [ 0 ] && opts . framebufferHeight !== this . _nativeSize [ 1 ]
1692
+ ) ;
1693
+
1684
1694
const numDrawables = drawables . length ;
1685
1695
for ( let drawableIndex = 0 ; drawableIndex < numDrawables ; ++ drawableIndex ) {
1686
1696
const drawableID = drawables [ drawableIndex ] ;
@@ -1695,11 +1705,13 @@ class RenderWebGL extends EventEmitter {
1695
1705
// the ignoreVisibility flag is used (e.g. for stamping or touchingColor).
1696
1706
if ( ! drawable . getVisible ( ) && ! opts . ignoreVisibility ) continue ;
1697
1707
1698
- // Combine drawable scale with the native vs. backing pixel ratio
1699
- const drawableScale = [
1700
- drawable . scale [ 0 ] * this . _gl . canvas . width / this . _nativeSize [ 0 ] ,
1701
- drawable . scale [ 1 ] * this . _gl . canvas . height / this . _nativeSize [ 1 ]
1702
- ] ;
1708
+ // drawableScale is the "framebuffer-pixel-space" scale of the drawable, as percentages of the drawable's
1709
+ // "native size" (so 100 = same as skin's "native size", 200 = twice "native size").
1710
+ // If the framebuffer dimensions are the same as the stage's "native" size, there's no need to calculate it.
1711
+ const drawableScale = framebufferSpaceScaleDiffers ? [
1712
+ drawable . scale [ 0 ] * opts . framebufferWidth / this . _nativeSize [ 0 ] ,
1713
+ drawable . scale [ 1 ] * opts . framebufferHeight / this . _nativeSize [ 1 ]
1714
+ ] : drawable . scale ;
1703
1715
1704
1716
// If the skin or texture isn't ready yet, skip it.
1705
1717
if ( ! drawable . skin || ! drawable . skin . getTexture ( drawableScale ) ) continue ;
0 commit comments