Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::EmbedderTestContextGL Class Reference

#include <embedder_test_context_gl.h>

Inheritance diagram for flutter::testing::EmbedderTestContextGL:
flutter::testing::EmbedderTestContext

Public Types

using GLGetFBOCallback = std::function< void(FlutterFrameInfo frame_info)>
 
using GLPopulateExistingDamageCallback = std::function< void(intptr_t id, FlutterDamage *existing_damage)>
 
using GLPresentCallback = std::function< void(FlutterPresentInfo present_info)>
 

Public Member Functions

 EmbedderTestContextGL (std::string assets_path="")
 
 ~EmbedderTestContextGL () override
 
size_t GetSurfacePresentCount () const override
 
EmbedderTestContextType GetContextType () const override
 
void SetOpenGLFBOCallBack ()
 
void SetOpenGLPresentCallBack ()
 
void SetGLGetFBOCallback (const GLGetFBOCallback &callback)
 Sets a callback that will be invoked (on the raster task runner) when the engine asks the embedder for a new FBO ID at the updated size.
 
void SetGLPopulateExistingDamageCallback (GLPopulateExistingDamageCallback callback)
 
uint32_t GetWindowFBOId () const
 
void SetGLPresentCallback (GLPresentCallback callback)
 Sets a callback that will be invoked (on the raster task runner) when the engine presents an fbo that was given by the embedder.
 
void GLPopulateExistingDamage (const intptr_t id, FlutterDamage *existing_damage)
 
void * GLGetProcAddress (const char *name)
 
- Public Member Functions inherited from flutter::testing::EmbedderTestContext
 EmbedderTestContext (std::string assets_path="")
 
virtual ~EmbedderTestContext ()
 
const std::string & GetAssetsPath () const
 
const fml::MappingGetVMSnapshotData () const
 
const fml::MappingGetVMSnapshotInstructions () const
 
const fml::MappingGetIsolateSnapshotData () const
 
const fml::MappingGetIsolateSnapshotInstructions () const
 
FlutterEngineAOTData GetAOTData () const
 
void SetRootSurfaceTransformation (DlMatrix matrix)
 
FlutterRendererConfigGetRendererConfig ()
 
void AddIsolateCreateCallback (const fml::closure &closure)
 
void SetSemanticsUpdateCallback2 (SemanticsUpdateCallback2 update_semantics)
 
void SetSemanticsUpdateCallback (SemanticsUpdateCallback update_semantics)
 
void AddNativeCallback (const char *name, Dart_NativeFunction function)
 
void SetSemanticsNodeCallback (SemanticsNodeCallback update_semantics_node)
 
void SetSemanticsCustomActionCallback (SemanticsActionCallback semantics_custom_action)
 
void SetPlatformMessageCallback (const std::function< void(const FlutterPlatformMessage *)> &callback)
 
void SetLogMessageCallback (const LogMessageCallback &log_message_callback)
 
void SetChannelUpdateCallback (const ChannelUpdateCallback &callback)
 
void SetViewFocusChangeRequestCallback (const ViewFocusChangeRequestCallback &callback)
 
std::future< sk_sp< SkImage > > GetNextSceneImage ()
 
EmbedderTestCompositorGetCompositor ()
 
void SetVsyncCallback (std::function< void(intptr_t)> callback)
 
void RunVsyncCallback (intptr_t baton)
 

Additional Inherited Members

- Protected Types inherited from flutter::testing::EmbedderTestContext
using NextSceneCallback = std::function< void(sk_sp< SkImage > image)>
 
- Protected Member Functions inherited from flutter::testing::EmbedderTestContext
FlutterUpdateSemanticsCallback2 GetUpdateSemanticsCallback2Hook ()
 
FlutterUpdateSemanticsCallback GetUpdateSemanticsCallbackHook ()
 
FlutterUpdateSemanticsNodeCallback GetUpdateSemanticsNodeCallbackHook ()
 
FlutterUpdateSemanticsCustomActionCallback GetUpdateSemanticsCustomActionCallbackHook ()
 
FlutterChannelUpdateCallback GetChannelUpdateCallbackHook ()
 
FlutterViewFocusChangeRequestCallback GetViewFocusChangeRequestCallbackHook ()
 
void SetupAOTMappingsIfNecessary ()
 
void SetupAOTDataIfNecessary ()
 
void FireIsolateCreateCallbacks ()
 
void SetNativeResolver ()
 
FlutterTransformation GetRootSurfaceTransformation ()
 
void PlatformMessageCallback (const FlutterPlatformMessage *message)
 
void FireRootSurfacePresentCallbackIfPresent (const std::function< sk_sp< SkImage >(void)> &image_callback)
 
void SetNextSceneCallback (const NextSceneCallback &next_scene_callback)
 
 FML_DISALLOW_COPY_AND_ASSIGN (EmbedderTestContext)
 
- Static Protected Member Functions inherited from flutter::testing::EmbedderTestContext
static VoidCallback GetIsolateCreateCallbackHook ()
 
static FlutterLogMessageCallback GetLogMessageCallbackHook ()
 
static FlutterComputePlatformResolvedLocaleCallback GetComputePlatformResolvedLocaleCallbackHook ()
 
- Protected Attributes inherited from flutter::testing::EmbedderTestContext
std::string assets_path_
 
ELFAOTSymbols aot_symbols_
 
std::unique_ptr< fml::Mappingvm_snapshot_data_
 
std::unique_ptr< fml::Mappingvm_snapshot_instructions_
 
std::unique_ptr< fml::Mappingisolate_snapshot_data_
 
std::unique_ptr< fml::Mappingisolate_snapshot_instructions_
 
UniqueAOTData aot_data_
 
std::vector< fml::closureisolate_create_callbacks_
 
std::shared_ptr< TestDartNativeResolvernative_resolver_
 
FlutterRendererConfig renderer_config_ = {}
 
SemanticsUpdateCallback2 update_semantics_callback2_
 
SemanticsUpdateCallback update_semantics_callback_
 
SemanticsNodeCallback update_semantics_node_callback_
 
SemanticsActionCallback update_semantics_custom_action_callback_
 
ChannelUpdateCallback channel_update_callback_
 
ViewFocusChangeRequestCallback view_focus_change_request_callback_
 
std::function< void(const FlutterPlatformMessage *)> platform_message_callback_
 
LogMessageCallback log_message_callback_
 
std::unique_ptr< EmbedderTestCompositorcompositor_
 
NextSceneCallback next_scene_callback_
 
DlMatrix root_surface_transformation_
 
std::function< void(intptr_t)> vsync_callback_ = nullptr
 

Detailed Description

Definition at line 16 of file embedder_test_context_gl.h.

Member Typedef Documentation

◆ GLGetFBOCallback

Definition at line 18 of file embedder_test_context_gl.h.

◆ GLPopulateExistingDamageCallback

using flutter::testing::EmbedderTestContextGL::GLPopulateExistingDamageCallback = std::function<void(intptr_t id, FlutterDamage* existing_damage)>

Definition at line 19 of file embedder_test_context_gl.h.

◆ GLPresentCallback

Definition at line 21 of file embedder_test_context_gl.h.

Constructor & Destructor Documentation

◆ EmbedderTestContextGL()

flutter::testing::EmbedderTestContextGL::EmbedderTestContextGL ( std::string  assets_path = "")
explicit

Definition at line 21 of file embedder_test_context_gl.cc.

22 : EmbedderTestContext(std::move(assets_path)),
23 egl_context_(std::make_shared<TestEGLContext>()) {
27 .make_current = [](void* context) -> bool {
28 return reinterpret_cast<EmbedderTestContextGL*>(context)
29 ->GLMakeCurrent();
30 },
31 .clear_current = [](void* context) -> bool {
32 return reinterpret_cast<EmbedderTestContextGL*>(context)
33 ->GLClearCurrent();
34 },
35 .make_resource_current = [](void* context) -> bool {
36 return reinterpret_cast<EmbedderTestContextGL*>(context)
37 ->GLMakeResourceCurrent();
38 },
39 .fbo_reset_after_present = true,
40 .surface_transformation = [](void* context) -> FlutterTransformation {
41 return reinterpret_cast<EmbedderTestContextGL*>(context)
43 },
44 .gl_proc_resolver = [](void* context, const char* name) -> void* {
45 return reinterpret_cast<EmbedderTestContextGL*>(context)
47 },
48 .fbo_with_frame_info_callback =
49 [](void* context, const FlutterFrameInfo* frame_info) -> uint32_t {
50 return reinterpret_cast<EmbedderTestContextGL*>(context)
51 ->GLGetFramebuffer(*frame_info);
52 },
53 .present_with_info = [](void* context,
54 const FlutterPresentInfo* present_info) -> bool {
55 return reinterpret_cast<EmbedderTestContextGL*>(context)->GLPresent(
56 *present_info);
57 },
58 .populate_existing_damage = nullptr,
59 };
60}
EmbedderTestContext(std::string assets_path="")
@ kOpenGL
Definition embedder.h:80
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
size_t struct_size
The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
Definition embedder.h:719
FlutterOpenGLRendererConfig open_gl
Definition embedder.h:1033
FlutterRendererType type
Definition embedder.h:1031

References flutter::testing::EmbedderTestContext::GetRootSurfaceTransformation(), GLGetProcAddress(), kOpenGL, flutter::name, FlutterRendererConfig::open_gl, flutter::testing::EmbedderTestContext::renderer_config_, FlutterOpenGLRendererConfig::struct_size, and FlutterRendererConfig::type.

◆ ~EmbedderTestContextGL()

flutter::testing::EmbedderTestContextGL::~EmbedderTestContextGL ( )
override

Definition at line 62 of file embedder_test_context_gl.cc.

62 {
63 SetGLGetFBOCallback(nullptr);
64}
void SetGLGetFBOCallback(const GLGetFBOCallback &callback)
Sets a callback that will be invoked (on the raster task runner) when the engine asks the embedder fo...

References SetGLGetFBOCallback().

Member Function Documentation

◆ GetContextType()

EmbedderTestContextType flutter::testing::EmbedderTestContextGL::GetContextType ( ) const
overridevirtual

◆ GetSurfacePresentCount()

size_t flutter::testing::EmbedderTestContextGL::GetSurfacePresentCount ( ) const
overridevirtual

Implements flutter::testing::EmbedderTestContext.

Definition at line 185 of file embedder_test_context_gl.cc.

185 {
186 return gl_surface_present_count_;
187}

◆ GetWindowFBOId()

uint32_t flutter::testing::EmbedderTestContextGL::GetWindowFBOId ( ) const

Definition at line 193 of file embedder_test_context_gl.cc.

193 {
194 FML_CHECK(gl_surface_);
195 return gl_surface_->GetWindowFBOId();
196}
#define FML_CHECK(condition)
Definition logging.h:104

References FML_CHECK.

◆ GLGetProcAddress()

void * flutter::testing::EmbedderTestContextGL::GLGetProcAddress ( const char *  name)

Definition at line 180 of file embedder_test_context_gl.cc.

180 {
181 FML_CHECK(gl_surface_) << "GL surface must be initialized.";
182 return gl_surface_->GetProcAddress(name);
183}

References FML_CHECK, and flutter::name.

Referenced by EmbedderTestContextGL().

◆ GLPopulateExistingDamage()

void flutter::testing::EmbedderTestContextGL::GLPopulateExistingDamage ( const intptr_t  id,
FlutterDamage existing_damage 
)

Definition at line 159 of file embedder_test_context_gl.cc.

161 {
162 FML_CHECK(gl_surface_) << "GL surface must be initialized.";
163
165 {
166 std::scoped_lock lock(gl_callback_mutex_);
167 callback = gl_populate_existing_damage_callback_;
168 }
169
170 if (callback) {
171 callback(id, existing_damage);
172 }
173}
std::function< void(intptr_t id, FlutterDamage *existing_damage)> GLPopulateExistingDamageCallback
FlutterDesktopBinaryReply callback

References callback, and FML_CHECK.

◆ SetGLGetFBOCallback()

void flutter::testing::EmbedderTestContextGL::SetGLGetFBOCallback ( const GLGetFBOCallback callback)

Sets a callback that will be invoked (on the raster task runner) when the engine asks the embedder for a new FBO ID at the updated size.

Attention
The callback will be invoked on the raster task runner. The callback can be set on the tests host thread.
Parameters
[in]callbackThe callback to set. The previous callback will be un-registered.

Definition at line 125 of file embedder_test_context_gl.cc.

126 {
127 std::scoped_lock lock(gl_callback_mutex_);
128 gl_get_fbo_callback_ = callback;
129}

References callback.

Referenced by ~EmbedderTestContextGL().

◆ SetGLPopulateExistingDamageCallback()

void flutter::testing::EmbedderTestContextGL::SetGLPopulateExistingDamageCallback ( GLPopulateExistingDamageCallback  callback)

Definition at line 131 of file embedder_test_context_gl.cc.

132 {
133 std::scoped_lock lock(gl_callback_mutex_);
134 gl_populate_existing_damage_callback_ = std::move(callback);
135}

References callback.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ SetGLPresentCallback()

void flutter::testing::EmbedderTestContextGL::SetGLPresentCallback ( GLPresentCallback  callback)

Sets a callback that will be invoked (on the raster task runner) when the engine presents an fbo that was given by the embedder.

Attention
The callback will be invoked on the raster task runner. The callback can be set on the tests host thread.
Parameters
[in]callbackThe callback to set. The previous callback will be un-registered.

Definition at line 137 of file embedder_test_context_gl.cc.

137 {
138 std::scoped_lock lock(gl_callback_mutex_);
139 gl_present_callback_ = std::move(callback);
140}

References callback.

◆ SetOpenGLFBOCallBack()

void flutter::testing::EmbedderTestContextGL::SetOpenGLFBOCallBack ( )

Definition at line 66 of file embedder_test_context_gl.cc.

66 {
67 // SetOpenGLRendererConfig must be called before this.
69
70 renderer_config_.open_gl.fbo_callback = [](void* context) -> uint32_t {
71 FlutterFrameInfo frame_info = {};
72 // fbo_callback doesn't use the frame size information, only
73 // fbo_callback_with_frame_info does.
74 frame_info.struct_size = sizeof(FlutterFrameInfo);
75 frame_info.size.width = 0;
76 frame_info.size.height = 0;
77 return reinterpret_cast<EmbedderTestContextGL*>(context)->GLGetFramebuffer(
78 frame_info);
79 };
80}
size_t struct_size
The size of this struct. Must be sizeof(FlutterFrameInfo).
Definition embedder.h:681
FlutterUIntSize size
The size of the surface that will be backed by the fbo.
Definition embedder.h:683
uint32_t height
Definition embedder.h:637
uint32_t width
Definition embedder.h:636

References FlutterOpenGLRendererConfig::fbo_callback, FML_CHECK, FlutterUIntSize::height, kOpenGL, FlutterRendererConfig::open_gl, flutter::testing::EmbedderTestContext::renderer_config_, FlutterFrameInfo::size, FlutterFrameInfo::struct_size, FlutterRendererConfig::type, and FlutterUIntSize::width.

◆ SetOpenGLPresentCallBack()

void flutter::testing::EmbedderTestContextGL::SetOpenGLPresentCallBack ( )

Definition at line 82 of file embedder_test_context_gl.cc.

82 {
83 // SetOpenGLRendererConfig must be called before this.
85
86 renderer_config_.open_gl.present = [](void* context) -> bool {
87 // passing a placeholder fbo_id.
88 return reinterpret_cast<EmbedderTestContextGL*>(context)->GLPresent(
90 .fbo_id = 0,
91 });
92 };
93}
uint32_t fbo_id
Id of the fbo backing the surface that was presented.
Definition embedder.h:705

References FlutterPresentInfo::fbo_id, FML_CHECK, kOpenGL, FlutterRendererConfig::open_gl, FlutterOpenGLRendererConfig::present, flutter::testing::EmbedderTestContext::renderer_config_, and FlutterRendererConfig::type.


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