FCanvas

Encapsulates the canvas state.

Windows
MacOS
Linux

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 VVertical position of the upper left corner of the portion of the texture to be float float float float float float float const FLinearColor const FTexturebool

 

AlphaBlend

Public variable

float

 

AlphaModulate

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float float float float float const FLinearColor &

 

Color

Public variable

int32

 

LastElementIndex

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

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float float float float

 

SizeU

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float float float float float

 

SizeV

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float

 

SizeX

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float

 

SizeY

Public variable

TMap< int32, int32 >

 

SortedElementLookupMap

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

Public variable

TArray< FCanvasSortElement >

 

SortedElements

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

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float float float float float const FLinearColor const FTexture *

 

Texture

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float float float float

 

U

Public variable

*param V Vertical position of the upper left corner of the portion of the texture to be float float float float float

 

V

Public variable

TSharedPtr< FCanvasWordWrapper >

 

WordWrapper

Private class for handling word wrapping behavior.

Public variable

*param VVertical position of the upper left corner of the portion of the texture to be float

 

Y

Constructors

Name Description

Public function

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyConsumer,
    UWorld* InWorld,
    ERHIFeatureLevel::Type InFeatureLevel,
    ECanvasDrawMode DrawMode,
    float InDPIScale
)

Constructor.

Public function

FCanvas

(
    FRenderTarget* InRenderTarget,
    FHitProxyConsumer* InHitProxyConsumer,
    float InRealTime,
    float InWorldTime,
    float InWorldDeltaTime,
    ERHIFeatureLevel::Type InFeatureLevel,
    float InDPIScale
)

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

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* MaterialRenderProxy,
    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* MaterialRenderProxy,
    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

ESimpleElementBlendMode

 

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

 

CopyTransformStack

(
    const FCanvas& Copy
)

Copy the conents of the TransformStack from an existing canvas

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    float X,
    float Y
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    const FVector2D& InPosition
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawItem

(
    FCanvasItem& Item
)

Draw a CanvasItem

Public function

void

 

DrawNGon

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

Public function

int32

 

DrawShadowedString

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

Draw an string centered on given location.

Public function

int32

 

DrawShadowedText

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

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& RHICmdList,
    bool bForce,
    bool bInsideRenderPass
)

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

Public function Const

uint32

 

GetAllowedModes()

Accessor for allowed canvas modes

Public function Const

bool

 

GetAllowSwitchVerticalAxis()

Get/Set if this Canvas allows its batched elements to switch vertical axis (e.g., rendering to back buffer should never flip)

Public function

FBatchedElements *

 

GetBatchedElements

(
    EElementType InElementType,
    FBatchedElementParameters* InBatchedElementParameters,
    const FTexture* Texture,
    ESimpleElementBlendMode BlendMode,
    const FDepthFieldGlowInfo& GlowInfo,
    bool bApplyDPIScale
)

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

Public function Const

const FMatrix &

 

GetBottomTransform()

Get the bottom-most element of the transform stack.

Public function Const

float

 

GetCurrentDeltaWorldTime()

Access current delta time

Public function Const

float

 

GetCurrentRealTime()

Access current real time

Public function Const

float

 

GetCurrentWorldTime()

Access current world time

Public function Const

float

 

GetDPIScale()

Public function Const

ERHIFeatureLevel::Type

 

GetFeatureLevel()

Access current feature level

Public function Const

const FMatrix &

 

GetFullTransform()

Get the current top-most transform entry

Public function Const

FHitProxyConsumer *

 

GetHitProxyConsumer()

Public function Const

FHitProxyId

 

GetHitProxyId()

Public function Const

FIntPoint

 

GetParentCanvasSize()

Public function Const

FRenderTarget *

 

GetRenderTarget()

Get the current render target for the canvas

Public function Const

FSceneInterface *

 

GetScene()

Public function Const

EShaderPlatform

 

GetShaderPlatform()

Access current shader platform

Public function

FCanvasSortElement &

 

GetSortElement

(
    int32 DepthSortKey
)

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

Public function Const

FMatrix

 

GetTransform()

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

Public function Const

const TArray< FTransformEntry > &

 

GetTransformStack()

Returns the transform stack

Public function Const

const FIntRect &

 

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

 

SetAllowSwitchVerticalAxis

(
    bool bInAllowsToSwitchVerticalAxis
)

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 VVertical position of the upper left corner of the portion of the texture to be

 

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 >& out_Lines,
    FCanvasWordWrapper::FWrappedLineData*const OutWrappedLineData
)

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.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback