1 | import { ALPHA_MODES } from '@pixi/constants';
|
2 | import { BaseImageResource } from './BaseImageResource';
|
3 | import type { Renderer } from '../../Renderer';
|
4 | import type { BaseTexture } from '../BaseTexture';
|
5 | import type { GLTexture } from '../GLTexture';
|
6 | export interface IImageBitmapResourceOptions {
|
7 | /** Start loading process automatically when constructed. */
|
8 | autoLoad?: boolean;
|
9 | /** Load image using cross origin. */
|
10 | crossOrigin?: boolean;
|
11 | /** Alpha mode used when creating the ImageBitmap. */
|
12 | alphaMode?: ALPHA_MODES;
|
13 | }
|
14 | /**
|
15 | * Resource type for ImageBitmap.
|
16 | * @memberof PIXI
|
17 | */
|
18 | export declare class ImageBitmapResource extends BaseImageResource {
|
19 | /** URL of the image source. */
|
20 | url: string | null;
|
21 | /**
|
22 | * Load image using cross origin.
|
23 | * @default false
|
24 | */
|
25 | crossOrigin: boolean;
|
26 | /**
|
27 | * Controls texture alphaMode field
|
28 | * Copies from options
|
29 | * Default is `null`, copies option from baseTexture
|
30 | * @readonly
|
31 | */
|
32 | alphaMode: ALPHA_MODES | null;
|
33 | /**
|
34 | * Promise when loading.
|
35 | * @default null
|
36 | */
|
37 | private _load;
|
38 | /**
|
39 | * @param source - ImageBitmap or URL to use
|
40 | * @param options
|
41 | * @param {boolean} [options.autoLoad=true] - Start loading process automatically when constructed.
|
42 | * @param {boolean} [options.crossOrigin=true] - Load image using cross origin.
|
43 | * @param {PIXI.ALPHA_MODES} [options.alphaMode=null] - Alpha mode used when creating the ImageBitmap.
|
44 | */
|
45 | constructor(source: ImageBitmap | string, options?: IImageBitmapResourceOptions);
|
46 | load(): Promise<ImageBitmapResource>;
|
47 | /**
|
48 | * Upload the image bitmap resource to GPU.
|
49 | * @param renderer - Renderer to upload to
|
50 | * @param baseTexture - BaseTexture for this resource
|
51 | * @param glTexture - GLTexture to use
|
52 | * @returns {boolean} true is success
|
53 | */
|
54 | upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;
|
55 | /** Destroys this resource. */
|
56 | dispose(): void;
|
57 | /**
|
58 | * Used to auto-detect the type of resource.
|
59 | * @param {*} source - The source object
|
60 | * @returns {boolean} `true` if current environment support ImageBitmap, and source is string or ImageBitmap
|
61 | */
|
62 | static test(source: unknown): source is string | ImageBitmap;
|
63 | /**
|
64 | * Cached empty placeholder canvas.
|
65 | * @see EMPTY
|
66 | */
|
67 | private static _EMPTY;
|
68 | /**
|
69 | * ImageBitmap cannot be created synchronously, so a empty placeholder canvas is needed when loading from URLs.
|
70 | * Only for internal usage.
|
71 | * @returns The cached placeholder canvas.
|
72 | */
|
73 | private static get EMPTY();
|
74 | }
|