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

#include <embedder_test_context_metal.h>

Inheritance diagram for flutter::testing::EmbedderTestContextMetal:
flutter::testing::EmbedderTestContext

Public Types

using TestExternalTextureCallback = std::function< bool(int64_t texture_id, size_t w, size_t h, FlutterMetalExternalTexture *output)>
 
using NextDrawableCallback = std::function< FlutterMetalTexture(const FlutterFrameInfo *frame_info)>
 
using PresentCallback = std::function< bool(int64_t texture_id)>
 

Public Member Functions

 EmbedderTestContextMetal (std::string assets_path="")
 
 ~EmbedderTestContextMetal () override
 
EmbedderTestContextType GetContextType () const override
 
size_t GetSurfacePresentCount () const override
 
void SetExternalTextureCallback (TestExternalTextureCallback external_texture_frame_callback)
 
void SetPresentCallback (PresentCallback present_callback)
 
bool Present (int64_t texture_id)
 
bool PopulateExternalTexture (int64_t texture_id, size_t w, size_t h, FlutterMetalExternalTexture *output)
 
TestMetalContextGetTestMetalContext ()
 
TestMetalSurfaceGetTestMetalSurface ()
 
void SetNextDrawableCallback (NextDrawableCallback next_drawable_callback)
 
FlutterMetalTexture GetNextDrawable (const FlutterFrameInfo *frame_info)
 
- 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 15 of file embedder_test_context_metal.h.

Member Typedef Documentation

◆ NextDrawableCallback

◆ PresentCallback

Definition at line 26 of file embedder_test_context_metal.h.

◆ TestExternalTextureCallback

Definition at line 17 of file embedder_test_context_metal.h.

Constructor & Destructor Documentation

◆ EmbedderTestContextMetal()

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

Definition at line 16 of file embedder_test_context_metal.mm.

17 : EmbedderTestContext(std::move(assets_path)) {
18 metal_context_ = std::make_unique<TestMetalContext>();
22 .device = (__bridge FlutterMetalDeviceHandle)metal_context_->GetMetalDevice(),
23 .present_command_queue =
24 (__bridge FlutterMetalCommandQueueHandle)metal_context_->GetMetalCommandQueue(),
25 .get_next_drawable_callback =
26 [](void* user_data, const FlutterFrameInfo* frame_info) {
27 return reinterpret_cast<EmbedderTestContextMetal*>(user_data)->GetNextDrawable(
28 frame_info);
29 },
30 .present_drawable_callback = [](void* user_data, const FlutterMetalTexture* texture) -> bool {
31 return reinterpret_cast<EmbedderTestContextMetal*>(user_data)->Present(texture->texture_id);
32 },
33 .external_texture_frame_callback = [](void* user_data, int64_t texture_id, size_t width,
34 size_t height,
35 FlutterMetalExternalTexture* texture_out) -> bool {
37 texture_id, width, height, texture_out);
38 },
39 };
40}
EmbedderTestContext(std::string assets_path="")
FlutterMetalTexture GetNextDrawable(const FlutterFrameInfo *frame_info)
bool PopulateExternalTexture(int64_t texture_id, size_t w, size_t h, FlutterMetalExternalTexture *output)
const void * FlutterMetalDeviceHandle
Alias for id<MTLDevice>.
Definition embedder.h:800
@ kMetal
Definition embedder.h:85
const void * FlutterMetalCommandQueueHandle
Alias for id<MTLCommandQueue>.
Definition embedder.h:803
VkDevice device
Definition main.cc:69
FlTexture * texture
int32_t height
int32_t width
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalRendererConfig).
Definition embedder.h:889
FlutterMetalRendererConfig metal
Definition embedder.h:1035
FlutterRendererType type
Definition embedder.h:1031
int64_t texture_id

References device, GetNextDrawable(), height, kMetal, FlutterRendererConfig::metal, PopulateExternalTexture(), Present(), flutter::testing::EmbedderTestContext::renderer_config_, FlutterMetalRendererConfig::struct_size, texture, texture_id, FlutterRendererConfig::type, user_data, and width.

◆ ~EmbedderTestContextMetal()

flutter::testing::EmbedderTestContextMetal::~EmbedderTestContextMetal ( )
override

Definition at line 42 of file embedder_test_context_metal.mm.

42{}

Member Function Documentation

◆ GetContextType()

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

◆ GetNextDrawable()

FlutterMetalTexture flutter::testing::EmbedderTestContextMetal::GetNextDrawable ( const FlutterFrameInfo frame_info)

Definition at line 95 of file embedder_test_context_metal.mm.

95 {
96 if (next_drawable_callback_ != nullptr) {
97 return next_drawable_callback_(frame_info);
98 }
99
100 auto texture_info = metal_surface_->GetTextureInfo();
103 texture.texture_id = texture_info.texture_id;
104 texture.texture = reinterpret_cast<FlutterMetalTextureHandle>(texture_info.texture);
105 return texture;
106}
const void * FlutterMetalTextureHandle
Alias for id<MTLTexture>.
Definition embedder.h:806
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalTexture).
Definition embedder.h:855

References FlutterMetalTexture::struct_size, and texture.

Referenced by EmbedderTestContextMetal().

◆ GetSurfacePresentCount()

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

Implements flutter::testing::EmbedderTestContext.

Definition at line 48 of file embedder_test_context_metal.mm.

48 {
49 return present_count_;
50}

◆ GetTestMetalContext()

TestMetalContext * flutter::testing::EmbedderTestContextMetal::GetTestMetalContext ( )

Definition at line 52 of file embedder_test_context_metal.mm.

52 {
53 return metal_context_.get();
54}

◆ GetTestMetalSurface()

TestMetalSurface * flutter::testing::EmbedderTestContextMetal::GetTestMetalSurface ( )

Definition at line 56 of file embedder_test_context_metal.mm.

56 {
57 return metal_surface_.get();
58}

◆ PopulateExternalTexture()

bool flutter::testing::EmbedderTestContextMetal::PopulateExternalTexture ( int64_t  texture_id,
size_t  w,
size_t  h,
FlutterMetalExternalTexture output 
)

Definition at line 79 of file embedder_test_context_metal.mm.

82 {
83 if (external_texture_frame_callback_ != nullptr) {
84 return external_texture_frame_callback_(texture_id, w, h, output);
85 } else {
86 return false;
87 }
88}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
Definition switch_defs.h:54

References flutter::h, and texture_id.

Referenced by EmbedderTestContextMetal().

◆ Present()

bool flutter::testing::EmbedderTestContextMetal::Present ( int64_t  texture_id)

Definition at line 64 of file embedder_test_context_metal.mm.

64 {
66 [&]() { return metal_surface_->GetRasterSurfaceSnapshot(); });
67 present_count_++;
68 if (present_callback_ != nullptr) {
69 return present_callback_(texture_id);
70 }
71 return metal_context_->Present(texture_id);
72}
void FireRootSurfacePresentCallbackIfPresent(const std::function< sk_sp< SkImage >(void)> &image_callback)

References flutter::testing::EmbedderTestContext::FireRootSurfacePresentCallbackIfPresent(), and texture_id.

Referenced by EmbedderTestContextMetal().

◆ SetExternalTextureCallback()

void flutter::testing::EmbedderTestContextMetal::SetExternalTextureCallback ( TestExternalTextureCallback  external_texture_frame_callback)

Definition at line 74 of file embedder_test_context_metal.mm.

75 {
76 external_texture_frame_callback_ = std::move(external_texture_frame_callback);
77}

◆ SetNextDrawableCallback()

void flutter::testing::EmbedderTestContextMetal::SetNextDrawableCallback ( NextDrawableCallback  next_drawable_callback)

Definition at line 90 of file embedder_test_context_metal.mm.

91 {
92 next_drawable_callback_ = std::move(next_drawable_callback);
93}

◆ SetPresentCallback()

void flutter::testing::EmbedderTestContextMetal::SetPresentCallback ( PresentCallback  present_callback)

Definition at line 60 of file embedder_test_context_metal.mm.

60 {
61 present_callback_ = std::move(present_callback);
62}

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