From 87266d742f3b2c16db64fcd380cc6668707a73bf Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 7 Dec 2022 19:53:41 -0800 Subject: [PATCH] [embedder] Expose metal surface from test context This is a minor cleanup that exposes the test metal surface to tests via EmbedderTestContextMeta::GetTestMetalSurface for parity with the GetTestMetalContext method which exposes the test metal context. This eliminates the need for the more specific GetTextureInfo method since the texture info is accessible via the test context. This is a test refactoring with no semantic differences to the engine. Issue: https://github.com/flutter/flutter/issues/116381 --- .../embedder/tests/embedder_test_context_metal.cc | 8 ++++---- .../platform/embedder/tests/embedder_test_context_metal.h | 3 +-- shell/platform/embedder/tests/embedder_unittests_metal.mm | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/embedder/tests/embedder_test_context_metal.cc b/shell/platform/embedder/tests/embedder_test_context_metal.cc index aa83ca73ddd03..7a4c9b92a58fa 100644 --- a/shell/platform/embedder/tests/embedder_test_context_metal.cc +++ b/shell/platform/embedder/tests/embedder_test_context_metal.cc @@ -47,6 +47,10 @@ TestMetalContext* EmbedderTestContextMetal::GetTestMetalContext() { return metal_context_.get(); } +TestMetalSurface* EmbedderTestContextMetal::GetTestMetalSurface() { + return metal_surface_.get(); +} + void EmbedderTestContextMetal::SetPresentCallback( PresentCallback present_callback) { present_callback_ = std::move(present_callback); @@ -79,10 +83,6 @@ bool EmbedderTestContextMetal::PopulateExternalTexture( } } -TestMetalContext::TextureInfo EmbedderTestContextMetal::GetTextureInfo() { - return metal_surface_->GetTextureInfo(); -} - void EmbedderTestContextMetal::SetNextDrawableCallback( NextDrawableCallback next_drawable_callback) { next_drawable_callback_ = std::move(next_drawable_callback); diff --git a/shell/platform/embedder/tests/embedder_test_context_metal.h b/shell/platform/embedder/tests/embedder_test_context_metal.h index ad1e08b83173c..a8f49089997e8 100644 --- a/shell/platform/embedder/tests/embedder_test_context_metal.h +++ b/shell/platform/embedder/tests/embedder_test_context_metal.h @@ -53,8 +53,7 @@ class EmbedderTestContextMetal : public EmbedderTestContext { TestMetalContext* GetTestMetalContext(); - // Returns the TextureInfo for the test Metal surface. - TestMetalContext::TextureInfo GetTextureInfo(); + TestMetalSurface* GetTestMetalSurface(); // Override the default handling for GetNextDrawable. void SetNextDrawableCallback(NextDrawableCallback next_drawable_callback); diff --git a/shell/platform/embedder/tests/embedder_unittests_metal.mm b/shell/platform/embedder/tests/embedder_unittests_metal.mm index 7d07b54d7e894..62b7a43bcc83d 100644 --- a/shell/platform/embedder/tests/embedder_unittests_metal.mm +++ b/shell/platform/embedder/tests/embedder_unittests_metal.mm @@ -242,7 +242,8 @@ GrBackendTexture backend_texture(texture_size.width(), texture_size.height(), Gr auto collect_context = std::make_unique(); context.SetNextDrawableCallback([&context, &collect_context](const FlutterFrameInfo* frame_info) { - auto texture_info = context.GetTextureInfo(); + auto texture_info = context.GetTestMetalSurface()->GetTextureInfo(); + FlutterMetalTexture texture; texture.struct_size = sizeof(FlutterMetalTexture); texture.texture_id = texture_info.texture_id;