Flutter Engine
flutter::testing::EmbedderTestCompositor Class Referenceabstract

#include <embedder_test_compositor.h>

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

Public Types

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

Public Member Functions

 EmbedderTestCompositor (SkISize surface_size, sk_sp< GrDirectContext > context)
 
virtual ~EmbedderTestCompositor ()
 
void SetBackingStoreProducer (std::unique_ptr< EmbedderTestBackingStoreProducer > backingstore_producer)
 
bool CreateBackingStore (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
 
bool CollectBackingStore (const FlutterBackingStore *backing_store)
 
bool Present (const FlutterLayer **layers, size_t layers_count)
 
void SetPlatformViewRendererCallback (const PlatformViewRendererCallback &callback)
 
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. More...
 
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 (fml::closure callback)
 
void AddOnCollectRenderTargetCallback (fml::closure callback)
 
void AddOnPresentCallback (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 SkISize 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 19 of file embedder_test_compositor.h.

Member Typedef Documentation

◆ NextSceneCallback

Definition at line 56 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 23 of file embedder_test_compositor.h.

◆ PresentCallback

using flutter::testing::EmbedderTestCompositor::PresentCallback = std::function<void(const FlutterLayer** layers, size_t layers_count)>

Definition at line 25 of file embedder_test_compositor.h.

Constructor & Destructor Documentation

◆ EmbedderTestCompositor()

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

Definition at line 14 of file embedder_test_compositor.cc.

References FML_CHECK, surface_size_, and ~EmbedderTestCompositor().

16  : surface_size_(surface_size), context_(context) {
17  FML_CHECK(!surface_size_.isEmpty()) << "Surface size must not be empty";
18 }
#define FML_CHECK(condition)
Definition: logging.h:68

◆ ~EmbedderTestCompositor()

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

Referenced by EmbedderTestCompositor().

Member Function Documentation

◆ AddOnCollectRenderTargetCallback()

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

Definition at line 125 of file embedder_test_compositor.cc.

References on_collect_render_target_callbacks_.

126  {
127  on_collect_render_target_callbacks_.push_back(callback);
128 }
std::vector< fml::closure > on_collect_render_target_callbacks_

◆ AddOnCreateRenderTargetCallback()

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

Definition at line 120 of file embedder_test_compositor.cc.

References on_create_render_target_callbacks_.

121  {
122  on_create_render_target_callbacks_.push_back(callback);
123 }
std::vector< fml::closure > on_create_render_target_callbacks_

◆ AddOnPresentCallback()

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

Definition at line 130 of file embedder_test_compositor.cc.

References on_present_callbacks_.

130  {
131  on_present_callbacks_.push_back(callback);
132 }

◆ CollectBackingStore()

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

Definition at line 41 of file embedder_test_compositor.cc.

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

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

◆ CreateBackingStore()

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

Definition at line 30 of file embedder_test_compositor.cc.

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

32  {
33  bool success = backingstore_producer_->Create(config, backing_store_out);
34  if (success) {
37  }
38  return success;
39 }
static void InvokeAllCallbacks(const std::vector< fml::closure > &callbacks)
std::vector< fml::closure > on_create_render_target_callbacks_
std::unique_ptr< EmbedderTestBackingStoreProducer > backingstore_producer_

◆ 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 116 of file embedder_test_compositor.cc.

References backing_stores_collected_.

◆ GetBackingStoresCreatedCount()

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

Definition at line 112 of file embedder_test_compositor.cc.

References backing_stores_created_.

◆ GetGrContext()

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

Definition at line 134 of file embedder_test_compositor.cc.

References context_.

134  {
135  return context_;
136 }

◆ GetLastComposition()

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

Definition at line 57 of file embedder_test_compositor.cc.

References last_composition_.

57  {
58  return last_composition_;
59 }

◆ GetPendingBackingStoresCount()

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

◆ Present()

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

Definition at line 61 of file embedder_test_compositor.cc.

References FML_LOG, flutter::testing::InvokeAllCallbacks(), on_present_callbacks_, present_callback_, present_callback_is_one_shot_, and UpdateOffscrenComposition().

62  {
63  if (!UpdateOffscrenComposition(layers, layers_count)) {
64  FML_LOG(ERROR)
65  << "Could not update the off-screen composition in the test compositor";
66  return false;
67  }
68 
69  // If the test has asked to access the layers and renderers being presented.
70  // Access the same and present it to the test for its test assertions.
71  if (present_callback_) {
72  auto callback = present_callback_;
74  present_callback_ = nullptr;
75  }
76  callback(layers, layers_count);
77  }
78 
80  return true;
81 }
static void InvokeAllCallbacks(const std::vector< fml::closure > &callbacks)
virtual bool UpdateOffscrenComposition(const FlutterLayer **layers, size_t layers_count)=0
#define FML_LOG(severity)
Definition: logging.h:65

◆ SetBackingStoreProducer()

void flutter::testing::EmbedderTestCompositor::SetBackingStoreProducer ( std::unique_ptr< EmbedderTestBackingStoreProducer backingstore_producer)

Definition at line 52 of file embedder_test_compositor.cc.

References backingstore_producer_.

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

53  {
54  backingstore_producer_ = std::move(backingstore_producer);
55 }
std::unique_ptr< EmbedderTestBackingStoreProducer > backingstore_producer_

◆ 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 83 of file embedder_test_compositor.cc.

References SetPresentCallback().

84  {
85  SetPresentCallback(next_present_callback, true);
86 }
void SetPresentCallback(const PresentCallback &present_callback, bool one_shot)

◆ SetNextSceneCallback()

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

Definition at line 96 of file embedder_test_compositor.cc.

References FML_CHECK, and next_scene_callback_.

97  {
99  next_scene_callback_ = next_scene_callback;
100 }
#define FML_CHECK(condition)
Definition: logging.h:68

◆ SetPlatformViewRendererCallback()

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

Definition at line 102 of file embedder_test_compositor.cc.

References platform_view_renderer_callback_.

103  {
105 }
PlatformViewRendererCallback platform_view_renderer_callback_

◆ SetPresentCallback()

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

Definition at line 88 of file embedder_test_compositor.cc.

References FML_CHECK, present_callback_, and present_callback_is_one_shot_.

Referenced by SetNextPresentCallback().

90  {
92  present_callback_ = present_callback;
94 }
#define FML_CHECK(condition)
Definition: logging.h:68

◆ 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_

std::unique_ptr<EmbedderTestBackingStoreProducer> flutter::testing::EmbedderTestCompositor::backingstore_producer_
protected

Definition at line 80 of file embedder_test_compositor.h.

Referenced by CreateBackingStore(), and SetBackingStoreProducer().

◆ context_

sk_sp<GrDirectContext> flutter::testing::EmbedderTestCompositor::context_
protected

◆ last_composition_

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

◆ next_scene_callback_

◆ 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 93 of file embedder_test_compositor.h.

Referenced by AddOnPresentCallback(), and Present().

◆ platform_view_renderer_callback_

◆ present_callback_

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

Definition at line 86 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 85 of file embedder_test_compositor.h.

Referenced by Present(), and SetPresentCallback().

◆ surface_size_


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