FCanvas

Encapsulates the canvas state.

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Public/CanvasTypes.h

Include

#include "CanvasTypes.h"

Syntax

class FCanvas

Remarks

Encapsulates the canvas state.

Variables

Name Description

Public variable

*param VVer...

 

AlphaBlend

Public variable

float

 

AlphaModulate

Public variable

*param VVer...

 

Color

Public variable

int32

 

LastElementIndex

Store index of last Element off to avoid semi expensive Find()

Public variable

*param VVer...

 

SizeU

Public variable

*param VVer...

 

SizeV

Public variable

*param VVer...

 

SizeX

Public variable

*param VVer...

 

SizeY

Public variable

TMap< int32, in...

 

SortedElementLookupMap

Map from sortkey to array index of SortedElements for faster lookup of existing entries

Public variable

TArray< FCanvas...

 

SortedElements

Batched canvas elements to be sorted for rendering. Sort order is back-to-front

Public variable

*param VVer...

 

Texture

Public variable

*param VVer...

 

U

Public variable

*param V Ve...

 

V

Public variable

TSharedPtr< FCa...

 

WordWrapper

Private class for handling word wrapping behavior.

Public variable

*param VVer...

 

Y

Constructors

Name Description

Public function

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    const FGameTime& Time,
    ERHIFeatureLevel::Type InFeatureLev...,
    float InDPIScale
)

  1. For situations where a world is not available, but time information is

Public function

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    UWorld* InWorld,
    ERHIFeatureLevel::Type InFeatureLev...,
    ECanvasDrawMode DrawMode,
    float InDPIScale
)

Constructor.

Public function

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    float InRealTime,
    float InWorldTime,
    float InWorldDeltaTime,
    ERHIFeatureLevel::Type InFeatureLev...,
    float InDPIScale
)

Pass down a FGameTime instead.

Destructors

Name Description

Public function

~FCanvas()

Destructor.

Functions

Name Description

Public function

void

 

AddTileRenderItem

(
    float X,
    float Y,
    float SizeX,
    float SizeY,
    float U,
    float V,
    float SizeU,
    float SizeV,
    const FMaterialRenderProxy* Ma...,
    FHitProxyId HitProxyId,
    bool bFreezeTime,
    FColor InColor
)

Generates a new FCanvasTileRendererItem for the current sortkey and adds it to the sortelement list of items to render

Public function

void

 

AddTriangleRenderItem

(
    const FCanvasUVTri& Tri,
    const FMaterialRenderProxy* Ma...,
    FHitProxyId HitProxyId,
    bool bFreezeTime
)

Generates a new FCanvasTriangleRendererItem for the current sortkey and adds it to the sortelement list of items to render

Public function Static

ESimpleEleme...

 

BlendToSimpleElementBlend

(
    EBlendMode BlendMode
)

Translate EBlendMode into ESimpleElementBlendMode used by tiles

Public function Static

FMatrix

 

CalcBaseTransform2D

(
    uint32 ViewSizeX,
    uint32 ViewSizeY
)

Generate a 2D projection for the canvas.

Public function Static

FMatrix

 

CalcBaseTransform3D

(
    uint32 ViewSizeX,
    uint32 ViewSizeY,
    float fFOV,
    float NearPlane
)

Generate a 3D projection for the canvas. Use this if you want to transform in 3D

Public function Static

FMatrix

 

CalcProjectionMatrix

(
    uint32 ViewSizeX,
    uint32 ViewSizeY,
    float fFOV,
    float NearPlane
)

Generate a projection matrix for the canvas. Used for CalcBaseTransform3D

Public function Static

FMatrix

 

CalcViewMatrix

(
    uint32 ViewSizeX,
    uint32 ViewSizeY,
    float fFOV
)

Generate a view matrix for the canvas. Used for CalcBaseTransform3D

Public function

void

 

Clear

(
    const FLinearColor& Color
)

Clear the canvas

