Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::EmbedderTestCompositor Class Referenceabstract

#include <embedder_test_compositor.h>

Inheritance diagram for flutter::testing::EmbedderTestCompositor:
flutter::testing::EmbedderTestCompositorGL flutter::testing::EmbedderTestCompositorMetal flutter::testing::EmbedderTestCompositorSoftware flutter::testing::EmbedderTestCompositorVulkan

Public Types

using PlatformViewRendererCallback = std::function< sk_sp< SkImage >(const FlutterLayer &layer, GrDirectContext *context)>
 
using PresentCallback = std::function< void(FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)>
 
using NextSceneCallback = std::function< void(sk_sp< SkImage > image)>
 

Public Member Functions

 EmbedderTestCompositor (DlISize surface_size, sk_sp< GrDirectContext > context)
 
virtual ~EmbedderTestCompositor ()
 
virtual void SetRenderTargetType (EmbedderTestBackingStoreProducer::RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt)=0
 
bool CreateBackingStore (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
 
bool CollectBackingStore (const FlutterBackingStore *backing_store)
 
bool Present (FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
 
void SetPlatformViewRendererCallback (const PlatformViewRendererCallback &callback)
 
sk_sp< SkSurface > GetSurface (const FlutterBackingStore *backing_store) const
 
void SetNextPresentCallback (const PresentCallback &next_present_callback)
 Allows tests to install a callback to notify them when the entire render tree has been finalized so they can run their assertions.
 
void SetPresentCallback (const PresentCallback &present_callback, bool one_shot)
 
void SetNextSceneCallback (const NextSceneCallback &next_scene_callback)
 
sk_sp< SkImage > GetLastComposition ()
 
size_t GetPendingBackingStoresCount () const
 
size_t GetBackingStoresCreatedCount () const
 
size_t GetBackingStoresCollectedCount () const
 
void AddOnCreateRenderTargetCallback (const fml::closure &callback)
 
void AddOnCollectRenderTargetCallback (const fml::closure &callback)
 
void AddOnPresentCallback (const fml::closure &callback)
 
sk_sp< GrDirectContext > GetGrContext ()
 

Protected Member Functions

virtual bool UpdateOffscrenComposition (const FlutterLayer **layers, size_t layers_count)=0
 
 FML_DISALLOW_COPY_AND_ASSIGN (EmbedderTestCompositor)
 

Protected Attributes

std::unique_ptr< EmbedderTestBackingStoreProducerbackingstore_producer_
 
const DlISize surface_size_
 
sk_sp< GrDirectContext > context_
 
PlatformViewRendererCallback platform_view_renderer_callback_
 
bool present_callback_is_one_shot_ = false
 
PresentCallback present_callback_
 
NextSceneCallback next_scene_callback_
 
sk_sp< SkImage > last_composition_
 
size_t backing_stores_created_ = 0
 
size_t backing_stores_collected_ = 0
 
std::vector< fml::closureon_create_render_target_callbacks_
 
std::vector< fml::closureon_collect_render_target_callbacks_
 
std::vector< fml::closureon_present_callbacks_
 

Detailed Description

Definition at line 20 of file embedder_test_compositor.h.

Member Typedef Documentation

◆ NextSceneCallback

using flutter::testing::EmbedderTestCompositor::NextSceneCallback = std::function<void(sk_sp<SkImage> image)>

Definition at line 63 of file embedder_test_compositor.h.

◆ PlatformViewRendererCallback

using flutter::testing::EmbedderTestCompositor::PlatformViewRendererCallback = std::function<sk_sp<SkImage>(const FlutterLayer& layer, GrDirectContext* context)>

Definition at line 22 of file embedder_test_compositor.h.

◆ PresentCallback

Constructor & Destructor Documentation

◆ EmbedderTestCompositor()

flutter::testing::EmbedderTestCompositor::EmbedderTestCompositor ( DlISize  surface_size,
sk_sp< GrDirectContext >  context 
)

Definition at line 16 of file embedder_test_compositor.cc.

18 : surface_size_(surface_size), context_(std::move(context)) {
19 FML_CHECK(!surface_size_.IsEmpty()) << "Surface size must not be empty";
20}
#define FML_CHECK(condition)
Definition logging.h:104
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:123

References FML_CHECK, impeller::TSize< T >::IsEmpty(), and surface_size_.

◆ ~EmbedderTestCompositor()

flutter::testing::EmbedderTestCompositor::~EmbedderTestCompositor ( )
virtualdefault

Member Function Documentation

◆ AddOnCollectRenderTargetCallback()

void flutter::testing::EmbedderTestCompositor::AddOnCollectRenderTargetCallback ( const fml::closure callback)

Definition at line 128 of file embedder_test_compositor.cc.

129 {
131}
std::vector< fml::closure > on_collect_render_target_callbacks_
FlutterDesktopBinaryReply callback

References callback, and on_collect_render_target_callbacks_.

◆ AddOnCreateRenderTargetCallback()

void flutter::testing::EmbedderTestCompositor::AddOnCreateRenderTargetCallback ( const fml::closure callback)

Definition at line 123 of file embedder_test_compositor.cc.

124 {
126}
std::vector< fml::closure > on_create_render_target_callbacks_

References callback, and on_create_render_target_callbacks_.

◆ AddOnPresentCallback()

void flutter::testing::EmbedderTestCompositor::AddOnPresentCallback ( const fml::closure callback)

Definition at line 133 of file embedder_test_compositor.cc.

134 {
136}

References callback, and on_present_callbacks_.

◆ CollectBackingStore()

bool flutter::testing::EmbedderTestCompositor::CollectBackingStore ( const FlutterBackingStore backing_store)

Definition at line 43 of file embedder_test_compositor.cc.

44 {
45 // We have already set the destruction callback for the various backing
46 // stores. Our user_data is just the canvas from that backing store and does
47 // not need to be explicitly collected. Embedders might have some other state
48 // they want to collect though.
51 return true;
52}
static void InvokeAllCallbacks(const std::vector< fml::closure > &callbacks)

References backing_stores_collected_, flutter::testing::InvokeAllCallbacks(), and on_collect_render_target_callbacks_.

◆ CreateBackingStore()

bool flutter::testing::EmbedderTestCompositor::CreateBackingStore ( const FlutterBackingStoreConfig config,
FlutterBackingStore backing_store_out 
)

Definition at line 32 of file embedder_test_compositor.cc.

34 {
35 bool success = backingstore_producer_->Create(config, backing_store_out);
36 if (success) {
39 }
40 return success;
41}
std::unique_ptr< EmbedderTestBackingStoreProducer > backingstore_producer_

References backing_stores_created_, backingstore_producer_, flutter::testing::InvokeAllCallbacks(), and on_create_render_target_callbacks_.

◆ FML_DISALLOW_COPY_AND_ASSIGN()

flutter::testing::EmbedderTestCompositor::FML_DISALLOW_COPY_AND_ASSIGN ( EmbedderTestCompositor  )
protected

◆ GetBackingStoresCollectedCount()

size_t flutter::testing::EmbedderTestCompositor::GetBackingStoresCollectedCount ( ) const

Definition at line 119 of file embedder_test_compositor.cc.

119 {
121}

References backing_stores_collected_.

◆ GetBackingStoresCreatedCount()

size_t flutter::testing::EmbedderTestCompositor::GetBackingStoresCreatedCount ( ) const

Definition at line 115 of file embedder_test_compositor.cc.

115 {
117}

References backing_stores_created_.

◆ GetGrContext()

sk_sp< GrDirectContext > flutter::testing::EmbedderTestCompositor::GetGrContext ( )

Definition at line 138 of file embedder_test_compositor.cc.

138 {
139 return context_;
140}

References context_.

◆ GetLastComposition()

sk_sp< SkImage > flutter::testing::EmbedderTestCompositor::GetLastComposition ( )

Definition at line 59 of file embedder_test_compositor.cc.

References last_composition_.

◆ GetPendingBackingStoresCount()

size_t flutter::testing::EmbedderTestCompositor::GetPendingBackingStoresCount ( ) const

◆ GetSurface()

sk_sp< SkSurface > flutter::testing::EmbedderTestCompositor::GetSurface ( const FlutterBackingStore backing_store) const

Definition at line 54 of file embedder_test_compositor.cc.

55 {
56 return backingstore_producer_->GetSurface(backing_store);
57}

References backingstore_producer_.

◆ Present()

bool flutter::testing::EmbedderTestCompositor::Present ( FlutterViewId  view_id,
const FlutterLayer **  layers,
size_t  layers_count 
)

Definition at line 63 of file embedder_test_compositor.cc.

65 {
67 FML_LOG(ERROR)
68 << "Could not update the off-screen composition in the test compositor";
69 return false;
70 }
71
72 // If the test has asked to access the layers and renderers being presented.
73 // Access the same and present it to the test for its test assertions.
77 present_callback_ = nullptr;
78 }
80 }
81
83 return true;
84}
virtual bool UpdateOffscrenComposition(const FlutterLayer **layers, size_t layers_count)=0
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS FlutterViewId view_id
#define FML_LOG(severity)
Definition logging.h:101

