Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getIndexBuffer(size)
{
// 12 indices is enough for 2 quads
const roundedP2 = nextPow2(Math.ceil(size / 12));
const roundedSizeIndex = log2(roundedP2);
const roundedSize = roundedP2 * 12;
if (this._iBuffers.length <= roundedSizeIndex)
{
this._iBuffers.length = roundedSizeIndex + 1;
}
let buffer = this._iBuffers[roundedSizeIndex];
if (!buffer)
{
this._iBuffers[roundedSizeIndex] = buffer = new Uint16Array(roundedSize);
}
return buffer;
getAttributeBuffer(size)
{
// 8 vertices is enough for 2 quads
const roundedP2 = nextPow2(Math.ceil(size / 8));
const roundedSizeIndex = log2(roundedP2);
const roundedSize = roundedP2 * 8;
if (this._aBuffers.length <= roundedSizeIndex)
{
this._iBuffers.length = roundedSizeIndex + 1;
}
let buffer = this._aBuffers[roundedSize];
if (!buffer)
{
this._aBuffers[roundedSize] = buffer = new ViewableBuffer(roundedSize * this.vertexSize * 4);
}
return buffer;
getIndexBuffer(size)
{
// 12 indices is enough for 2 quads
const roundedP2 = nextPow2(Math.ceil(size / 12));
const roundedSizeIndex = log2(roundedP2);
const roundedSize = roundedP2 * 12;
if (this._iBuffers.length <= roundedSizeIndex)
{
this._iBuffers.length = roundedSizeIndex + 1;
}
let buffer = this._iBuffers[roundedSizeIndex];
if (!buffer)
{
this._iBuffers[roundedSizeIndex] = buffer = new Uint16Array(roundedSize);
}
return buffer;
getAttributeBuffer(size)
{
// 8 vertices is enough for 2 quads
const roundedP2 = nextPow2(Math.ceil(size / 8));
const roundedSizeIndex = log2(roundedP2);
const roundedSize = roundedP2 * 8;
if (this._aBuffers.length <= roundedSizeIndex)
{
this._iBuffers.length = roundedSizeIndex + 1;
}
let buffer = this._aBuffers[roundedSize];
if (!buffer)
{
this._aBuffers[roundedSize] = buffer = new ViewableBuffer(roundedSize * this.vertexSize * 4);
}
return buffer;
getOptimalFilterTexture(minWidth, minHeight, resolution = 1)
{
let key = screenKey;
minWidth *= resolution;
minHeight *= resolution;
if (minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight)
{
minWidth = nextPow2(minWidth);
minHeight = nextPow2(minHeight);
key = ((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF);
}
if (!this.texturePool[key])
{
this.texturePool[key] = [];
}
let renderTexture = this.texturePool[key].pop();
if (!renderTexture)
{
renderTexture = RenderTexture.create({
width: minWidth,
height: minHeight,
});
getOptimalTexture(minWidth, minHeight, resolution = 1)
{
let key = RenderTexturePool.SCREEN_KEY;
minWidth *= resolution;
minHeight *= resolution;
if (!this.enableFullScreen || minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight)
{
minWidth = nextPow2(minWidth);
minHeight = nextPow2(minHeight);
key = ((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF);
}
if (!this.texturePool[key])
{
this.texturePool[key] = [];
}
let renderTexture = this.texturePool[key].pop();
if (!renderTexture)
{
renderTexture = this.createTexture(minWidth, minHeight);
}
getOptimalFilterTexture(minWidth, minHeight, resolution = 1)
{
let key = screenKey;
minWidth *= resolution;
minHeight *= resolution;
if (minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight)
{
minWidth = nextPow2(minWidth);
minHeight = nextPow2(minHeight);
key = ((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF);
}
if (!this.texturePool[key])
{
this.texturePool[key] = [];
}
let renderTexture = this.texturePool[key].pop();
if (!renderTexture)
{
renderTexture = RenderTexture.create({
width: minWidth,
height: minHeight,
getOptimalTexture(minWidth, minHeight, resolution = 1)
{
let key = RenderTexturePool.SCREEN_KEY;
minWidth *= resolution;
minHeight *= resolution;
if (!this.enableFullScreen || minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight)
{
minWidth = nextPow2(minWidth);
minHeight = nextPow2(minHeight);
key = ((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF);
}
if (!this.texturePool[key])
{
this.texturePool[key] = [];
}
let renderTexture = this.texturePool[key].pop();
if (!renderTexture)
{
renderTexture = this.createTexture(minWidth, minHeight);
}
renderTexture.filterPoolKey = key;