UNPKG

starling-framework

Version:

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

114 lines 5.38 kB
import Texture from "./Texture"; import ByteArray from "openfl/utils/ByteArray"; import NetStream from "openfl/net/NetStream"; import TextureBase from "openfl/display3D/textures/TextureBase"; import BitmapData from "openfl/display/BitmapData"; import Bitmap from "openfl/display/Bitmap"; declare namespace starling.textures { /** * A ConcreteTexture wraps a Stage3D texture object, storing the properties of the texture * * and providing utility methods for data upload, etc. * * * * <p>This class cannot be instantiated directly; create instances using * * <code>Texture.fromTextureBase</code> instead. However, that's only necessary when * * you need to wrap a <code>TextureBase</code> object in a Starling texture; * * the preferred way of creating textures is to use one of the other * * <code>Texture.from...</code> factory methods in the <code>Texture</code> class.</p> * * * * @see Texture * */ export class ConcreteTexture extends Texture { /** * @private * * * * Creates a ConcreteTexture object from a TextureBase, storing information about size, * * mip-mapping, and if the channels contain premultiplied alpha values. May only be * * called from subclasses. * * * * <p>Note that <code>width</code> and <code>height</code> are expected in pixels, * * i.e. they do not take the scale factor into account.</p> * */ protected constructor(base: TextureBase, format: string, width: number, height: number, mipMapping: boolean, premultipliedAlpha: boolean, optimizedForRenderTexture?: boolean, scale?: number); /** * Disposes the TextureBase object. */ override dispose(): void; /** * Uploads a bitmap to the texture. The existing contents will be replaced. * * If the size of the bitmap does not match the size of the texture, the bitmap will be * * cropped or filled up with transparent pixels. * * * * <p>Pass a callback function to attempt asynchronous texture upload. * * If the current platform or runtime version does not support asynchronous texture loading, * * the callback will still be executed.</p> * * * * <p>This is the expected function definition: * * <code>function(texture:ConcreteTexture):Void;</code> * */ uploadBitmap(bitmap: Bitmap, async?: (arg0: ConcreteTexture) => void): void; /** * Uploads bitmap data to the texture. The existing contents will be replaced. * * If the size of the bitmap does not match the size of the texture, the bitmap will be * * cropped or filled up with transparent pixels. * * * * <p>Pass a callback function to attempt asynchronous texture upload. * * If the current platform or runtime version does not support asynchronous texture loading, * * the callback will still be executed.</p> * * * * <p>This is the expected function definition: * * <code>function(texture:ConcreteTexture):Void;</code> * */ uploadBitmapData(data: BitmapData, async?: (arg0: ConcreteTexture) => void): void; /** * Uploads ATF data from a ByteArray to the texture. Note that the size of the * * ATF-encoded data must be exactly the same as the original texture size. * * * * <p>The 'async' parameter is a callback function. * * If it's <code>null</code>, the texture will be decoded synchronously and will be visible right away. * * If it's a function, the data will be decoded asynchronously. The texture will remain unchanged until the * * upload is complete, at which time the callback function will be executed. This is the * * expected function definition: <code>function(texture:ConcreteTexture):Void;</code></p> * */ uploadAtfData(data: ByteArray, offset?: number, async?: (arg0: ConcreteTexture) => void): void; /** * Specifies a video stream to be rendered within the texture. */ attachNetStream(netStream: NetStream, onComplete?: (arg0: ConcreteTexture) => void): void; /** * Clears the texture with a certain color and alpha value. The previous contents of the * * texture is wiped out. */ clear(color?: number, alpha?: number): void; /** * Indicates if the base texture was optimized for being used in a render texture. */ get optimizedForRenderTexture(): boolean; /** * Indicates if the base texture is a standard power-of-two dimensioned texture of type * * <code>flash.display3D.textures.Texture</code>. */ get isPotTexture(): boolean; /** * The function that you provide here will be called after a context loss. * * On execution, a new base texture will already have been created; however, * * it will be empty. Call one of the "upload..." methods from within the callback * * to restore the actual texture data. * * * * <listing> * * var texture:Texture = Texture.fromBitmap(new EmbeddedBitmap()); * * texture.root.onRestore = function():void * * { * * texture.root.uploadFromBitmap(new EmbeddedBitmap()); * * };</listing> * */ get onRestore(): (arg0: ConcreteTexture) => void; set onRestore(value: (arg0: ConcreteTexture) => void) } } export default starling.textures.ConcreteTexture;