UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

133 lines 6.04 kB
import Padding from "../utils/Padding"; import Texture from "../textures/Texture"; import Painter from "../rendering/Painter"; import IFilterHelper from "./IFilterHelper"; import EventDispatcher from "../events/EventDispatcher"; declare namespace starling.filters { /** * Dispatched when the settings change in a way that requires a redraw. */ export class FragmentFilter extends EventDispatcher { /** * Creates a new instance. The base class' implementation just draws the unmodified * * input texture. */ constructor(); /** * Disposes all resources that have been created by the filter. */ dispose(): void; /** * Renders the filtered target object. Most users will never have to call this manually; * * it's executed automatically in the rendering process of the filtered display object. * */ render(painter: Painter): void; /** * Does the actual filter processing. This method will be called with up to four input * * textures and must return a new texture (acquired from the <code>helper</code>) that * * contains the filtered output. To to do this, it configures the FilterEffect * * (provided via <code>createEffect</code>) and calls its <code>render</code> method. * * * * <p>In a standard filter, only <code>input0</code> will contain a texture; that's the * * object the filter was applied to, rendered into an appropriately sized texture. * * However, filters may also accept multiple textures; that's useful when you need to * * combine the output of several filters into one. For example, the DropShadowFilter * * uses a BlurFilter to create the shadow and then feeds both input and shadow texture * * into a CompositeFilter.</p> * * * * <p>Never create or dispose any textures manually within this method; instead, get * * new textures from the provided helper object, and pass them to the helper when you do * * not need them any longer. Ownership of both input textures and returned texture * * lies at the caller; only temporary textures should be put into the helper.</p> * */ process(painter: Painter, helper: IFilterHelper, input0?: Texture, input1?: Texture, input2?: Texture, input3?: Texture): Texture; /** * Caches the filter output into a texture. * * * * <p>An uncached filter is rendered every frame (except if it can be rendered from the * * global render cache, which happens if the target object does not change its appearance * * or location relative to the stage). A cached filter is only rendered once; the output * * stays unchanged until you call <code>cache</code> again or change the filter settings. * * </p> * * * * <p>Beware: you cannot cache filters on 3D objects; if the object the filter is attached * * to is a Sprite3D or has a Sprite3D as (grand-) parent, the request will be silently * * ignored. However, you <em>can</em> cache a 2D object that has 3D children!</p> * */ cache(): void; /** * Clears the cached output of the filter. After calling this method, the filter will be * * processed once per frame again. */ clearCache(): void; /** * @private */ override addEventListener(type: string, listener: Function): void; /** * @private */ override removeEventListener(type: string, listener: Function): void; /** * Indicates the number of rendering passes required for this filter. * * Subclasses must override this method if the number of passes is not <code>1</code>. */ get numPasses(): number; /** * Padding can extend the size of the filter texture in all directions. * * That's useful when the filter "grows" the bounds of the object in any direction. */ get padding(): Padding; set padding(value: Padding) /** * Indicates if the filter is cached (via the <code>cache</code> method). */ get isCached(): boolean; /** * The resolution of the filter texture. "1" means stage resolution, "0.5" half the stage * * resolution. A lower resolution saves memory and execution time, but results in a lower * * output quality. Values greater than 1 are allowed; such values might make sense for a * * cached filter when it is scaled up. @default 1 * */ get resolution(): number; set resolution(value: number) /** * The anti-aliasing level. This is only used for rendering the target object * * into a texture, not for the filter passes. 0 - none, 4 - maximum. @default 0 */ get antiAliasing(): number; set antiAliasing(value: number) /** * The smoothing mode of the filter texture. @default bilinear */ get textureSmoothing(): string; set textureSmoothing(value: string) /** * The format of the filter texture. @default BGRA */ get textureFormat(): string; set textureFormat(value: string) /** * Indicates if the last filter pass is always drawn directly to the back buffer. * * * * <p>Per default, the filter tries to automatically render in a smart way: objects that * * are currently moving are rendered to the back buffer, objects that are static are * * rendered into a texture first, which allows the filter to be drawn directly from the * * render cache in the next frame (in case the object remains static).</p> * * * * <p>However, this fails when filters are added to an object that does not support the * * render cache, or to a container with such a child (e.g. a Sprite3D object or a masked * * display object). In such a case, enable this property for maximum performance.</p> * * * * @default false * */ get alwaysDrawToBackBuffer(): boolean; set alwaysDrawToBackBuffer(value: boolean) } } export default starling.filters.FragmentFilter;