Public function

void

 

ClearBatchesToRender()

Clear the list of dirty batches that need to be rendered by the canvas

Public function

void

 

CopyTransformStack

(
    const FCanvas& Copy
)

Copy the conents of the TransformStack from an existing canvas

Public function Static

FCanvas *...

 

Create

(
    FRDGBuilder& GraphBuilder,
    FRDGTextureRef InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    const FGameTime& Time,
    ERHIFeatureLevel::Type InFeatureLev...,
    float InDPIScale
)

Public function

void

 

DrawItem

(
    FCanvasItem& Item
)

Draw a CanvasItem

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    const FVector2D& InPosition
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    float X,
    float Y
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawNGon

(
    const FVector2D& Center,
    const FColor& Color,
    int32 NumSides,
    float Radius
)

Public function

int32

 

DrawShadowedString

(
    double StartX,
    double StartY,
    const TCHAR* Text,
    const UFont* Font,
    const FLinearColor& Color,
    const FLinearColor& ShadowColor
)

Draw an string centered on given location.

Public function

int32

 

DrawShadowedText

(
    double StartX,
    double StartY,
    const FText& Text,
    const UFont* Font,
    const FLinearColor& Color,
    const FLinearColor& ShadowColor
)

Public function

void

 

DrawTile

(
    double X,
    double Y,
    double SizeX,
    double SizeY,
    float U,
    float V,
    float SizeU,
    float SizeV,
    const FLinearColor& Color,
    const FTexture* Texture,
    ESimpleElementBlendMode BlendMode
)

Public function

void

 

Flush_GameThread

(
    bool bForce
)

Sends a message to the rendering thread to draw the batched elements.

Public function

void

 

Flush_RenderThread

(
    FRHICommandListImmediate& RHICmdLi...,
    bool bForce
)

Sends a message to the rendering thread to draw the batched elements.

Public function

void

 

Flush_RenderThread

(
    FRDGBuilder& GraphBuilder,
    bool bForce
)

Sends a message to the rendering thread to draw the batched elements.

Public function Const

uint32

 

GetAllowedModes()

Accessor for allowed canvas modes

Public function

FBatchedElem...

 

GetBatchedElements

(
    EElementType InElementType,
    FBatchedElementParameters* InB...,
    const FTexture* Texture,
    ESimpleElementBlendMode BlendMode,
    const FDepthFieldGlowInfo& GlowInf...,
    bool bApplyDPIScale
)

Returns a FBatchedElements pointer to be used for adding vertices and primitives for rendering.

Public function Const

const FMatri...

 

GetBottomTransform()

Get the bottom-most element of the transform stack.

Public function Const

float

 

GetDPIScale()

Public function Const

ERHIFeatureL...

 

GetFeatureLevel()

Access current feature level

Public function Const

const FMatri...

 

GetFullTransform()

Get the current top-most transform entry

Public function Const

FHitProxyCon...

 

GetHitProxyConsumer()

Public function Const

FHitProxyId

 

GetHitProxyId()

Public function Const

FIntPoint

 

GetParentCanvasSize()

Public function Const

FRenderTarge...

 

GetRenderTarget()

Get the current render target for the canvas

Public function Const

FSceneInterf...

 

GetScene()

Public function Const

EShaderPlatf...

 

GetShaderPlatform()

Access current shader platform

Public function

FCanvasSortE...

 

GetSortElement

(
    int32 DepthSortKey
)

Get the sort element for the given sort key. Allocates a new entry if one does not exist

Public function Const

const FGameT...

 

GetTime()

Access gameplay time

Public function Const

FMatrix

 

GetTransform()

Get the current top-most transform entry without the canvas projection

Public function Const

const TArray...

 

GetTransformStack()

Returns the transform stack

Public function Const

const FIntRe...

 

GetViewRect()

Public function Const

bool

 

HasBatchesToRender()

Determine if the canvas has dirty batches that need to be rendered

