UNPKG

1.7 kBTypeScriptView Raw
1import type { ITypedArray } from './Buffer';
2/**
3 * Flexible wrapper around `ArrayBuffer` that also provides typed array views on demand.
4 * @memberof PIXI
5 */
6export declare class ViewableBuffer {
7 size: number;
8 /** Underlying `ArrayBuffer` that holds all the data and is of capacity `this.size`. */
9 rawBinaryData: ArrayBuffer;
10 /** View on the raw binary data as a `Uint32Array`. */
11 uint32View: Uint32Array;
12 /** View on the raw binary data as a `Float32Array`. */
13 float32View: Float32Array;
14 private _int8View;
15 private _uint8View;
16 private _int16View;
17 private _uint16View;
18 private _int32View;
19 /**
20 * @param length - The size of the buffer in bytes.
21 */
22 constructor(length: number);
23 /**
24 * @param arrayBuffer - The source array buffer.
25 */
26 constructor(arrayBuffer: ArrayBuffer);
27 /** View on the raw binary data as a `Int8Array`. */
28 get int8View(): Int8Array;
29 /** View on the raw binary data as a `Uint8Array`. */
30 get uint8View(): Uint8Array;
31 /** View on the raw binary data as a `Int16Array`. */
32 get int16View(): Int16Array;
33 /** View on the raw binary data as a `Uint16Array`. */
34 get uint16View(): Uint16Array;
35 /** View on the raw binary data as a `Int32Array`. */
36 get int32View(): Int32Array;
37 /**
38 * Returns the view of the given type.
39 * @param type - One of `int8`, `uint8`, `int16`,
40 * `uint16`, `int32`, `uint32`, and `float32`.
41 * @returns - typed array of given type
42 */
43 view(type: string): ITypedArray;
44 /** Destroys all buffer references. Do not use after calling this. */
45 destroy(): void;
46 static sizeOf(type: string): number;
47}