References callback, FML_LOG, flutter::testing::InvokeAllCallbacks(), layers, layers_count, on_present_callbacks_, present_callback_, present_callback_is_one_shot_, UpdateOffscrenComposition(), and view_id.

Referenced by flutter::testing::EmbedderConfigBuilder::SetCompositor().

◆ SetNextPresentCallback()

void flutter::testing::EmbedderTestCompositor::SetNextPresentCallback ( const PresentCallback next_present_callback)

Allows tests to install a callback to notify them when the entire render tree has been finalized so they can run their assertions.

Parameters
[in]next_present_callbackThe next present callback

Definition at line 86 of file embedder_test_compositor.cc.

87 {
88 SetPresentCallback(next_present_callback, true);
89}
void SetPresentCallback(const PresentCallback &present_callback, bool one_shot)

References SetPresentCallback().

◆ SetNextSceneCallback()

void flutter::testing::EmbedderTestCompositor::SetNextSceneCallback ( const NextSceneCallback next_scene_callback)

◆ SetPlatformViewRendererCallback()

void flutter::testing::EmbedderTestCompositor::SetPlatformViewRendererCallback ( const PlatformViewRendererCallback callback)

Definition at line 105 of file embedder_test_compositor.cc.

References callback, and platform_view_renderer_callback_.

