diff --git a/packages/mixin-cache-as-bitmap/package.json b/packages/mixin-cache-as-bitmap/package.json index ecfa117..86d5060 100644 --- a/packages/mixin-cache-as-bitmap/package.json +++ b/packages/mixin-cache-as-bitmap/package.json @@ -26,6 +26,7 @@ ], "dependencies": { "@pixi/core": "^5.0.0-alpha.3", + "@pixi/settings": "^5.0.0-alpha.3", "@pixi/display": "^5.0.0-alpha.3", "@pixi/math": "^5.0.0-alpha.3", "@pixi/sprite": "^5.0.0-alpha.3", diff --git a/packages/mixin-cache-as-bitmap/package.json b/packages/mixin-cache-as-bitmap/package.json index ecfa117..86d5060 100644 --- a/packages/mixin-cache-as-bitmap/package.json +++ b/packages/mixin-cache-as-bitmap/package.json @@ -26,6 +26,7 @@ ], "dependencies": { "@pixi/core": "^5.0.0-alpha.3", + "@pixi/settings": "^5.0.0-alpha.3", "@pixi/display": "^5.0.0-alpha.3", "@pixi/math": "^5.0.0-alpha.3", "@pixi/sprite": "^5.0.0-alpha.3", diff --git a/packages/mixin-cache-as-bitmap/src/index.js b/packages/mixin-cache-as-bitmap/src/index.js index 15c049c..69645f2 100644 --- a/packages/mixin-cache-as-bitmap/src/index.js +++ b/packages/mixin-cache-as-bitmap/src/index.js @@ -3,6 +3,7 @@ import { DisplayObject } from '@pixi/display'; import { Matrix } from '@pixi/math'; import { uid } from '@pixi/utils'; +import { settings } from '@pixi/settings'; const _tempMatrix = new Matrix(); @@ -138,7 +139,7 @@ this._initCachedDisplayObject(renderer); - this._cacheData.sprite._transformID = -1; + this._cacheData.sprite.transform._worldID = this.transform._worldID; this._cacheData.sprite.worldAlpha = this.worldAlpha; this._cacheData.sprite._render(renderer); }; @@ -180,6 +181,8 @@ bounds.pad(padding); } + bounds.ceil(settings.RESOLUTION); + // for now we cache the current renderTarget that the webGL renderer is currently using. // this could be more elegant.. const cachedRenderTarget = renderer._activeRenderTarget; @@ -187,8 +190,7 @@ // const stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject - - const renderTexture = RenderTexture.create(bounds.width | 0, bounds.height | 0); + const renderTexture = RenderTexture.create(bounds.width, bounds.height); const textureCacheId = `cacheAsBitmap_${uid()}`; @@ -271,8 +273,7 @@ this._initCachedDisplayObjectCanvas(renderer); this._cacheData.sprite.worldAlpha = this.worldAlpha; - - this._cacheData.sprite.renderCanvas(renderer); + this._cacheData.sprite._renderCanvas(renderer); }; // TODO this can be the same as the webGL version.. will need to do a little tweaking first though.. @@ -299,7 +300,9 @@ const cachedRenderTarget = renderer.context; - const renderTexture = RenderTexture.create(bounds.width | 0, bounds.height | 0); + bounds.ceil(settings.RESOLUTION); + + const renderTexture = RenderTexture.create(bounds.width, bounds.height); const textureCacheId = `cacheAsBitmap_${uid()}`; @@ -328,7 +331,7 @@ renderer.context = cachedRenderTarget; this.renderCanvas = this._renderCachedCanvas; - this._calculateBounds = this._calculateCachedBounds; + this.calculateBounds = this._calculateCachedBounds; this._mask = null; this.filterArea = null; @@ -367,7 +370,10 @@ */ DisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds() { + this._bounds.clear(); + this._cacheData.sprite.transform._worldID = this.transform._worldID; this._cacheData.sprite._calculateBounds(); + this._lastBoundsID = this._boundsID; }; /**