diff --git a/shell/platform/embedder/tests/embedder_test_context_metal.mm b/shell/platform/embedder/tests/embedder_test_context_metal.mm index 848c93c4b90be..d50016d8ea383 100644 --- a/shell/platform/embedder/tests/embedder_test_context_metal.mm +++ b/shell/platform/embedder/tests/embedder_test_context_metal.mm @@ -19,8 +19,9 @@ renderer_config_.type = FlutterRendererType::kMetal; renderer_config_.metal = { .struct_size = sizeof(FlutterMetalRendererConfig), - .device = metal_context_->GetMetalDevice(), - .present_command_queue = metal_context_->GetMetalCommandQueue(), + .device = (__bridge FlutterMetalDeviceHandle)metal_context_->GetMetalDevice(), + .present_command_queue = + (__bridge FlutterMetalCommandQueueHandle)metal_context_->GetMetalCommandQueue(), .get_next_drawable_callback = [](void* user_data, const FlutterFrameInfo* frame_info) { return reinterpret_cast(user_data)->GetNextDrawable( diff --git a/testing/test_metal_context.h b/testing/test_metal_context.h index a0955f1db2ce4..5d3fb60aa628f 100644 --- a/testing/test_metal_context.h +++ b/testing/test_metal_context.h @@ -9,6 +9,8 @@ #include #include +#include + #include "third_party/skia/include/gpu/ganesh/GrDirectContext.h" #include "third_party/skia/include/ports/SkCFObject.h" @@ -27,9 +29,9 @@ class TestMetalContext { ~TestMetalContext(); - void* GetMetalDevice() const; + id GetMetalDevice() const; - void* GetMetalCommandQueue() const; + id GetMetalCommandQueue() const; sk_sp GetSkiaContext() const; @@ -41,7 +43,8 @@ class TestMetalContext { TextureInfo GetTextureInfo(int64_t texture_id); private: - std::unique_ptr metal_; + id device_; + id command_queue_; sk_sp skia_context_; std::mutex textures_mutex_; int64_t texture_id_ctr_ = 1; // guarded by textures_mutex diff --git a/testing/test_metal_context.mm b/testing/test_metal_context.mm index 4301a0ab0d386..7fcebbf3e84cb 100644 --- a/testing/test_metal_context.mm +++ b/testing/test_metal_context.mm @@ -17,12 +17,6 @@ namespace flutter::testing { -// TOOD(cbracken): https://github.com/flutter/flutter/issues/157942 -struct MetalObjCFields { - id device; - id command_queue; -}; - TestMetalContext::TestMetalContext() { id device = MTLCreateSystemDefaultDevice(); if (!device) { @@ -48,22 +42,21 @@ FML_LOG(ERROR) << "Could not create the GrDirectContext from the Metal Device " "and command queue."; } - - metal_ = std::make_unique(MetalObjCFields{device, command_queue}); + device_ = device; + command_queue_ = command_queue; } TestMetalContext::~TestMetalContext() { std::scoped_lock lock(textures_mutex_); textures_.clear(); - metal_.reset(); } -void* TestMetalContext::GetMetalDevice() const { - return metal_ ? (__bridge void*)metal_->device : nil; +id TestMetalContext::GetMetalDevice() const { + return device_; } -void* TestMetalContext::GetMetalCommandQueue() const { - return metal_ ? (__bridge void*)metal_->command_queue : nil; +id TestMetalContext::GetMetalCommandQueue() const { + return command_queue_; } sk_sp TestMetalContext::GetSkiaContext() const { @@ -88,12 +81,12 @@ return {.texture_id = -1, .texture = nullptr}; } - if (!metal_) { + if (!device_) { FML_CHECK(false) << "Invalid Metal device."; return {.texture_id = -1, .texture = nullptr}; } - id texture = [metal_->device newTextureWithDescriptor:texture_descriptor]; + id texture = [device_ newTextureWithDescriptor:texture_descriptor]; if (!texture) { FML_CHECK(false) << "Could not create texture from texture descriptor."; return {.texture_id = -1, .texture = nullptr};