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 | /**
|
7 | * Options for ImageBitmapResource.
|
8 | * @memberof PIXI
|
9 | */
|
10 | export interface IImageBitmapResourceOptions {
|
11 | /** Start loading process automatically when constructed. */
|
12 | autoLoad?: boolean;
|
13 | /** Load image using cross origin. */
|
14 | crossOrigin?: boolean;
|
15 | /** Alpha mode used when creating the ImageBitmap. */
|
16 | alphaMode?: ALPHA_MODES;
|
17 | /**
|
18 | * Whether the underlying ImageBitmap is owned by the {@link PIXI.ImageBitmapResource}. When set to `true`,
|
19 | * the underlying ImageBitmap will be disposed automatically when disposing {@link PIXI.ImageBitmapResource}.
|
20 | * If this option is not set, whether it owns the underlying ImageBitmap is determained by the type of `source`
|
21 | * used when constructing {@link PIXI.ImageBitmapResource}:
|
22 | * - When `source` is `ImageBitmap`, the underlying ImageBitmap is not owned by default.
|
23 | * - When `source` is `string` (a URL), the underlying ImageBitmap is owned by default.
|
24 | * @see PIXI.ImageBitmapResource.ownsImageBitmap
|
25 | */
|
26 | ownsImageBitmap?: boolean;
|
27 | }
|
28 | /**
|
29 | * Resource type for ImageBitmap.
|
30 | * @memberof PIXI
|
31 | */
|
32 | export declare class ImageBitmapResource extends BaseImageResource {
|
33 | /** URL of the image source. */
|
34 | url: string | null;
|
35 | /**
|
36 | * Load image using cross origin.
|
37 | * @default false
|
38 | */
|
39 | crossOrigin: boolean;
|
40 | /**
|
41 | * Controls texture alphaMode field
|
42 | * Copies from options
|
43 | * Default is `null`, copies option from baseTexture
|
44 | * @readonly
|
45 | */
|
46 | alphaMode: ALPHA_MODES | null;
|
47 | /**
|
48 | * Whether the underlying ImageBitmap is owned by the ImageBitmapResource.
|
49 | * @see PIXI.IImageBitmapResourceOptions.ownsImageBitmap
|
50 | */
|
51 | private ownsImageBitmap;
|
52 | /**
|
53 | * Promise when loading.
|
54 | * @default null
|
55 | */
|
56 | private _load;
|
57 | /**
|
58 | * @param source - ImageBitmap or URL to use.
|
59 | * @param options - Options to use.
|
60 | */
|
61 | constructor(source: ImageBitmap | string, options?: IImageBitmapResourceOptions);
|
62 | load(): Promise<this>;
|
63 | /**
|
64 | * Upload the image bitmap resource to GPU.
|
65 | * @param renderer - Renderer to upload to
|
66 | * @param baseTexture - BaseTexture for this resource
|
67 | * @param glTexture - GLTexture to use
|
68 | * @returns {boolean} true is success
|
69 | */
|
70 | upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;
|
71 | /** Destroys this resource. */
|
72 | dispose(): void;
|
73 | /**
|
74 | * Used to auto-detect the type of resource.
|
75 | * @param {*} source - The source object
|
76 | * @returns {boolean} `true` if current environment support ImageBitmap, and source is string or ImageBitmap
|
77 | */
|
78 | static test(source: unknown): source is string | ImageBitmap;
|
79 | /**
|
80 | * Cached empty placeholder canvas.
|
81 | * @see EMPTY
|
82 | */
|
83 | private static _EMPTY;
|
84 | /**
|
85 | * ImageBitmap cannot be created synchronously, so a empty placeholder canvas is needed when loading from URLs.
|
86 | * Only for internal usage.
|
87 | * @returns The cached placeholder canvas.
|
88 | */
|
89 | private static get EMPTY();
|
90 | }
|