UNPKG

4.3 kBTypeScriptView Raw
1import { BLEND_MODES } from '@pixi/constants';
2import { State } from './State';
3import type { ExtensionMetadata } from '@pixi/extensions';
4import type { IRenderingContext } from '../IRenderer';
5import type { ISystem } from '../system/ISystem';
6/**
7 * System plugin to the renderer to manage WebGL state machines.
8 * @memberof PIXI
9 */
10export declare class StateSystem implements ISystem {
11 /** @ignore */
12 static extension: ExtensionMetadata;
13 /**
14 * State ID
15 * @readonly
16 */
17 stateId: number;
18 /**
19 * Polygon offset
20 * @readonly
21 */
22 polygonOffset: number;
23 /**
24 * Blend mode
25 * @default PIXI.BLEND_MODES.NONE
26 * @readonly
27 */
28 blendMode: BLEND_MODES | -1;
29 /** Whether current blend equation is different */
30 protected _blendEq: boolean;
31 /**
32 * GL context
33 * @member {WebGLRenderingContext}
34 * @readonly
35 */
36 protected gl: IRenderingContext;
37 protected blendModes: number[][];
38 /**
39 * Collection of calls
40 * @member {Function[]}
41 */
42 protected readonly map: Array<(value: boolean) => void>;
43 /**
44 * Collection of check calls
45 * @member {Function[]}
46 */
47 protected readonly checks: Array<(system: this, state: State) => void>;
48 /**
49 * Default WebGL State
50 * @readonly
51 */
52 protected defaultState: State;
53 constructor();
54 contextChange(gl: IRenderingContext): void;
55 /**
56 * Sets the current state
57 * @param {*} state - The state to set.
58 */
59 set(state: State): void;
60 /**
61 * Sets the state, when previous state is unknown.
62 * @param {*} state - The state to set
63 */
64 forceState(state: State): void;
65 /**
66 * Sets whether to enable or disable blending.
67 * @param value - Turn on or off WebGl blending.
68 */
69 setBlend(value: boolean): void;
70 /**
71 * Sets whether to enable or disable polygon offset fill.
72 * @param value - Turn on or off webgl polygon offset testing.
73 */
74 setOffset(value: boolean): void;
75 /**
76 * Sets whether to enable or disable depth test.
77 * @param value - Turn on or off webgl depth testing.
78 */
79 setDepthTest(value: boolean): void;
80 /**
81 * Sets whether to enable or disable depth mask.
82 * @param value - Turn on or off webgl depth mask.
83 */
84 setDepthMask(value: boolean): void;
85 /**
86 * Sets whether to enable or disable cull face.
87 * @param {boolean} value - Turn on or off webgl cull face.
88 */
89 setCullFace(value: boolean): void;
90 /**
91 * Sets the gl front face.
92 * @param {boolean} value - true is clockwise and false is counter-clockwise
93 */
94 setFrontFace(value: boolean): void;
95 /**
96 * Sets the blend mode.
97 * @param {number} value - The blend mode to set to.
98 */
99 setBlendMode(value: number): void;
100 /**
101 * Sets the polygon offset.
102 * @param {number} value - the polygon offset
103 * @param {number} scale - the polygon offset scale
104 */
105 setPolygonOffset(value: number, scale: number): void;
106 /** Resets all the logic and disables the VAOs. */
107 reset(): void;
108 /**
109 * Checks to see which updates should be checked based on which settings have been activated.
110 *
111 * For example, if blend is enabled then we should check the blend modes each time the state is changed
112 * or if polygon fill is activated then we need to check if the polygon offset changes.
113 * The idea is that we only check what we have too.
114 * @param func - the checking function to add or remove
115 * @param value - should the check function be added or removed.
116 */
117 updateCheck(func: (system: this, state: State) => void, value: boolean): void;
118 /**
119 * A private little wrapper function that we call to check the blend mode.
120 * @param system - the System to perform the state check on
121 * @param state - the state that the blendMode will pulled from
122 */
123 private static checkBlendMode;
124 /**
125 * A private little wrapper function that we call to check the polygon offset.
126 * @param system - the System to perform the state check on
127 * @param state - the state that the blendMode will pulled from
128 */
129 private static checkPolygonOffset;
130 /**
131 * @ignore
132 */
133 destroy(): void;
134}