Public function Const

bool

 

IsHitTesting()

Public function Const

bool

 

IsScaledToRenderTarget()

Public function Const

bool

 

IsStereoRendering()

Public function Const

bool

 

IsUsingInternalTexture()

Public function

int32

 

PopDepthSortKey()

Pop sort key off of the stack.

Public function

void

 

PopTransform()

Removes the top transform from the canvas's transform stack.

Public function

void

 

PushAbsoluteTransform

(
    const FMatrix& Transform
)

Pushes a transform onto the canvas's transform stack.

Public function

void

 

PushDepthSortKey

(
    int32 InSortKey
)

Push sort key onto the stack. Rendering is done with the current sort key stack entry.

Public function

void

 

PushRelativeTransform

(
    const FMatrix& Transform
)

Pushes a transform onto the canvas's transform stack, multiplying it with the current top of the stack.

Public function

void

 

SetAllowedModes

(
    uint32 InAllowedModes
)

Toggle allowed canvas modes

Public function

void

 

SetBaseTransform

(
    const FMatrix& Transform
)

Replace the base (ie. TransformStack(0)) transform for the canvas with the given matrix

Public function

void

 

SetHitProxy

(
    HHitProxy* HitProxy
)

Sets the hit proxy which will be used for subsequent canvas primitives.

Public function

void

 

SetParentCanvasSize

(
    FIntPoint InParentSize
)

Public function

void

 

SetRenderTarget_GameThread

(
    FRenderTarget* NewRenderTarget
)

Sets the render target which will be used for subsequent canvas primitives.

Public function

void

 

SetRenderTargetDirty

(
    bool bDirty
)

Marks render target as dirty so that it will be resolved to texture

Public function

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

Public function

void

 

SetRenderTargetScissorRect

(
    const FIntRect& ScissorRect
)

The clipping rectangle used when rendering this canvas

Public function

void

 

SetScaledToRenderTarget

(
    bool bScale
)

Public function

void

 

SetStereoRendering

(
    bool bStereo
)

Public function

void

 

SetUseInternalTexture

(
    const bool bInUseInternalTexture
)

Public function

*param V...

 

shown

(
    texels
)

Draw arbitrary aligned rectangle.

Public function

int32

 

TopDepthSortKey()

Return top sort key of the stack.

Public function

void

 

WrapString

(
    FTextSizingParameters& Parameters,
    const float InCurX,
    const TCHAR*const pText,
    TArray< FWrappedStringElement >& o...,
    FCanvasWordWrapper::FWrappedLineDat...
)

Classes

Name

Description

Public class

FCanvasSortElement

Contains all of the batched elements that need to be rendered at a certain depth sort key

Public class

FTransformEntry

Entry for the transform stack which stores a matrix and its CRC for faster comparisons

Enums

Name

Description

Public enum

ECanvasAllowModes

Enum for canvas features that are allowed

Public enum

ECanvasDrawMode

Public enum

EElementType

Enum that describes what type of element we are currently batching.

Deprecated Functions

Name Description

Public function Static

FCanvas *...

 

Create

(
    FRDGBuilder& GraphBuilder,
    FRDGTextureRef InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    float InRealTime,
    float InWorldTime,
    float InWorldDeltaTime,
    ERHIFeatureLevel::Type InFeatureLev...,
    float InDPIScale
)

Pass down a FGameTime instead.

Public function

 

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyC...,
    float InRealTime,
    float InWorldTime,
    float InWorldDeltaTime,
    ERHIFeatureLevel::Type InFeatureLev...,
    float InDPIScale
)

Pass down a FGameTime instead.

Public function Const

float

 

GetCurrentDeltaWorldTime()

Use FCanvas::GetTime()

Public function Const

float

 

GetCurrentRealTime()

Use FCanvas::GetTime()

Public function Const

float

 

GetCurrentWorldTime()

Use FCanvas::GetTime()

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel