1 | import { BUFFER_BITS, MSAA_QUALITY } from '@pixi/constants';
|
2 | import { Rectangle } from '@pixi/math';
|
3 | import { Framebuffer } from './Framebuffer';
|
4 | import { GLFramebuffer } from './GLFramebuffer';
|
5 | import type { ExtensionMetadata } from '@pixi/extensions';
|
6 | import type { IRenderingContext } from '../IRenderer';
|
7 | import type { Renderer } from '../Renderer';
|
8 | import type { ISystem } from '../system/ISystem';
|
9 | /**
|
10 | * System plugin to the renderer to manage framebuffers.
|
11 | * @memberof PIXI
|
12 | */
|
13 | export declare class FramebufferSystem implements ISystem {
|
14 | /** @ignore */
|
15 | static extension: ExtensionMetadata;
|
16 | /** A list of managed framebuffers. */
|
17 | readonly managedFramebuffers: Array<Framebuffer>;
|
18 | current: Framebuffer;
|
19 | viewport: Rectangle;
|
20 | hasMRT: boolean;
|
21 | writeDepthTexture: boolean;
|
22 | protected CONTEXT_UID: number;
|
23 | protected gl: IRenderingContext;
|
24 | /** Framebuffer value that shows that we don't know what is bound. */
|
25 | protected unknownFramebuffer: Framebuffer;
|
26 | protected msaaSamples: Array<number>;
|
27 | renderer: Renderer;
|
28 | /**
|
29 | * @param renderer - The renderer this System works for.
|
30 | */
|
31 | constructor(renderer: Renderer);
|
32 | /** Sets up the renderer context and necessary buffers. */
|
33 | protected contextChange(): void;
|
34 | /**
|
35 | * Bind a framebuffer.
|
36 | * @param framebuffer
|
37 | * @param frame - frame, default is framebuffer size
|
38 | * @param mipLevel - optional mip level to set on the framebuffer - defaults to 0
|
39 | */
|
40 | bind(framebuffer?: Framebuffer, frame?: Rectangle, mipLevel?: number): void;
|
41 | /**
|
42 | * Set the WebGLRenderingContext's viewport.
|
43 | * @param x - X position of viewport
|
44 | * @param y - Y position of viewport
|
45 | * @param width - Width of viewport
|
46 | * @param height - Height of viewport
|
47 | */
|
48 | setViewport(x: number, y: number, width: number, height: number): void;
|
49 | /**
|
50 | * Get the size of the current width and height. Returns object with `width` and `height` values.
|
51 | * @readonly
|
52 | */
|
53 | get size(): {
|
54 | x: number;
|
55 | y: number;
|
56 | width: number;
|
57 | height: number;
|
58 | };
|
59 | /**
|
60 | * Clear the color of the context
|
61 | * @param r - Red value from 0 to 1
|
62 | * @param g - Green value from 0 to 1
|
63 | * @param b - Blue value from 0 to 1
|
64 | * @param a - Alpha value from 0 to 1
|
65 | * @param {PIXI.BUFFER_BITS} [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks
|
66 | * that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.
|
67 | */
|
68 | clear(r: number, g: number, b: number, a: number, mask?: BUFFER_BITS): void;
|
69 | /**
|
70 | * Initialize framebuffer for this context
|
71 | * @protected
|
72 | * @param framebuffer
|
73 | * @returns - created GLFramebuffer
|
74 | */
|
75 | initFramebuffer(framebuffer: Framebuffer): GLFramebuffer;
|
76 | /**
|
77 | * Resize the framebuffer
|
78 | * @param framebuffer
|
79 | * @protected
|
80 | */
|
81 | resizeFramebuffer(framebuffer: Framebuffer): void;
|
82 | /**
|
83 | * Update the framebuffer
|
84 | * @param framebuffer
|
85 | * @param mipLevel
|
86 | * @protected
|
87 | */
|
88 | updateFramebuffer(framebuffer: Framebuffer, mipLevel: number): void;
|
89 | /**
|
90 | * Returns true if the frame buffer can be multisampled.
|
91 | * @param framebuffer
|
92 | */
|
93 | protected canMultisampleFramebuffer(framebuffer: Framebuffer): boolean;
|
94 | /**
|
95 | * Detects number of samples that is not more than a param but as close to it as possible
|
96 | * @param samples - number of samples
|
97 | * @returns - recommended number of samples
|
98 | */
|
99 | protected detectSamples(samples: MSAA_QUALITY): MSAA_QUALITY;
|
100 | /**
|
101 | * Only works with WebGL2
|
102 | *
|
103 | * blits framebuffer to another of the same or bigger size
|
104 | * after that target framebuffer is bound
|
105 | *
|
106 | * Fails with WebGL warning if blits multisample framebuffer to different size
|
107 | * @param framebuffer - by default it blits "into itself", from renderBuffer to texture.
|
108 | * @param sourcePixels - source rectangle in pixels
|
109 | * @param destPixels - dest rectangle in pixels, assumed to be the same as sourcePixels
|
110 | */
|
111 | blit(framebuffer?: Framebuffer, sourcePixels?: Rectangle, destPixels?: Rectangle): void;
|
112 | /**
|
113 | * Disposes framebuffer.
|
114 | * @param framebuffer - framebuffer that has to be disposed of
|
115 | * @param contextLost - If context was lost, we suppress all delete function calls
|
116 | */
|
117 | disposeFramebuffer(framebuffer: Framebuffer, contextLost?: boolean): void;
|
118 | /**
|
119 | * Disposes all framebuffers, but not textures bound to them.
|
120 | * @param [contextLost=false] - If context was lost, we suppress all delete function calls
|
121 | */
|
122 | disposeAll(contextLost?: boolean): void;
|
123 | /**
|
124 | * Forcing creation of stencil buffer for current framebuffer, if it wasn't done before.
|
125 | * Used by MaskSystem, when its time to use stencil mask for Graphics element.
|
126 | *
|
127 | * Its an alternative for public lazy `framebuffer.enableStencil`, in case we need stencil without rebind.
|
128 | * @private
|
129 | */
|
130 | forceStencil(): void;
|
131 | /** Resets framebuffer stored state, binds screen framebuffer. Should be called before renderTexture reset(). */
|
132 | reset(): void;
|
133 | destroy(): void;
|
134 | }
|