UNPKG

4.03 kBTypeScriptView Raw
1import { Rectangle } from '@pixi/math';
2import type { ColorSource } from '@pixi/color';
3import type { BUFFER_BITS } from '@pixi/constants';
4import type { ExtensionMetadata } from '@pixi/extensions';
5import type { MaskData } from '../mask/MaskData';
6import type { Renderer } from '../Renderer';
7import type { ISystem } from '../system/ISystem';
8import type { RenderTexture } from './RenderTexture';
9/**
10 * System plugin to the renderer to manage render textures.
11 *
12 * Should be added after FramebufferSystem
13 *
14 * ### Frames
15 *
16 * The `RenderTextureSystem` holds a sourceFrame → destinationFrame projection. The following table explains the different
17 * coordinate spaces used:
18 *
19 * | Frame | Description | Coordinate System |
20 * | ---------------------- | ---------------------------------------------------------------- | ------------------------------------------------------- |
21 * | sourceFrame | The rectangle inside of which display-objects are being rendered | **World Space**: The origin on the top-left |
22 * | destinationFrame | The rectangle in the render-target (canvas or texture) into which contents should be rendered | If rendering to the canvas, this is in screen space and the origin is on the top-left. If rendering to a render-texture, this is in its base-texture's space with the origin on the bottom-left. |
23 * | viewportFrame | The framebuffer viewport corresponding to the destination-frame | **Window Coordinates**: The origin is always on the bottom-left. |
24 * @memberof PIXI
25 */
26export declare class RenderTextureSystem implements ISystem {
27 /** @ignore */
28 static extension: ExtensionMetadata;
29 /**
30 * List of masks for the {@link PIXI.StencilSystem}.
31 * @readonly
32 */
33 defaultMaskStack: Array<MaskData>;
34 /**
35 * Render texture currently bound. {@code null} if rendering to the canvas.
36 * @readonly
37 */
38 current: RenderTexture | null;
39 /**
40 * The source frame for the render-target's projection mapping.
41 *
42 * See {@link PIXI.ProjectionSystem#sourceFrame} for more details
43 */
44 readonly sourceFrame: Rectangle;
45 /**
46 * The destination frame for the render-target's projection mapping.
47 *
48 * See {@link PIXI.ProjectionSystem#destinationFrame} for more details.
49 */
50 readonly destinationFrame: Rectangle;
51 /**
52 * The viewport frame for the render-target's viewport binding. This is equal to the destination-frame
53 * for render-textures, while it is y-flipped when rendering to the screen (i.e. its origin is always on
54 * the bottom-left).
55 */
56 readonly viewportFrame: Rectangle;
57 private renderer;
58 /** Does the renderer have alpha and are its color channels stored premultipled by the alpha channel? */
59 private _rendererPremultipliedAlpha;
60 /**
61 * @param renderer - The renderer this System works for.
62 */
63 constructor(renderer: Renderer);
64 protected contextChange(): void;
65 /**
66 * Bind the current render texture.
67 * @param renderTexture - RenderTexture to bind, by default its `null` - the screen.
68 * @param sourceFrame - Part of world that is mapped to the renderTexture.
69 * @param destinationFrame - Part of renderTexture, by default it has the same size as sourceFrame.
70 */
71 bind(renderTexture?: RenderTexture, sourceFrame?: Rectangle, destinationFrame?: Rectangle): void;
72 /**
73 * Erases the render texture and fills the drawing area with a colour.
74 * @param clearColor - The color as rgba, default to use the renderer backgroundColor
75 * @param [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks
76 * that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.
77 */
78 clear(clearColor?: ColorSource, mask?: BUFFER_BITS): void;
79 resize(): void;
80 /** Resets render-texture state. */
81 reset(): void;
82 destroy(): void;
83}