UMultithreadAwareCompositorWrapper
This class utilizes the Decorator pattern and it detects whether the provided CompositorInterface APIs invoke on the Game Thread or a Worker Thread. If the Compositor API’s are invoked on the Game Thread - the wrapper executes them on the Game Thread directly. If your cohtml::View runs in Concurrent Advance mode, the Compositor APIs will invoke on a Worker Thread and this wrapper will add them to a Queue with pending compositions which will be processed on the Game Thread.
#include <RenoirSublayerCompositor.h>
Inherits from UObject, ICompositorInterfaceUnreal
Public Functions
Name | |
---|---|
virtual void | OnDrawSubLayer(const renoir::ISubLayerCompositor::DrawData & DrawData) override Should be called on the layout thread. Since we cannot create/update textures there, we just save them for processing on the GameThread. |
virtual void | OnCompositionAdded(unsigned ViewId, const char * CompositionId, void * Metadata) override Called on GameThread whenever a new composition is found in the HTML. Should initialize the relevant materials that the texture will be drawn into. |
virtual void | OnCompositionVisibility(unsigned , const char * , void * , bool ) override Called on Game Thread whenever the visibility of the composition has changed. |
virtual void | OnCompositionTransform(unsigned , const char * , void * , const renoir::float4x4 & ) override Called on GameThread whenever the transform of the composition has changed. |
virtual void | OnCompositionRemoved(unsigned ViewId, const char * CompositionId, void * Metadata) override Called on GameThread whenever a new composition is found in the HTML. Should destroy the relevant materials that the texture will be drawn into. |
virtual void | CreateCompositions() override Executed during AdvanceCompositor after we have waited for cohtml::View::Advance and Layout. |
virtual void | SetViewSize(int32_t Width, int32_t Height) override Helper method for compositors that care about size. |
virtual void | EnqueueRenderingCommands(uint32_t FrameId) override Usually called at the end of the frame during paint. |
virtual void | ProcessDrawData(const FDrawData & DrawData, int32_t IndexToProcess) override Called on the GameThread, used to create/update textures based on the draw data received for them. Should be overridden by child classes depending on where/how they want to draw the textures. |
virtual void | DiscardCurrentFrameState() override Helper method to discard the current compositor frame. |
virtual void | CompleteFrameState(uint32_t CompositorFrame) override Should be called when the cohtml::View::Advance and Layout is completed, so that work can be done on the Game Thread. |
virtual bool | ShouldSkipFrame() override Helper method to combine multiple conditions to determine if the current compositor frame should be skipped. |
virtual bool | HasCompositions() override Helper method to save on computation when there are no compositions. |
virtual bool | IsValidObject() override Helper method to catch some invalid creation/destruction edge cases. |
virtual FFrameState * | GetCurrentFrameState() override |
virtual uint32_t | PrepareForAdvance() override Should be called once per frame, before the View gets advanced. Will update the current frame. |
virtual FrameId | GetCurrentCompositorFrameId() override |
virtual FCriticalSection & | GetCriticalSectionFrameStates() override |
virtual const TMap< FString, FDrawData > & | GetDrawDataInfoMap() const override |
void | SetCompositor(UObject * CompositorOwner, ICompositorInterfaceUnreal * CompositorInterfaceObject) |
UObject * | GetCompositorUObject() |
Additional inherited members
Public Classes inherited from ICompositorInterfaceUnreal
Name | |
---|---|
struct | FFrameState |
Public Types inherited from ICompositorInterfaceUnreal
Name | |
---|---|
using uint32_t | FrameId |
Public Functions inherited from ICompositorInterfaceUnreal
Name | |
---|---|
void | SignalFrameComplete(uint32_t FrameId) Should be called when the view’s advance/layout is finished, so we can start processing the composited elements of the page we’ve received during the layout/advance. |
void | AdvanceCompositor() Will block until the view’s advance/layout is finished, then start processing the DrawData(s) collected during (likely done by child classes) |
virtual void | PrepareAllMeshMaterial(uint32_t FrameId) |
virtual void | ProcessRenderData(const FRenderData & RenderData) |
Protected Functions inherited from ICompositorInterfaceUnreal
Name | |
---|---|
UTexture2D * | CreateTexture(const FDrawData & DrawData, IRenderingBackend * InterfaceBackend, int32_t IndexToProcess) |
Protected Attributes inherited from ICompositorInterfaceUnreal
Name | |
---|---|
FCriticalSection | CriticalSectionFrameStates |
FrameId | CompositorFrameId |
TMap< FrameId, FFrameState > | FrameStates |
TMap< FrameId, TArray< FRenderData > > | RenderDataInfosMap |
TMap< FString, FDrawData > | DrawDataInfoMap |
Public Functions Documentation
function OnDrawSubLayer
virtual void OnDrawSubLayer(
const renoir::ISubLayerCompositor::DrawData & DrawData
) override
Should be called on the layout thread. Since we cannot create/update textures there, we just save them for processing on the GameThread.
Reimplements: ICompositorInterfaceUnreal::OnDrawSubLayer
function OnCompositionAdded
virtual void OnCompositionAdded(
unsigned ViewId,
const char * CompositionId,
void * Metadata
) override
Called on GameThread whenever a new composition is found in the HTML. Should initialize the relevant materials that the texture will be drawn into.
Reimplements: ICompositorInterfaceUnreal::OnCompositionAdded
function OnCompositionVisibility
virtual void OnCompositionVisibility(
unsigned ,
const char * ,
void * ,
bool
) override
Called on Game Thread whenever the visibility of the composition has changed.
Reimplements: ICompositorInterfaceUnreal::OnCompositionVisibility
function OnCompositionTransform
virtual void OnCompositionTransform(
unsigned ,
const char * ,
void * ,
const renoir::float4x4 &
) override
Called on GameThread whenever the transform of the composition has changed.
Reimplements: ICompositorInterfaceUnreal::OnCompositionTransform
function OnCompositionRemoved
virtual void OnCompositionRemoved(
unsigned ViewId,
const char * CompositionId,
void * Metadata
) override
Called on GameThread whenever a new composition is found in the HTML. Should destroy the relevant materials that the texture will be drawn into.
Reimplements: ICompositorInterfaceUnreal::OnCompositionRemoved
function CreateCompositions
virtual void CreateCompositions() override
Executed during AdvanceCompositor after we have waited for cohtml::View::Advance and Layout.
Reimplements: ICompositorInterfaceUnreal::CreateCompositions
function SetViewSize
virtual void SetViewSize(
int32_t Width,
int32_t Height
) override
Helper method for compositors that care about size.
Reimplements: ICompositorInterfaceUnreal::SetViewSize
function EnqueueRenderingCommands
virtual void EnqueueRenderingCommands(
uint32_t FrameId
) override
Usually called at the end of the frame during paint.
Reimplements: ICompositorInterfaceUnreal::EnqueueRenderingCommands
function ProcessDrawData
virtual void ProcessDrawData(
const FDrawData & DrawData,
int32_t IndexToProcess
) override
Called on the GameThread, used to create/update textures based on the draw data received for them. Should be overridden by child classes depending on where/how they want to draw the textures.
Reimplements: ICompositorInterfaceUnreal::ProcessDrawData
function DiscardCurrentFrameState
virtual void DiscardCurrentFrameState() override
Helper method to discard the current compositor frame.
Reimplements: ICompositorInterfaceUnreal::DiscardCurrentFrameState
function CompleteFrameState
virtual void CompleteFrameState(
uint32_t CompositorFrame
) override
Should be called when the cohtml::View::Advance and Layout is completed, so that work can be done on the Game Thread.
Reimplements: ICompositorInterfaceUnreal::CompleteFrameState
function ShouldSkipFrame
virtual bool ShouldSkipFrame() override
Helper method to combine multiple conditions to determine if the current compositor frame should be skipped.
Reimplements: ICompositorInterfaceUnreal::ShouldSkipFrame
function HasCompositions
virtual bool HasCompositions() override
Helper method to save on computation when there are no compositions.
Reimplements: ICompositorInterfaceUnreal::HasCompositions
function IsValidObject
virtual bool IsValidObject() override
Helper method to catch some invalid creation/destruction edge cases.
Reimplements: ICompositorInterfaceUnreal::IsValidObject
function GetCurrentFrameState
virtual FFrameState * GetCurrentFrameState() override
Reimplements: ICompositorInterfaceUnreal::GetCurrentFrameState
function PrepareForAdvance
virtual uint32_t PrepareForAdvance() override
Should be called once per frame, before the View gets advanced. Will update the current frame.
Reimplements: ICompositorInterfaceUnreal::PrepareForAdvance
function GetCurrentCompositorFrameId
virtual FrameId GetCurrentCompositorFrameId() override
Reimplements: ICompositorInterfaceUnreal::GetCurrentCompositorFrameId
function GetCriticalSectionFrameStates
virtual FCriticalSection & GetCriticalSectionFrameStates() override
Reimplements: ICompositorInterfaceUnreal::GetCriticalSectionFrameStates
function GetDrawDataInfoMap
virtual const TMap< FString, FDrawData > & GetDrawDataInfoMap() const override
Reimplements: ICompositorInterfaceUnreal::GetDrawDataInfoMap
function SetCompositor
void SetCompositor(
UObject * CompositorOwner,
ICompositorInterfaceUnreal * CompositorInterfaceObject
)
function GetCompositorUObject
UObject * GetCompositorUObject()