UNPKG

1.77 kBTypeScriptView Raw
1import { Resource } from './Resource';
2import type { ISize } from '@pixi/math';
3import type { Renderer } from '../../Renderer';
4import type { BaseTexture } from '../BaseTexture';
5import type { GLTexture } from '../GLTexture';
6export type BufferType = null | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array;
7/**
8 * Constructor options for BufferResource.
9 * @memberof PIXI
10 */
11export interface IBufferResourceOptions extends ISize {
12 unpackAlignment?: 1 | 2 | 4 | 8;
13}
14/**
15 * Buffer resource with data of typed array.
16 * @memberof PIXI
17 */
18export declare class BufferResource extends Resource {
19 /** The data of this resource. */
20 data: BufferType;
21 /** The alignment of the rows in the data. */
22 unpackAlignment: 1 | 2 | 4 | 8;
23 /**
24 * @param source - Source buffer
25 * @param options - Options
26 * @param {number} options.width - Width of the texture
27 * @param {number} options.height - Height of the texture
28 * @param {1|2|4|8} [options.unpackAlignment=4] - The alignment of the pixel rows.
29 */
30 constructor(source: BufferType, options: IBufferResourceOptions);
31 /**
32 * Upload the texture to the GPU.
33 * @param renderer - Upload to the renderer
34 * @param baseTexture - Reference to parent texture
35 * @param glTexture - glTexture
36 * @returns - true is success
37 */
38 upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;
39 /** Destroy and don't use after this. */
40 dispose(): void;
41 /**
42 * Used to auto-detect the type of resource.
43 * @param {*} source - The source object
44 * @returns {boolean} `true` if buffer source
45 */
46 static test(source: unknown): source is BufferType;
47}