1 | import { Runner } from '@pixi/runner';
|
2 | import type { Renderer } from '../../Renderer';
|
3 | import type { BaseTexture } from '../BaseTexture';
|
4 | import type { GLTexture } from '../GLTexture';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export declare abstract class Resource {
|
12 |
|
13 | src: string;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | destroyed: boolean;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | internal: boolean;
|
27 |
|
28 | protected _width: number;
|
29 |
|
30 | protected _height: number;
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | protected onResize: Runner;
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 | protected onUpdate: Runner;
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | protected onError: Runner;
|
51 | |
52 |
|
53 |
|
54 |
|
55 | constructor(width?: number, height?: number);
|
56 | /**
|
57 | * Bind to a parent BaseTexture
|
58 | * @param baseTexture - Parent texture
|
59 | */
|
60 | bind(baseTexture: BaseTexture): void;
|
61 | /**
|
62 | * Unbind to a parent BaseTexture
|
63 | * @param baseTexture - Parent texture
|
64 | */
|
65 | unbind(baseTexture: BaseTexture): void;
|
66 | /**
|
67 | * Trigger a resize event
|
68 | * @param width - X dimension
|
69 | * @param height - Y dimension
|
70 | */
|
71 | resize(width: number, height: number): void;
|
72 | /**
|
73 | * Has been validated
|
74 | * @readonly
|
75 | */
|
76 | get valid(): boolean;
|
77 | /** Has been updated trigger event. */
|
78 | update(): void;
|
79 | /**
|
80 | * This can be overridden to start preloading a resource
|
81 | * or do any other prepare step.
|
82 | * @protected
|
83 | * @returns Handle the validate event
|
84 | */
|
85 | load(): Promise<Resource>;
|
86 | /**
|
87 | * The width of the resource.
|
88 | * @readonly
|
89 | */
|
90 | get width(): number;
|
91 | /**
|
92 | * The height of the resource.
|
93 | * @readonly
|
94 | */
|
95 | get height(): number;
|
96 | /**
|
97 | * Uploads the texture or returns false if it cant for some reason. Override this.
|
98 | * @param renderer - yeah, renderer!
|
99 | * @param baseTexture - the texture
|
100 | * @param glTexture - texture instance for this webgl context
|
101 | * @returns - true is success
|
102 | */
|
103 | abstract upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;
|
104 | /**
|
105 | * Set the style, optional to override
|
106 | * @param _renderer - yeah, renderer!
|
107 | * @param _baseTexture - the texture
|
108 | * @param _glTexture - texture instance for this webgl context
|
109 | * @returns - `true` is success
|
110 | */
|
111 | style(_renderer: Renderer, _baseTexture: BaseTexture, _glTexture: GLTexture): boolean;
|
112 | /** Clean up anything, this happens when destroying is ready. */
|
113 | dispose(): void;
|
114 | /**
|
115 | * Call when destroying resource, unbind any BaseTexture object
|
116 | * before calling this method, as reference counts are maintained
|
117 | * internally.
|
118 | */
|
119 | destroy(): void;
|
120 | /**
|
121 | * Abstract, used to auto-detect resource type.
|
122 | * @param {*} _source - The source object
|
123 | * @param {string} _extension - The extension of source, if set
|
124 | */
|
125 | static test(_source: unknown, _extension?: string): boolean;
|
126 | }
|