UNPKG

4.34 kBTypeScriptView Raw
1import type { ExtensionMetadata } from '@pixi/extensions';
2import type { ICanvas } from '@pixi/settings';
3import type { ISystem } from '../system/ISystem';
4import type { Renderer } from '../Renderer';
5import type { WebGLExtensions } from './WebGLExtensions';
6import type { IRenderingContext } from '../IRenderer';
7export interface ISupportDict {
8 uint32Indices: boolean;
9}
10export interface ContextOptions {
11 context?: IRenderingContext;
12 /**
13 * Use premultipliedAlpha instead
14 * @deprecated since 7.0.0
15 */
16 useContextAlpha?: boolean | 'notMultiplied';
17 premultipliedAlpha?: boolean;
18 powerPreference?: WebGLPowerPreference;
19 preserveDrawingBuffer?: boolean;
20 antialias?: boolean;
21}
22/**
23 * System plugin to the renderer to manage the context.
24 * @memberof PIXI
25 */
26export declare class ContextSystem implements ISystem<ContextOptions> {
27 /** @ignore */
28 static extension: ExtensionMetadata;
29 /**
30 * Either 1 or 2 to reflect the WebGL version being used.
31 * @readonly
32 */
33 webGLVersion: number;
34 /**
35 * Features supported by current context.
36 * @type {object}
37 * @readonly
38 * @property {boolean} uint32Indices - Support for 32-bit indices buffer.
39 */
40 readonly supports: ISupportDict;
41 preserveDrawingBuffer: boolean;
42 powerPreference: WebGLPowerPreference;
43 /**
44 * Pass-thru setting for the canvas' context `alpha` property. This is typically
45 * not something you need to fiddle with. If you want transparency, use `backgroundAlpha`.
46 * @member {boolean}
47 * @deprecated since 7.0.0
48 */
49 useContextAlpha: boolean | 'notMultiplied';
50 protected CONTEXT_UID: number;
51 protected gl: IRenderingContext;
52 /**
53 * Extensions available.
54 * @type {object}
55 * @readonly
56 * @property {WEBGL_draw_buffers} drawBuffers - WebGL v1 extension
57 * @property {WEBGL_depth_texture} depthTexture - WebGL v1 extension
58 * @property {OES_texture_float} floatTexture - WebGL v1 extension
59 * @property {WEBGL_lose_context} loseContext - WebGL v1 extension
60 * @property {OES_vertex_array_object} vertexArrayObject - WebGL v1 extension
61 * @property {EXT_texture_filter_anisotropic} anisotropicFiltering - WebGL v1 and v2 extension
62 */
63 extensions: WebGLExtensions;
64 private renderer;
65 /** @param renderer - The renderer this System works for. */
66 constructor(renderer: Renderer);
67 /**
68 * `true` if the context is lost
69 * @readonly
70 */
71 get isLost(): boolean;
72 /**
73 * Handles the context change event.
74 * @param {WebGLRenderingContext} gl - New WebGL context.
75 */
76 protected contextChange(gl: IRenderingContext): void;
77 init(options: ContextOptions): void;
78 /**
79 * Initializes the context.
80 * @protected
81 * @param {WebGLRenderingContext} gl - WebGL context
82 */
83 initFromContext(gl: IRenderingContext): void;
84 /**
85 * Initialize from context options
86 * @protected
87 * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
88 * @param {object} options - context attributes
89 */
90 initFromOptions(options: WebGLContextAttributes): void;
91 /**
92 * Helper class to create a WebGL Context
93 * @param canvas - the canvas element that we will get the context from
94 * @param options - An options object that gets passed in to the canvas element containing the
95 * context attributes
96 * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext
97 * @returns {WebGLRenderingContext} the WebGL context
98 */
99 createContext(canvas: ICanvas, options: WebGLContextAttributes): IRenderingContext;
100 /** Auto-populate the {@link PIXI.ContextSystem.extensions extensions}. */
101 protected getExtensions(): void;
102 /**
103 * Handles a lost webgl context
104 * @param {WebGLContextEvent} event - The context lost event.
105 */
106 protected handleContextLost(event: WebGLContextEvent): void;
107 /** Handles a restored webgl context. */
108 protected handleContextRestored(): void;
109 destroy(): void;
110 /** Handle the post-render runner event. */
111 protected postrender(): void;
112 /**
113 * Validate context.
114 * @param {WebGLRenderingContext} gl - Render context.
115 */
116 protected validateContext(gl: IRenderingContext): void;
117}