Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
// We also store the filter stack - I will definitely look to change how this works a little later down the line.
// const stack = renderer.filterManager.filterStack;
// this renderTexture will be used to store the cached DisplayObject
const renderTexture = RenderTexture.create(bounds.width, bounds.height);
const textureCacheId = `cacheAsBitmap_${uid()}`;
this._cacheData.textureCacheId = textureCacheId;
BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);
Texture.addToCache(renderTexture, textureCacheId);
// need to set //
const m = _tempMatrix;
m.tx = -bounds.x;
m.ty = -bounds.y;
// reset
this.transform.worldTransform.identity();
// set all properties to there original so we can render to a texture
static from(source, options, strict = settings.STRICT_TEXTURE_CACHE)
{
const isFrame = typeof source === 'string';
let cacheId = null;
if (isFrame)
{
cacheId = source;
}
else
{
if (!source._pixiId)
{
source._pixiId = `pixiid_${uid()}`;
}
cacheId = source._pixiId;
}
let baseTexture = BaseTextureCache[cacheId];
// Strict-mode rejects invalid cacheIds
if (isFrame && strict && !baseTexture)
{
throw new Error(`The cacheId "${cacheId}" does not exist in BaseTextureCache.`);
}
if (!baseTexture)
{
baseTexture = new BaseTexture(source, options);
*/
this.alphaMode = alphaMode !== undefined ? alphaMode : ALPHA_MODES.UNPACK;
if (options.premultiplyAlpha !== undefined)
{
// triggers deprecation
this.premultiplyAlpha = options.premultiplyAlpha;
}
/**
* Global unique identifier for this BaseTexture
*
* @member {string}
* @protected
*/
this.uid = uid();
/**
* Used by automatic texture Garbage Collection, stores last GC tick when it was bound
*
* @member {number}
* @protected
*/
this.touched = 0;
/**
* Whether or not the texture is a power of two, try to use power of two textures as much
* as you can
*
* @readonly
* @member {boolean}
* @default false
static from(source, options = {}, strict = settings.STRICT_TEXTURE_CACHE)
{
const isFrame = typeof source === 'string';
let cacheId = null;
if (isFrame)
{
cacheId = source;
}
else
{
if (!source._pixiId)
{
source._pixiId = `pixiid_${uid()}`;
}
cacheId = source._pixiId;
}
let texture = TextureCache[cacheId];
// Strict-mode rejects invalid cacheIds
if (isFrame && strict && !texture)
{
throw new Error(`The cacheId "${cacheId}" does not exist in TextureCache.`);
}
if (!texture)
{
if (!options.resolution)
}
// get bounds actually transforms the object for us already!
const bounds = this.getLocalBounds();
const cacheAlpha = this.alpha;
this.alpha = 1;
const cachedRenderTarget = renderer.context;
bounds.ceil(settings.RESOLUTION);
const renderTexture = RenderTexture.create(bounds.width, bounds.height);
const textureCacheId = `cacheAsBitmap_${uid()}`;
this._cacheData.textureCacheId = textureCacheId;
BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);
Texture.addToCache(renderTexture, textureCacheId);
// need to set //
const m = _tempMatrix;
this.transform.localTransform.copyTo(m);
m.invert();
m.tx -= bounds.x;
m.ty -= bounds.y;
// m.append(this.transform.worldTransform.)
static fromVideo(video, scaleMode)
{
if (!video._pixiId)
{
video._pixiId = `video_${uid()}`;
}
let baseTexture = BaseTextureCache[video._pixiId];
if (!baseTexture)
{
baseTexture = new VideoBaseTexture(video, scaleMode);
BaseTexture.addToCache(baseTexture, video._pixiId);
}
return baseTexture;
}
let cacheId = null;
if (typeof source === 'string')
{
cacheId = source;
if (!options.resolution)
{
options.resolution = getResolutionOfUrl(source);
}
}
else
{
if (!source._pixiId)
{
source._pixiId = `pixiid_${uid()}`;
}
cacheId = source._pixiId;
}
let texture = TextureCache[cacheId];
if (!texture)
{
texture = new Texture(new BaseTexture(source, options));
texture.baseTexture.cacheId = cacheId;
BaseTexture.addToCache(texture.baseTexture, cacheId);
Texture.addToCache(texture, cacheId);
}