UNPKG

2.8 kBTypeScriptView Raw
1import { GC_MODES } from '@pixi/constants';
2import type { ExtensionMetadata } from '@pixi/extensions';
3import type { Renderer } from '../Renderer';
4import type { RenderTexture } from '../renderTexture/RenderTexture';
5import type { ISystem } from '../system/ISystem';
6import type { Texture } from './Texture';
7export interface IUnloadableTexture {
8 _texture: Texture | RenderTexture;
9 children: IUnloadableTexture[];
10}
11/**
12 * System plugin to the renderer to manage texture garbage collection on the GPU,
13 * ensuring that it does not get clogged up with textures that are no longer being used.
14 * @memberof PIXI
15 */
16export declare class TextureGCSystem implements ISystem {
17 /**
18 * Default garbage collection mode.
19 * @static
20 * @type {PIXI.GC_MODES}
21 * @default PIXI.GC_MODES.AUTO
22 * @see PIXI.TextureGCSystem#mode
23 */
24 static defaultMode: GC_MODES;
25 /**
26 * Default maximum idle frames before a texture is destroyed by garbage collection.
27 * @static
28 * @default 3600
29 * @see PIXI.TextureGCSystem#maxIdle
30 */
31 static defaultMaxIdle: number;
32 /**
33 * Default frames between two garbage collections.
34 * @static
35 * @default 600
36 * @see PIXI.TextureGCSystem#checkCountMax
37 */
38 static defaultCheckCountMax: number;
39 /** @ignore */
40 static extension: ExtensionMetadata;
41 /**
42 * Frame count since started.
43 * @readonly
44 */
45 count: number;
46 /**
47 * Frame count since last garbage collection.
48 * @readonly
49 */
50 checkCount: number;
51 /**
52 * Maximum idle frames before a texture is destroyed by garbage collection.
53 * @see PIXI.TextureGCSystem.defaultMaxIdle
54 */
55 maxIdle: number;
56 /**
57 * Frames between two garbage collections.
58 * @see PIXI.TextureGCSystem.defaultCheckCountMax
59 */
60 checkCountMax: number;
61 /**
62 * Current garbage collection mode.
63 * @see PIXI.TextureGCSystem.defaultMode
64 */
65 mode: GC_MODES;
66 private renderer;
67 /** @param renderer - The renderer this System works for. */
68 constructor(renderer: Renderer);
69 /**
70 * Checks to see when the last time a texture was used.
71 * If the texture has not been used for a specified amount of time, it will be removed from the GPU.
72 */
73 protected postrender(): void;
74 /**
75 * Checks to see when the last time a texture was used.
76 * If the texture has not been used for a specified amount of time, it will be removed from the GPU.
77 */
78 run(): void;
79 /**
80 * Removes all the textures within the specified displayObject and its children from the GPU.
81 * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from.
82 */
83 unload(displayObject: IUnloadableTexture): void;
84 destroy(): void;
85}