◆ SetPresentCallback()

void flutter::testing::EmbedderTestCompositor::SetPresentCallback ( const PresentCallback present_callback,
bool  one_shot 
)

Definition at line 91 of file embedder_test_compositor.cc.

93 {
95 present_callback_ = present_callback;
97}

References FML_CHECK, present_callback_, and present_callback_is_one_shot_.

Referenced by SetNextPresentCallback().

◆ SetRenderTargetType()

◆ UpdateOffscrenComposition()

virtual bool flutter::testing::EmbedderTestCompositor::UpdateOffscrenComposition ( const FlutterLayer **  layers,
size_t  layers_count 
)
protectedpure virtual

Referenced by Present().

Member Data Documentation

◆ backing_stores_collected_

size_t flutter::testing::EmbedderTestCompositor::backing_stores_collected_ = 0
protected

◆ backing_stores_created_

size_t flutter::testing::EmbedderTestCompositor::backing_stores_created_ = 0
protected

◆ backingstore_producer_

◆ context_

◆ last_composition_

sk_sp<SkImage> flutter::testing::EmbedderTestCompositor::last_composition_
protected

Definition at line 95 of file embedder_test_compositor.h.

Referenced by GetLastComposition().

◆ next_scene_callback_

NextSceneCallback flutter::testing::EmbedderTestCompositor::next_scene_callback_
protected

Definition at line 94 of file embedder_test_compositor.h.

Referenced by SetNextSceneCallback().

◆ on_collect_render_target_callbacks_

std::vector<fml::closure> flutter::testing::EmbedderTestCompositor::on_collect_render_target_callbacks_
protected

◆ on_create_render_target_callbacks_

std::vector<fml::closure> flutter::testing::EmbedderTestCompositor::on_create_render_target_callbacks_
protected

◆ on_present_callbacks_

std::vector<fml::closure> flutter::testing::EmbedderTestCompositor::on_present_callbacks_
protected

Definition at line 100 of file embedder_test_compositor.h.

Referenced by AddOnPresentCallback(), and Present().

◆ platform_view_renderer_callback_

PlatformViewRendererCallback flutter::testing::EmbedderTestCompositor::platform_view_renderer_callback_
protected

Definition at line 91 of file embedder_test_compositor.h.

Referenced by SetPlatformViewRendererCallback().

◆ present_callback_

PresentCallback flutter::testing::EmbedderTestCompositor::present_callback_
protected

Definition at line 93 of file embedder_test_compositor.h.

Referenced by Present(), and SetPresentCallback().

◆ present_callback_is_one_shot_

bool flutter::testing::EmbedderTestCompositor::present_callback_is_one_shot_ = false
protected

Definition at line 92 of file embedder_test_compositor.h.

Referenced by Present(), and SetPresentCallback().

◆ surface_size_

const DlISize flutter::testing::EmbedderTestCompositor::surface_size_
protected

Definition at line 88 of file embedder_test_compositor.h.

Referenced by EmbedderTestCompositor().


The documentation for this class was generated from the following files: