@pixi/mixin-cache-as-bitmap
Advanced tools
Comparing version 6.0.0-rc.3 to 6.0.0
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -15,2 +15,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
display.DisplayObject.prototype._cacheData = null; | ||
display.DisplayObject.prototype._cacheAsBitmapResolution = null; | ||
// figured there's no point adding ALL the extra variables to prototype. | ||
@@ -42,2 +43,28 @@ // this model can hold the information needed. This can also be generated on demand as | ||
/** | ||
* The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution | ||
* but can be overriden for performance. Lower values will reduce memory usage at the expense | ||
* of render quality. A falsey value of `null` or `0` will default to the renderer's resolution. | ||
* If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution. | ||
* | ||
* @member {number} cacheAsBitmapResolution | ||
* @memberof PIXI.DisplayObject# | ||
* @default null | ||
*/ | ||
cacheAsBitmapResolution: { | ||
get: function () { | ||
return this._cacheAsBitmapResolution; | ||
}, | ||
set: function (resolution) { | ||
if (resolution === this._cacheAsBitmapResolution) { | ||
return; | ||
} | ||
this._cacheAsBitmapResolution = resolution; | ||
if (this.cacheAsBitmap) { | ||
// Toggle to re-render at the new resolution | ||
this.cacheAsBitmap = false; | ||
this.cacheAsBitmap = true; | ||
} | ||
}, | ||
}, | ||
/** | ||
* Set this to true if you want this display object to be cached as a bitmap. | ||
@@ -154,3 +181,7 @@ * This basically takes a snap shot of the display object as it is at that moment. It can | ||
// this renderTexture will be used to store the cached DisplayObject | ||
var renderTexture = core.RenderTexture.create({ width: bounds.width, height: bounds.height }); | ||
var renderTexture = core.RenderTexture.create({ | ||
width: bounds.width, | ||
height: bounds.height, | ||
resolution: this.cacheAsBitmapResolution || renderer.resolution, | ||
}); | ||
var textureCacheId = "cacheAsBitmap_" + utils.uid(); | ||
@@ -164,3 +195,3 @@ this._cacheData.textureCacheId = textureCacheId; | ||
this.render = this._cacheData.originalRender; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -248,3 +279,3 @@ renderer.projection.transform = cachedProjectionTransform; | ||
this.renderCanvas = this._cacheData.originalRenderCanvas; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -251,0 +282,0 @@ renderer.context = cachedRenderTarget; |
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
*/ | ||
this.PIXI=this.PIXI||{};var _pixi_mixin_cache_as_bitmap=function(t,a,e,i,s,r,n){"use strict";var h=new s.Matrix;i.DisplayObject.prototype._cacheAsBitmap=!1,i.DisplayObject.prototype._cacheData=null;var o=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();return Object.defineProperties(i.DisplayObject.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new o),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),i.DisplayObject.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},i.DisplayObject.prototype._initCachedDisplayObject=function(t){if(!this._cacheData||!this._cacheData.sprite){var i=this.alpha;this.alpha=1,t.batch.flush();var s=this.getLocalBounds(null,!0).clone();if(this.filters){var o=this.filters[0].padding;s.pad(o)}s.ceil(n.settings.RESOLUTION);var c=t.renderTexture.current,l=t.renderTexture.sourceFrame.clone(),d=t.projection.transform,u=a.RenderTexture.create({width:s.width,height:s.height}),p="cacheAsBitmap_"+r.uid();this._cacheData.textureCacheId=p,a.BaseTexture.addToCache(u.baseTexture,p),a.Texture.addToCache(u,p);var _=this.transform.localTransform.copyTo(h).invert().translate(-s.x,-s.y);this.render=this._cacheData.originalRender,t.render(this,u,!0,_,!1),t.projection.transform=d,t.renderTexture.bind(c,l),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var D=new e.Sprite(u);D.transform.worldTransform=this.transform.worldTransform,D.anchor.x=-s.x/s.width,D.anchor.y=-s.y/s.height,D.alpha=i,D._bounds=this._bounds,this._cacheData.sprite=D,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=D.containsPoint.bind(D)}},i.DisplayObject.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},i.DisplayObject.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cacheData||!this._cacheData.sprite){var i=this.getLocalBounds(null,!0),s=this.alpha;this.alpha=1;var o=t.context,c=t._projTransform;i.ceil(n.settings.RESOLUTION);var l=a.RenderTexture.create({width:i.width,height:i.height}),d="cacheAsBitmap_"+r.uid();this._cacheData.textureCacheId=d,a.BaseTexture.addToCache(l.baseTexture,d),a.Texture.addToCache(l,d);var u=h;this.transform.localTransform.copyTo(u),u.invert(),u.tx-=i.x,u.ty-=i.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,l,!0,u,!1),t.context=o,t._projTransform=c,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var p=new e.Sprite(l);p.transform.worldTransform=this.transform.worldTransform,p.anchor.x=-i.x/i.width,p.anchor.y=-i.y/i.height,p.alpha=s,p._bounds=this._bounds,this._cacheData.sprite=p,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=p.containsPoint.bind(p)}},i.DisplayObject.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},i.DisplayObject.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},i.DisplayObject.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,a.BaseTexture.removeFromCache(this._cacheData.textureCacheId),a.Texture.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},i.DisplayObject.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},t.CacheData=o,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI); | ||
this.PIXI=this.PIXI||{};var _pixi_mixin_cache_as_bitmap=function(t,a,e,i,s,r,n){"use strict";var h=new s.Matrix;i.DisplayObject.prototype._cacheAsBitmap=!1,i.DisplayObject.prototype._cacheData=null,i.DisplayObject.prototype._cacheAsBitmapResolution=null;var o=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();return Object.defineProperties(i.DisplayObject.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(t){t!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new o),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),i.DisplayObject.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},i.DisplayObject.prototype._initCachedDisplayObject=function(t){if(!this._cacheData||!this._cacheData.sprite){var i=this.alpha;this.alpha=1,t.batch.flush();var s=this.getLocalBounds(null,!0).clone();if(this.filters){var o=this.filters[0].padding;s.pad(o)}s.ceil(n.settings.RESOLUTION);var c=t.renderTexture.current,l=t.renderTexture.sourceFrame.clone(),d=t.projection.transform,p=a.RenderTexture.create({width:s.width,height:s.height,resolution:this.cacheAsBitmapResolution||t.resolution}),u="cacheAsBitmap_"+r.uid();this._cacheData.textureCacheId=u,a.BaseTexture.addToCache(p.baseTexture,u),a.Texture.addToCache(p,u);var _=this.transform.localTransform.copyTo(h).invert().translate(-s.x,-s.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:p,clear:!0,transform:_,skipUpdateTransform:!1}),t.projection.transform=d,t.renderTexture.bind(c,l),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var m=new e.Sprite(p);m.transform.worldTransform=this.transform.worldTransform,m.anchor.x=-s.x/s.width,m.anchor.y=-s.y/s.height,m.alpha=i,m._bounds=this._bounds,this._cacheData.sprite=m,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=m.containsPoint.bind(m)}},i.DisplayObject.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},i.DisplayObject.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cacheData||!this._cacheData.sprite){var i=this.getLocalBounds(null,!0),s=this.alpha;this.alpha=1;var o=t.context,c=t._projTransform;i.ceil(n.settings.RESOLUTION);var l=a.RenderTexture.create({width:i.width,height:i.height}),d="cacheAsBitmap_"+r.uid();this._cacheData.textureCacheId=d,a.BaseTexture.addToCache(l.baseTexture,d),a.Texture.addToCache(l,d);var p=h;this.transform.localTransform.copyTo(p),p.invert(),p.tx-=i.x,p.ty-=i.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:l,clear:!0,transform:p,skipUpdateTransform:!1}),t.context=o,t._projTransform=c,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var u=new e.Sprite(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-i.x/i.width,u.anchor.y=-i.y/i.height,u.alpha=s,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)}},i.DisplayObject.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},i.DisplayObject.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},i.DisplayObject.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,a.BaseTexture.removeFromCache(this._cacheData.textureCacheId),a.Texture.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},i.DisplayObject.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},t.CacheData=o,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI); | ||
//# sourceMappingURL=mixin-cache-as-bitmap.min.js.map |
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -22,2 +22,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
display.DisplayObject.prototype._cacheData = null; | ||
display.DisplayObject.prototype._cacheAsBitmapResolution = null; | ||
// figured there's no point adding ALL the extra variables to prototype. | ||
@@ -49,2 +50,28 @@ // this model can hold the information needed. This can also be generated on demand as | ||
/** | ||
* The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution | ||
* but can be overriden for performance. Lower values will reduce memory usage at the expense | ||
* of render quality. A falsey value of `null` or `0` will default to the renderer's resolution. | ||
* If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution. | ||
* | ||
* @member {number} cacheAsBitmapResolution | ||
* @memberof PIXI.DisplayObject# | ||
* @default null | ||
*/ | ||
cacheAsBitmapResolution: { | ||
get: function () { | ||
return this._cacheAsBitmapResolution; | ||
}, | ||
set: function (resolution) { | ||
if (resolution === this._cacheAsBitmapResolution) { | ||
return; | ||
} | ||
this._cacheAsBitmapResolution = resolution; | ||
if (this.cacheAsBitmap) { | ||
// Toggle to re-render at the new resolution | ||
this.cacheAsBitmap = false; | ||
this.cacheAsBitmap = true; | ||
} | ||
}, | ||
}, | ||
/** | ||
* Set this to true if you want this display object to be cached as a bitmap. | ||
@@ -161,3 +188,7 @@ * This basically takes a snap shot of the display object as it is at that moment. It can | ||
// this renderTexture will be used to store the cached DisplayObject | ||
var renderTexture = core.RenderTexture.create({ width: bounds.width, height: bounds.height }); | ||
var renderTexture = core.RenderTexture.create({ | ||
width: bounds.width, | ||
height: bounds.height, | ||
resolution: this.cacheAsBitmapResolution || renderer.resolution, | ||
}); | ||
var textureCacheId = "cacheAsBitmap_" + utils.uid(); | ||
@@ -171,3 +202,3 @@ this._cacheData.textureCacheId = textureCacheId; | ||
this.render = this._cacheData.originalRender; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -255,3 +286,3 @@ renderer.projection.transform = cachedProjectionTransform; | ||
this.renderCanvas = this._cacheData.originalRenderCanvas; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -258,0 +289,0 @@ renderer.context = cachedRenderTarget; |
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@pixi/core"),sprite=require("@pixi/sprite"),display=require("@pixi/display"),math=require("@pixi/math"),utils=require("@pixi/utils"),settings=require("@pixi/settings"),_tempMatrix=new math.Matrix;display.DisplayObject.prototype._cacheAsBitmap=!1,display.DisplayObject.prototype._cacheData=null;var CacheData=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();Object.defineProperties(display.DisplayObject.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new CacheData),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),display.DisplayObject.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},display.DisplayObject.prototype._initCachedDisplayObject=function(t){if(!this._cacheData||!this._cacheData.sprite){var a=this.alpha;this.alpha=1,t.batch.flush();var e=this.getLocalBounds(null,!0).clone();if(this.filters){var i=this.filters[0].padding;e.pad(i)}e.ceil(settings.settings.RESOLUTION);var s=t.renderTexture.current,r=t.renderTexture.sourceFrame.clone(),n=t.projection.transform,h=core.RenderTexture.create({width:e.width,height:e.height}),o="cacheAsBitmap_"+utils.uid();this._cacheData.textureCacheId=o,core.BaseTexture.addToCache(h.baseTexture,o),core.Texture.addToCache(h,o);var c=this.transform.localTransform.copyTo(_tempMatrix).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,t.render(this,h,!0,c,!1),t.projection.transform=n,t.renderTexture.bind(s,r),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var l=new sprite.Sprite(h);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-e.x/e.width,l.anchor.y=-e.y/e.height,l.alpha=a,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=l.containsPoint.bind(l)}},display.DisplayObject.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},display.DisplayObject.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cacheData||!this._cacheData.sprite){var a=this.getLocalBounds(null,!0),e=this.alpha;this.alpha=1;var i=t.context,s=t._projTransform;a.ceil(settings.settings.RESOLUTION);var r=core.RenderTexture.create({width:a.width,height:a.height}),n="cacheAsBitmap_"+utils.uid();this._cacheData.textureCacheId=n,core.BaseTexture.addToCache(r.baseTexture,n),core.Texture.addToCache(r,n);var h=_tempMatrix;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=a.x,h.ty-=a.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,r,!0,h,!1),t.context=i,t._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var o=new sprite.Sprite(r);o.transform.worldTransform=this.transform.worldTransform,o.anchor.x=-a.x/a.width,o.anchor.y=-a.y/a.height,o.alpha=e,o._bounds=this._bounds,this._cacheData.sprite=o,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=o.containsPoint.bind(o)}},display.DisplayObject.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},display.DisplayObject.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},display.DisplayObject.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,core.BaseTexture.removeFromCache(this._cacheData.textureCacheId),core.Texture.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},display.DisplayObject.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},exports.CacheData=CacheData; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@pixi/core"),sprite=require("@pixi/sprite"),display=require("@pixi/display"),math=require("@pixi/math"),utils=require("@pixi/utils"),settings=require("@pixi/settings"),_tempMatrix=new math.Matrix;display.DisplayObject.prototype._cacheAsBitmap=!1,display.DisplayObject.prototype._cacheData=null,display.DisplayObject.prototype._cacheAsBitmapResolution=null;var CacheData=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();Object.defineProperties(display.DisplayObject.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(t){t!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new CacheData),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),display.DisplayObject.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},display.DisplayObject.prototype._initCachedDisplayObject=function(t){if(!this._cacheData||!this._cacheData.sprite){var a=this.alpha;this.alpha=1,t.batch.flush();var e=this.getLocalBounds(null,!0).clone();if(this.filters){var i=this.filters[0].padding;e.pad(i)}e.ceil(settings.settings.RESOLUTION);var s=t.renderTexture.current,r=t.renderTexture.sourceFrame.clone(),n=t.projection.transform,h=core.RenderTexture.create({width:e.width,height:e.height,resolution:this.cacheAsBitmapResolution||t.resolution}),o="cacheAsBitmap_"+utils.uid();this._cacheData.textureCacheId=o,core.BaseTexture.addToCache(h.baseTexture,o),core.Texture.addToCache(h,o);var c=this.transform.localTransform.copyTo(_tempMatrix).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,t.render(this,{renderTexture:h,clear:!0,transform:c,skipUpdateTransform:!1}),t.projection.transform=n,t.renderTexture.bind(s,r),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var l=new sprite.Sprite(h);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-e.x/e.width,l.anchor.y=-e.y/e.height,l.alpha=a,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=l.containsPoint.bind(l)}},display.DisplayObject.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},display.DisplayObject.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cacheData||!this._cacheData.sprite){var a=this.getLocalBounds(null,!0),e=this.alpha;this.alpha=1;var i=t.context,s=t._projTransform;a.ceil(settings.settings.RESOLUTION);var r=core.RenderTexture.create({width:a.width,height:a.height}),n="cacheAsBitmap_"+utils.uid();this._cacheData.textureCacheId=n,core.BaseTexture.addToCache(r.baseTexture,n),core.Texture.addToCache(r,n);var h=_tempMatrix;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=a.x,h.ty-=a.y,this.renderCanvas=this._cacheData.originalRenderCanvas,t.render(this,{renderTexture:r,clear:!0,transform:h,skipUpdateTransform:!1}),t.context=i,t._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var o=new sprite.Sprite(r);o.transform.worldTransform=this.transform.worldTransform,o.anchor.x=-a.x/a.width,o.anchor.y=-a.y/a.height,o.alpha=e,o._bounds=this._bounds,this._cacheData.sprite=o,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=t._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=o.containsPoint.bind(o)}},display.DisplayObject.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},display.DisplayObject.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},display.DisplayObject.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,core.BaseTexture.removeFromCache(this._cacheData.textureCacheId),core.Texture.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},display.DisplayObject.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)},exports.CacheData=CacheData; | ||
//# sourceMappingURL=mixin-cache-as-bitmap.min.js.map |
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -18,2 +18,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
DisplayObject.prototype._cacheData = null; | ||
DisplayObject.prototype._cacheAsBitmapResolution = null; | ||
// figured there's no point adding ALL the extra variables to prototype. | ||
@@ -45,2 +46,28 @@ // this model can hold the information needed. This can also be generated on demand as | ||
/** | ||
* The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution | ||
* but can be overriden for performance. Lower values will reduce memory usage at the expense | ||
* of render quality. A falsey value of `null` or `0` will default to the renderer's resolution. | ||
* If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution. | ||
* | ||
* @member {number} cacheAsBitmapResolution | ||
* @memberof PIXI.DisplayObject# | ||
* @default null | ||
*/ | ||
cacheAsBitmapResolution: { | ||
get: function () { | ||
return this._cacheAsBitmapResolution; | ||
}, | ||
set: function (resolution) { | ||
if (resolution === this._cacheAsBitmapResolution) { | ||
return; | ||
} | ||
this._cacheAsBitmapResolution = resolution; | ||
if (this.cacheAsBitmap) { | ||
// Toggle to re-render at the new resolution | ||
this.cacheAsBitmap = false; | ||
this.cacheAsBitmap = true; | ||
} | ||
}, | ||
}, | ||
/** | ||
* Set this to true if you want this display object to be cached as a bitmap. | ||
@@ -157,3 +184,7 @@ * This basically takes a snap shot of the display object as it is at that moment. It can | ||
// this renderTexture will be used to store the cached DisplayObject | ||
var renderTexture = RenderTexture.create({ width: bounds.width, height: bounds.height }); | ||
var renderTexture = RenderTexture.create({ | ||
width: bounds.width, | ||
height: bounds.height, | ||
resolution: this.cacheAsBitmapResolution || renderer.resolution, | ||
}); | ||
var textureCacheId = "cacheAsBitmap_" + uid(); | ||
@@ -167,3 +198,3 @@ this._cacheData.textureCacheId = textureCacheId; | ||
this.render = this._cacheData.originalRender; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -251,3 +282,3 @@ renderer.projection.transform = cachedProjectionTransform; | ||
this.renderCanvas = this._cacheData.originalRenderCanvas; | ||
renderer.render(this, renderTexture, true, m, false); | ||
renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false }); | ||
// now restore the state be setting the new properties | ||
@@ -254,0 +285,0 @@ renderer.context = cachedRenderTarget; |
/*! | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0-rc.3 | ||
* Compiled Sat, 20 Feb 2021 22:50:47 UTC | ||
* @pixi/mixin-cache-as-bitmap - v6.0.0 | ||
* Compiled Tue, 02 Mar 2021 21:45:03 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. | ||
*/ | ||
import{RenderTexture as t,BaseTexture as a,Texture as i}from"@pixi/core";import{Sprite as e}from"@pixi/sprite";import{DisplayObject as r}from"@pixi/display";import{Matrix as s}from"@pixi/math";import{uid as n}from"@pixi/utils";import{settings as h}from"@pixi/settings";var o=new s;r.prototype._cacheAsBitmap=!1,r.prototype._cacheData=null;var c=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();Object.defineProperties(r.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new c),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),r.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},r.prototype._initCachedDisplayObject=function(r){if(!this._cacheData||!this._cacheData.sprite){var s=this.alpha;this.alpha=1,r.batch.flush();var c=this.getLocalBounds(null,!0).clone();if(this.filters){var l=this.filters[0].padding;c.pad(l)}c.ceil(h.RESOLUTION);var d=r.renderTexture.current,p=r.renderTexture.sourceFrame.clone(),u=r.projection.transform,_=t.create({width:c.width,height:c.height}),m="cacheAsBitmap_"+n();this._cacheData.textureCacheId=m,a.addToCache(_.baseTexture,m),i.addToCache(_,m);var f=this.transform.localTransform.copyTo(o).invert().translate(-c.x,-c.y);this.render=this._cacheData.originalRender,r.render(this,_,!0,f,!1),r.projection.transform=u,r.renderTexture.bind(d,p),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var C=new e(_);C.transform.worldTransform=this.transform.worldTransform,C.anchor.x=-c.x/c.width,C.anchor.y=-c.y/c.height,C.alpha=s,C._bounds=this._bounds,this._cacheData.sprite=C,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=C.containsPoint.bind(C)}},r.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},r.prototype._initCachedDisplayObjectCanvas=function(r){if(!this._cacheData||!this._cacheData.sprite){var s=this.getLocalBounds(null,!0),c=this.alpha;this.alpha=1;var l=r.context,d=r._projTransform;s.ceil(h.RESOLUTION);var p=t.create({width:s.width,height:s.height}),u="cacheAsBitmap_"+n();this._cacheData.textureCacheId=u,a.addToCache(p.baseTexture,u),i.addToCache(p,u);var _=o;this.transform.localTransform.copyTo(_),_.invert(),_.tx-=s.x,_.ty-=s.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,p,!0,_,!1),r.context=l,r._projTransform=d,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var m=new e(p);m.transform.worldTransform=this.transform.worldTransform,m.anchor.x=-s.x/s.width,m.anchor.y=-s.y/s.height,m.alpha=c,m._bounds=this._bounds,this._cacheData.sprite=m,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=m.containsPoint.bind(m)}},r.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},r.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},r.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,a.removeFromCache(this._cacheData.textureCacheId),i.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},r.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)};export{c as CacheData}; | ||
import{RenderTexture as t,BaseTexture as a,Texture as e}from"@pixi/core";import{Sprite as i}from"@pixi/sprite";import{DisplayObject as r}from"@pixi/display";import{Matrix as s}from"@pixi/math";import{uid as n}from"@pixi/utils";import{settings as h}from"@pixi/settings";var o=new s;r.prototype._cacheAsBitmap=!1,r.prototype._cacheData=null,r.prototype._cacheAsBitmapResolution=null;var c=function(){return function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}();Object.defineProperties(r.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(t){t!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=t,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){var a;this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._cacheData||(this._cacheData=new c),(a=this._cacheData).originalRender=this.render,a.originalRenderCanvas=this.renderCanvas,a.originalUpdateTransform=this.updateTransform,a.originalCalculateBounds=this.calculateBounds,a.originalGetLocalBounds=this.getLocalBounds,a.originalDestroy=this.destroy,a.originalContainsPoint=this.containsPoint,a.originalMask=this._mask,a.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((a=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=a.originalRender,this.renderCanvas=a.originalRenderCanvas,this.calculateBounds=a.originalCalculateBounds,this.getLocalBounds=a.originalGetLocalBounds,this.destroy=a.originalDestroy,this.updateTransform=a.originalUpdateTransform,this.containsPoint=a.originalContainsPoint,this._mask=a.originalMask,this.filterArea=a.originalFilterArea))}}}),r.prototype._renderCached=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(t))},r.prototype._initCachedDisplayObject=function(r){if(!this._cacheData||!this._cacheData.sprite){var s=this.alpha;this.alpha=1,r.batch.flush();var c=this.getLocalBounds(null,!0).clone();if(this.filters){var l=this.filters[0].padding;c.pad(l)}c.ceil(h.RESOLUTION);var d=r.renderTexture.current,p=r.renderTexture.sourceFrame.clone(),u=r.projection.transform,m=t.create({width:c.width,height:c.height,resolution:this.cacheAsBitmapResolution||r.resolution}),_="cacheAsBitmap_"+n();this._cacheData.textureCacheId=_,a.addToCache(m.baseTexture,_),e.addToCache(m,_);var f=this.transform.localTransform.copyTo(o).invert().translate(-c.x,-c.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:m,clear:!0,transform:f,skipUpdateTransform:!1}),r.projection.transform=u,r.renderTexture.bind(d,p),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var C=new i(m);C.transform.worldTransform=this.transform.worldTransform,C.anchor.x=-c.x/c.width,C.anchor.y=-c.y/c.height,C.alpha=s,C._bounds=this._bounds,this._cacheData.sprite=C,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=C.containsPoint.bind(C)}},r.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(t))},r.prototype._initCachedDisplayObjectCanvas=function(r){if(!this._cacheData||!this._cacheData.sprite){var s=this.getLocalBounds(null,!0),c=this.alpha;this.alpha=1;var l=r.context,d=r._projTransform;s.ceil(h.RESOLUTION);var p=t.create({width:s.width,height:s.height}),u="cacheAsBitmap_"+n();this._cacheData.textureCacheId=u,a.addToCache(p.baseTexture,u),e.addToCache(p,u);var m=o;this.transform.localTransform.copyTo(m),m.invert(),m.tx-=s.x,m.ty-=s.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:p,clear:!0,transform:m,skipUpdateTransform:!1}),r.context=l,r._projTransform=d,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var _=new i(p);_.transform.worldTransform=this.transform.worldTransform,_.anchor.x=-s.x/s.width,_.anchor.y=-s.y/s.height,_.alpha=c,_._bounds=this._bounds,this._cacheData.sprite=_,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=_.containsPoint.bind(_)}},r.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},r.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},r.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,a.removeFromCache(this._cacheData.textureCacheId),e.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},r.prototype._cacheAsBitmapDestroy=function(t){this.cacheAsBitmap=!1,this.destroy(t)};export{c as CacheData}; | ||
//# sourceMappingURL=mixin-cache-as-bitmap.min.js.map |
@@ -5,2 +5,4 @@ declare namespace GlobalMixins | ||
cacheAsBitmap?: boolean; | ||
cacheAsBitmapResolution?: number; | ||
_cacheAsBitmapResolution?: number; | ||
_cacheAsBitmap?: boolean; | ||
@@ -7,0 +9,0 @@ _cacheData?: import('@pixi/mixin-cache-as-bitmap').CacheData; |
{ | ||
"name": "@pixi/mixin-cache-as-bitmap", | ||
"version": "6.0.0-rc.3", | ||
"version": "6.0.0", | ||
"main": "dist/cjs/mixin-cache-as-bitmap.js", | ||
@@ -29,11 +29,11 @@ "module": "dist/esm/mixin-cache-as-bitmap.js", | ||
"dependencies": { | ||
"@pixi/canvas-renderer": "6.0.0-rc.3", | ||
"@pixi/core": "6.0.0-rc.3", | ||
"@pixi/display": "6.0.0-rc.3", | ||
"@pixi/math": "6.0.0-rc.3", | ||
"@pixi/settings": "6.0.0-rc.3", | ||
"@pixi/sprite": "6.0.0-rc.3", | ||
"@pixi/utils": "6.0.0-rc.3" | ||
"@pixi/canvas-renderer": "6.0.0", | ||
"@pixi/core": "6.0.0", | ||
"@pixi/display": "6.0.0", | ||
"@pixi/math": "6.0.0", | ||
"@pixi/settings": "6.0.0", | ||
"@pixi/sprite": "6.0.0", | ||
"@pixi/utils": "6.0.0" | ||
}, | ||
"gitHead": "6ea4d4077ffc05e8275bb1993ce77727e99da145" | ||
"gitHead": "40b8c8d7d1a3e99df059b5d5c582975eb536b30a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
212109
1218
1
+ Added@pixi/canvas-renderer@6.0.0(transitive)
+ Added@pixi/constants@6.0.0(transitive)
+ Added@pixi/core@6.0.0(transitive)
+ Added@pixi/display@6.0.0(transitive)
+ Added@pixi/math@6.0.0(transitive)
+ Added@pixi/runner@6.0.0(transitive)
+ Added@pixi/settings@6.0.0(transitive)
+ Added@pixi/sprite@6.0.0(transitive)
+ Added@pixi/ticker@6.0.0(transitive)
+ Added@pixi/utils@6.0.0(transitive)
- Removed@pixi/canvas-renderer@6.0.0-rc.3(transitive)
- Removed@pixi/constants@6.0.0-rc.3(transitive)
- Removed@pixi/core@6.0.0-rc.3(transitive)
- Removed@pixi/display@6.0.0-rc.3(transitive)
- Removed@pixi/math@6.0.0-rc.3(transitive)
- Removed@pixi/runner@6.0.0-rc.3(transitive)
- Removed@pixi/settings@6.0.0-rc.3(transitive)
- Removed@pixi/sprite@6.0.0-rc.3(transitive)
- Removed@pixi/ticker@6.0.0-rc.3(transitive)
- Removed@pixi/utils@6.0.0-rc.3(transitive)
Updated@pixi/canvas-renderer@6.0.0
Updated@pixi/core@6.0.0
Updated@pixi/display@6.0.0
Updated@pixi/math@6.0.0
Updated@pixi/settings@6.0.0
Updated@pixi/sprite@6.0.0
Updated@pixi/utils@6.0.0