From 9f5b68ded6f3b460dcea6e0001706bf3fe77fd40 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 26 Oct 2022 11:31:24 -0700 Subject: [PATCH] Fix runtime stage tests (flutter/engine#37025) --- .../flutter/impeller/entity/entity_unittests.cc | 2 +- .../flutter/impeller/playground/playground.cc | 16 ---------------- .../src/flutter/impeller/playground/playground.h | 3 --- .../impeller/playground/playground_test.cc | 13 +++++++++++++ .../impeller/playground/playground_test.h | 3 +++ .../runtime_stage/runtime_stage_playground.cc | 13 ------------- .../runtime_stage/runtime_stage_playground.h | 3 --- .../runtime_stage/runtime_stage_unittests.cc | 2 +- 8 files changed, 18 insertions(+), 37 deletions(-) diff --git a/engine/src/flutter/impeller/entity/entity_unittests.cc b/engine/src/flutter/impeller/entity/entity_unittests.cc index 7d57ad8b5e4..c8e3b88d682 100644 --- a/engine/src/flutter/impeller/entity/entity_unittests.cc +++ b/engine/src/flutter/impeller/entity/entity_unittests.cc @@ -2086,7 +2086,7 @@ TEST_P(EntityTest, RuntimeEffect) { contents->SetGeometry(Geometry::MakeCover()); auto runtime_stage = - LoadFixtureRuntimeStage("runtime_stage_example.frag.iplr"); + OpenAssetAsRuntimeStage("runtime_stage_example.frag.iplr"); contents->SetRuntimeStage(runtime_stage); struct FragUniforms { diff --git a/engine/src/flutter/impeller/playground/playground.cc b/engine/src/flutter/impeller/playground/playground.cc index 312713c2643..d25b686a29c 100644 --- a/engine/src/flutter/impeller/playground/playground.cc +++ b/engine/src/flutter/impeller/playground/playground.cc @@ -437,22 +437,6 @@ std::shared_ptr Playground::CreateTextureCubeForFixture( return texture; } -std::shared_ptr Playground::LoadFixtureRuntimeStage( - const char* fixture_name) const { - if (fixture_name == nullptr) { - return nullptr; - } - - auto runtime_stage = - std::make_shared(OpenAssetAsMapping(fixture_name)); - - if (!runtime_stage->IsValid()) { - VALIDATION_LOG << "Could not load valid runtime stage."; - return nullptr; - } - return runtime_stage; -} - void Playground::SetWindowSize(ISize size) { window_size_ = size; } diff --git a/engine/src/flutter/impeller/playground/playground.h b/engine/src/flutter/impeller/playground/playground.h index 255c87d7b47..82e1edf2946 100644 --- a/engine/src/flutter/impeller/playground/playground.h +++ b/engine/src/flutter/impeller/playground/playground.h @@ -64,9 +64,6 @@ class Playground { std::shared_ptr CreateTextureCubeForFixture( std::array fixture_names) const; - std::shared_ptr LoadFixtureRuntimeStage( - const char* fixture_name) const; - static bool SupportsBackend(PlaygroundBackend backend); virtual std::unique_ptr OpenAssetAsMapping( diff --git a/engine/src/flutter/impeller/playground/playground_test.cc b/engine/src/flutter/impeller/playground/playground_test.cc index 1627cf9a711..024c4d52174 100644 --- a/engine/src/flutter/impeller/playground/playground_test.cc +++ b/engine/src/flutter/impeller/playground/playground_test.cc @@ -34,6 +34,19 @@ std::unique_ptr PlaygroundTest::OpenAssetAsMapping( return flutter::testing::OpenFixtureAsMapping(asset_name); } +std::shared_ptr PlaygroundTest::OpenAssetAsRuntimeStage( + const char* asset_name) const { + auto fixture = flutter::testing::OpenFixtureAsMapping(asset_name); + if (!fixture || fixture->GetSize() == 0) { + return nullptr; + } + auto stage = std::make_unique(std::move(fixture)); + if (!stage->IsValid()) { + return nullptr; + } + return stage; +} + static std::string FormatWindowTitle(const std::string& test_name) { std::stringstream stream; stream << "Impeller Playground for '" << test_name diff --git a/engine/src/flutter/impeller/playground/playground_test.h b/engine/src/flutter/impeller/playground/playground_test.h index 2e10faebffc..351cbc0c954 100644 --- a/engine/src/flutter/impeller/playground/playground_test.h +++ b/engine/src/flutter/impeller/playground/playground_test.h @@ -27,6 +27,9 @@ class PlaygroundTest : public Playground, std::unique_ptr OpenAssetAsMapping( std::string asset_name) const override; + std::shared_ptr OpenAssetAsRuntimeStage( + const char* asset_name) const; + // |Playground| std::string GetWindowTitle() const override; diff --git a/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.cc b/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.cc index 09603084331..de0d3cf66f9 100644 --- a/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.cc +++ b/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.cc @@ -17,19 +17,6 @@ RuntimeStagePlayground::RuntimeStagePlayground() = default; RuntimeStagePlayground::~RuntimeStagePlayground() = default; -std::unique_ptr RuntimeStagePlayground::CreateStageFromFixture( - const std::string& fixture_name) const { - auto fixture = flutter::testing::OpenFixtureAsMapping(fixture_name); - if (!fixture || fixture->GetSize() == 0) { - return nullptr; - } - auto stage = std::make_unique(std::move(fixture)); - if (!stage->IsValid()) { - return nullptr; - } - return stage; -} - bool RuntimeStagePlayground::RegisterStage(const RuntimeStage& stage) { std::promise registration; auto future = registration.get_future(); diff --git a/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.h b/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.h index 0b4168b2220..3a1821006c7 100644 --- a/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.h +++ b/engine/src/flutter/impeller/runtime_stage/runtime_stage_playground.h @@ -16,9 +16,6 @@ class RuntimeStagePlayground : public PlaygroundTest { ~RuntimeStagePlayground(); - std::unique_ptr CreateStageFromFixture( - const std::string& fixture_name) const; - bool RegisterStage(const RuntimeStage& stage); private: diff --git a/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc b/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc index fd454cfe2c1..99efecefa88 100644 --- a/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc +++ b/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc @@ -216,7 +216,7 @@ TEST_P(RuntimeStageTest, CanCreatePipelineFromRuntimeStage) { if (GetParam() != PlaygroundBackend::kMetal) { GTEST_SKIP_("Skipped: https://github.com/flutter/flutter/issues/105538"); } - auto stage = CreateStageFromFixture("ink_sparkle.frag.iplr"); + auto stage = OpenAssetAsRuntimeStage("ink_sparkle.frag.iplr"); ASSERT_NE(stage, nullptr); ASSERT_TRUE(RegisterStage(*stage)); auto library = GetContext()->GetShaderLibrary();