Navigation
API > API/Runtime > API/Runtime/Engine
Encapsulates the canvas state.
| Name | FCanvas |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Public/CanvasTypes.h |
| Include Path | #include "CanvasTypes.h" |
Syntax
class FCanvas
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FCanvas
(
FRenderTarget* InRenderTarget, |
Constructor. | CanvasTypes.h | |
FCanvas
(
FRenderTarget* InRenderTarget, |
Constructor. For situations where a world is not available, but time information is | CanvasTypes.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FCanvas() |
Destructor. | CanvasTypes.h |
Classes
| Name | Remarks |
|---|---|
| FCanvasSortElement | Contains all of the batched elements that need to be rendered at a certain depth sort key |
| FTransformEntry | Entry for the transform stack which stores a matrix and its CRC for faster comparisons |
Enums
Public
| Name | Remarks |
|---|---|
| ECanvasAllowModes | Enum for canvas features that are allowed |
| ECanvasDrawMode | |
| EElementType | Enum that describes what type of element we are currently batching. |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AlphaModulate | float | CanvasTypes.h | ||
| LastElementIndex | int32 | Store index of last Element off to avoid semi expensive Find() | CanvasTypes.h | |
| SortedElementLookupMap | TMap< int32, int32 > | Map from sortkey to array index of SortedElements for faster lookup of existing entries | CanvasTypes.h | |
| SortedElements | TArray< FCanvasSortElement > | Batched canvas elements to be sorted for rendering. Sort order is back-to-front | CanvasTypes.h | |
| WordWrapper | TSharedPtr< FCanvasWordWrapper > | Private class for handling word wrapping behavior. | CanvasTypes.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AllowedModes | uint32 | Toggles for various canvas rendering functionality | CanvasTypes.h | |
| bRenderTargetDirty | bool | True if the render target has been rendered to since last calling SetRenderTarget() | CanvasTypes.h | |
| bScaledToRenderTarget | bool | True, if Canvas should be scaled to whole render target | CanvasTypes.h | |
| bStereoRendering | bool | True, if Canvas should be rendered in stereo | CanvasTypes.h | |
| bUseInternalTexture | bool | True, if Canvas is being rendered in its own texture | CanvasTypes.h | |
| bWriteDestinationAlpha | bool | True, if the destination alpha channel must be written | CanvasTypes.h | |
| CurrentHitProxy | TRefCountPtr< HHitProxy > | Current hit proxy object | CanvasTypes.h | |
| DepthSortKeyStack | TArray< int32 > | Stack of SortKeys. All rendering is done using the top most sort key | CanvasTypes.h | |
| DPIScale | float | CanvasTypes.h | ||
| DrawMode | ECanvasDrawMode | CanvasTypes.h | ||
| FeatureLevel | ERHIFeatureLevel::Type | Feature level that we are currently rendering with | CanvasTypes.h | |
| HitProxyConsumer | FHitProxyConsumer * | Current hit proxy consumer | CanvasTypes.h | |
| ParentSize | FIntPoint | CanvasTypes.h | ||
| RenderTarget | FRenderTarget * | Current render target used by the canvas | CanvasTypes.h | |
| Scene | FSceneInterface * | Optional scene for rendering. | CanvasTypes.h | |
| ScissorRect | FIntRect | Scissor rect for the render target | CanvasTypes.h | |
| Time | FGameTime | Current gameplay time | CanvasTypes.h | |
| TransformStack | TArray< FTransformEntry > | Stack of matrices. Bottom most entry is the canvas projection | CanvasTypes.h | |
| ViewRect | FIntRect | View rect for the render target | CanvasTypes.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddTileRenderItem
(
float X, |
Generates a new FCanvasTileRendererItem for the current sortkey and adds it to the sortelement list of items to render | CanvasTypes.h | |
void AddTriangleRenderItem
(
const FCanvasUVTri& Tri, |
Generates a new FCanvasTriangleRendererItem for the current sortkey and adds it to the sortelement list of items to render | CanvasTypes.h | |
void Clear
(
const FLinearColor& Color |
Clear the canvas | CanvasTypes.h | |
void ClearBatchesToRender() |
Clear the list of dirty batches that need to be rendered by the canvas | CanvasTypes.h | |
void CopyTransformStack
(
const FCanvas& Copy |
Copy the conents of the TransformStack from an existing canvas | CanvasTypes.h | |
void DrawItem
(
FCanvasItem& Item, |
Draw a CanvasItem at the given coordinates | CanvasTypes.h | |
void DrawItem
(
FCanvasItem& Item, |
Draw a CanvasItem at the given coordinates | CanvasTypes.h | |
void DrawItem
(
FCanvasItem& Item |
Draw a CanvasItem | CanvasTypes.h | |
void DrawNGon
(
const FVector2D& Center, |
CanvasTypes.h | ||
int32 DrawShadowedString
(
double StartX, |
Draw an string centered on given location. | CanvasTypes.h | |
int32 DrawShadowedText
(
double StartX, |
CanvasTypes.h | ||
void DrawTile
(
double X, |
CanvasTypes.h | ||
void DrawTile
(
double X, |
Draw arbitrary aligned rectangle. | CanvasTypes.h | |
void Flush_GameThread
(
bool bForce |
Sends a message to the rendering thread to draw the batched elements. | CanvasTypes.h | |
void Flush_RenderThread
(
FRHICommandListImmediate& RHICmdList, |
Sends a message to the rendering thread to draw the batched elements. | CanvasTypes.h | |
void Flush_RenderThread
(
FRDGBuilder& GraphBuilder, |
CanvasTypes.h | ||
uint32 GetAllowedModes() |
Accessor for allowed canvas modes | CanvasTypes.h | |
FBatchedElements * GetBatchedElements
(
EElementType InElementType, |
Returns a FBatchedElements pointer to be used for adding vertices and primitives for rendering. | CanvasTypes.h | |
const FMatrix & GetBottomTransform() |
Get the bottom-most element of the transform stack. | CanvasTypes.h | |
float GetDPIScale() |
CanvasTypes.h | ||
ERHIFeatureLevel::Type GetFeatureLevel() |
Access current feature level | CanvasTypes.h | |
const FMatrix & GetFullTransform() |
Get the current top-most transform entry | CanvasTypes.h | |
FHitProxyConsumer * GetHitProxyConsumer() |
CanvasTypes.h | ||
FHitProxyId GetHitProxyId() |
CanvasTypes.h | ||
FIntPoint GetParentCanvasSize() |
CanvasTypes.h | ||
FRenderTarget * GetRenderTarget() |
Get the current render target for the canvas | CanvasTypes.h | |
FSceneInterface * GetScene() |
CanvasTypes.h | ||
EShaderPlatform GetShaderPlatform() |
Access current shader platform | CanvasTypes.h | |
FCanvasSortElement & GetSortElement
(
int32 DepthSortKey |
Get the sort element for the given sort key. Allocates a new entry if one does not exist | CanvasTypes.h | |
const FGameTime & GetTime() |
Access gameplay time | CanvasTypes.h | |
FMatrix GetTransform() |
Get the current top-most transform entry without the canvas projection | CanvasTypes.h | |
const TArray< FTransformEntry > & GetTransformStack() |
Returns the transform stack | CanvasTypes.h | |
const FIntRect & GetViewRect() |
CanvasTypes.h | ||
bool HasBatchesToRender() |
Determine if the canvas has dirty batches that need to be rendered | CanvasTypes.h | |
bool IsHitTesting() |
CanvasTypes.h | ||
bool IsScaledToRenderTarget() |
CanvasTypes.h | ||
bool IsStereoRendering() |
CanvasTypes.h | ||
bool IsUsingInternalTexture() |
CanvasTypes.h | ||
bool IsWriteDestinationAlphaSet() |
CanvasTypes.h | ||
int32 PopDepthSortKey() |
Pop sort key off of the stack. | CanvasTypes.h | |
void PopTransform() |
Removes the top transform from the canvas's transform stack. | CanvasTypes.h | |
void PushAbsoluteTransform
(
const FMatrix& Transform |
Pushes a transform onto the canvas's transform stack. | CanvasTypes.h | |
void PushDepthSortKey
(
int32 InSortKey |
Push sort key onto the stack. Rendering is done with the current sort key stack entry. | CanvasTypes.h | |
void PushRelativeTransform
(
const FMatrix& Transform |
Pushes a transform onto the canvas's transform stack, multiplying it with the current top of the stack. | CanvasTypes.h | |
void SetAllowedModes
(
uint32 InAllowedModes |
Toggle allowed canvas modes | CanvasTypes.h | |
void SetBaseTransform
(
const FMatrix& Transform |
Replace the base (ie. TransformStack(0)) transform for the canvas with the given matrix | CanvasTypes.h | |
void SetHitProxy
(
HHitProxy* HitProxy |
Sets the hit proxy which will be used for subsequent canvas primitives. | CanvasTypes.h | |
void SetParentCanvasSize
(
FIntPoint InParentSize |
CanvasTypes.h | ||
void SetRenderTarget_GameThread
(
FRenderTarget* NewRenderTarget |
Sets the render target which will be used for subsequent canvas primitives. | CanvasTypes.h | |
void SetRenderTargetDirty
(
bool bDirty |
Marks render target as dirty so that it will be resolved to texture | CanvasTypes.h | |
void SetRenderTargetRect
(
const FIntRect& ViewRect |
Sets a rect that should be used to offset rendering into the viewport render target If not set the canvas will render to the full target | CanvasTypes.h | |
void SetRenderTargetScissorRect
(
const FIntRect& ScissorRect |
The clipping rectangle used when rendering this canvas | CanvasTypes.h | |
void SetScaledToRenderTarget
(
bool bScale |
CanvasTypes.h | ||
void SetStereoRendering
(
bool bStereo |
CanvasTypes.h | ||
void SetUseInternalTexture
(
const bool bInUseInternalTexture |
CanvasTypes.h | ||
void SetWriteDestinationAlpha
(
const bool bInForceWriteAlpha |
CanvasTypes.h | ||
int32 TopDepthSortKey() |
Return top sort key of the stack. | CanvasTypes.h | |
void WrapString
(
FTextSizingParameters& Parameters, |
CanvasTypes.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static ESimpleElementBlendMode BlendToSimpleElementBlend
(
EBlendMode BlendMode |
Translate EBlendMode into ESimpleElementBlendMode used by tiles | CanvasTypes.h | |
static FMatrix CalcBaseTransform2D
(
uint32 ViewSizeX, |
Generate a 2D projection for the canvas. | CanvasTypes.h | |
static FMatrix CalcBaseTransform3D
(
uint32 ViewSizeX, |
Generate a 3D projection for the canvas. Use this if you want to transform in 3D | CanvasTypes.h | |
static FMatrix CalcProjectionMatrix
(
uint32 ViewSizeX, |
Generate a projection matrix for the canvas. Used for CalcBaseTransform3D | CanvasTypes.h | |
static FMatrix CalcViewMatrix
(
uint32 ViewSizeX, |
Generate a view matrix for the canvas. Used for CalcBaseTransform3D | CanvasTypes.h | |
static FCanvas * Create
(
FRDGBuilder& GraphBuilder, |
CanvasTypes.h |