- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
import { BaseRenderTexture, RenderTexture } from '@pixi/core';
import { GuilloteneAllocator } from '@pixi-essentials/area-allocator';
import { TextureAllocator } from './TextureAllocator';
import type { BaseTexture } from '@pixi/core';
import type { Rectangle } from '@pixi/math';
import type { TextureSlab } from './TextureSlab';
/**
* This allocator issues render-textures, and is otherwise just like {@link TextureAllocator}.
*
* @public
*/
export class RenderTextureAllocator extends TextureAllocator<RenderTexture>
{
/**
* Creates a texture slab backed by a base render-texture.
*/
protected createSlab(): TextureSlab
{
return {
managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),
managedTextures: [],
slab: new BaseRenderTexture({
width: this.slabWidth,
height: this.slabHeight
})
};
}
/**
* Creates a render-texture from the given base render-texture.
*
* @param baseTexture
* @param frame
*/
protected createTexture(baseTexture: BaseTexture, frame: Rectangle): RenderTexture
{
return new RenderTexture(baseTexture as BaseRenderTexture, frame);
}
}