From 354ce9ffe02a59823ca2a1015c23e9b7df82c037 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 8 Dec 2022 10:23:29 -0800 Subject: [PATCH] [embedder] Expose metal surface from test context (flutter/engine#38133) 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 +-- .../platform/embedder/tests/embedder_unittests_metal.mm | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.cc b/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.cc index aa83ca73dd..7a4c9b92a5 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.cc +++ b/engine/src/flutter/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/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.h b/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.h index ad1e08b831..a8f4908999 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_test_context_metal.h +++ b/engine/src/flutter/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/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_metal.mm b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_metal.mm index 7d07b54d7e..62b7a43bcc 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_metal.mm +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_metal.mm @@ -242,7 +242,8 @@ TEST_F(EmbedderTest, TextureDestructionCallbackCalledWithoutCustomCompositorMeta 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;