Class TCustomLockableTexture

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCustomLockableTexture = class abstract(TCustomBaseTexture)

Description

Base definition of "lockable" texture; that is, a texture that can have regions "locked" so they become accessible to CPU. These textures are typical to most GPUs and also provide efficient means of storing dynamically changing data that is provided by CPU.

Hierarchy

Overview

Fields

Protected FBytesPerPixel: Integer;
Protected FDynamicTexture: Boolean;

Methods

Public function Clear: Boolean; override;
Public function CopyFromSurface(const Source: TPixelSurface): Boolean;
Public function CopyFromSurfaceRect(DestPos: TPoint2i; const Source: TPixelSurface; SourceRect: TIntRect): Boolean;
Public function CopyToSurface(const Dest: TPixelSurface): Boolean;
Public function CopyToSurfaceRect(DestPos: TPoint2i; const Dest: TPixelSurface; SourceRect: TIntRect): Boolean;
Public function Lock(const Rect: TIntRect; out Surface: TPixelSurface): Boolean; overload;
Public function Lock(out Surface: TPixelSurface): Boolean; overload; inline;
Public function Lock(const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean; overload;
Public function Lock(out LockedPixels: TLockedPixels): Boolean; overload; inline;
Public function Unlock: Boolean;
Protected function DoCopyRect(const Source: TCustomBaseTexture; const SourceRect: TIntRect; const DestPos: TPoint2i): Boolean; override;
Protected function DoLock(const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean; virtual; abstract;
Protected function DoUnlock: Boolean; virtual; abstract;
Protected function IsLockRectFull(const Rect: TIntRect): Boolean;
Protected function LockSurface(const Surface: TPixelSurface; const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean;

Properties

Public property BytesPerPixel: Integer read FBytesPerPixel;
Public property DynamicTexture: Boolean read FDynamicTexture write SetDynamicTexture;

Description

Fields

Protected FBytesPerPixel: Integer;

Current number of bytes each pixel occupies.

Protected FDynamicTexture: Boolean;

Determines whether the current texture is dynamic (that is, can have content changed intensively) or not.

Methods

Public function Clear: Boolean; override;

Clears the texture and fills its pixels with zeros.

Public function CopyFromSurface(const Source: TPixelSurface): Boolean;

Copies an entire source surface to this texture. This method does clipping when applicable and calls Lock / Unlock method pair appropriately during the process.

Public function CopyFromSurfaceRect(DestPos: TPoint2i; const Source: TPixelSurface; SourceRect: TIntRect): Boolean;

Copies a portion from source surface to this texture. This method does clipping when applicable and calls Lock / Unlock method pair appropriately during the process.

Public function CopyToSurface(const Dest: TPixelSurface): Boolean;

Copies the entire contents of this texture to the specified destination surface. This method does clipping when applicable and calls Lock / Unlock method pair appropriately during the process.

Public function CopyToSurfaceRect(DestPos: TPoint2i; const Dest: TPixelSurface; SourceRect: TIntRect): Boolean;

Copies a region of this texture to the specified destination surface. This method does clipping when applicable and calls Lock / Unlock method pair appropriately during the process.

Public function Lock(const Rect: TIntRect; out Surface: TPixelSurface): Boolean; overload;

Locks a portion of texture so that it can be accessed by CPU and provides TPixelSurface wrapper around this area for easy access. The texture can be unlocked either by calling Unlock or by freeing the surface returned by this function. Calling Unlock also releases the surface returned by this call.

Public function Lock(out Surface: TPixelSurface): Boolean; overload; inline;

Locks the entire texture so that it can be accessed by CPU and provides TPixelSurface wrapper around this area for easy access. The texture can be unlocked either by calling Unlock or by freeing the surface returned by this function. Calling Unlock also releases the surface returned by this call.

Public function Lock(const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean; overload;

Locks a portion of texture so that it can be accessed by CPU and provides information in TLockedPixels structure regarding this area.

Public function Lock(out LockedPixels: TLockedPixels): Boolean; overload; inline;

Locks the entire texture so that it can be accessed by CPU and provides information in TLockedPixels structure regarding this area.

Public function Unlock: Boolean;

Unlocks the texture and updates its contents.

Protected function DoCopyRect(const Source: TCustomBaseTexture; const SourceRect: TIntRect; const DestPos: TPoint2i): Boolean; override;

This class implements internally limited functionality of "DoCopyRect" by locking both textures and copying data on CPU. For typical applications this could be okay, but it is generally inefficient and should be re-implemented by derived classes to provide copy mechanism directly on the GPU.

Protected function DoLock(const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean; virtual; abstract;

Locks the specified rectangle and provides access information regarding this region. This should be implemented by derived classes. Returns True when the operation is successful and False otherwise.

Protected function DoUnlock: Boolean; virtual; abstract;

Unlocks the specified rectangle and makes sure the texture remains updated after these changes. This should be implemented by derived classes. Returns True when the operation is successful and False otherwise.

Protected function IsLockRectFull(const Rect: TIntRect): Boolean;

Returns True when the specified rectangle covers the entire texture and False otherwise. On some occasions, this can be useful to determine whether to pass rectangle pointer to locking mechanism or just pass Nil to cover the entire area.

Protected function LockSurface(const Surface: TPixelSurface; const Rect: TIntRect; out LockedPixels: TLockedPixels): Boolean;

Helper function that provides locking mechanism to a simple TPixelSurface. That is, a quick shortcut to "lock" non-GPU surface. Returns True when the operation is successful and False otherwise.

Properties

Public property BytesPerPixel: Integer read FBytesPerPixel;

Number of bytes each pixel in the texture occupies.

Public property DynamicTexture: Boolean read FDynamicTexture write SetDynamicTexture;

Determines whether the texture is "dynamic"; that is, can have content changing continuously without major impact on rendering performance. This can provide significant performance benefit but may or may not be supported on specific provider and platform.


Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.