From e7e2555ec6b458e6e9546b85045efa15c30c3288 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 18 Oct 2021 14:52:29 -0700 Subject: [PATCH] Merge primitives into compositor. --- engine/src/flutter/impeller/BUILD.gn | 2 -- .../src/flutter/impeller/compositor/BUILD.gn | 2 ++ .../compositor_unittests.mm} | 16 ++++----- engine/src/flutter/impeller/entity/BUILD.gn | 1 - engine/src/flutter/impeller/fixtures/BUILD.gn | 21 ++++++++++- .../{primitives => fixtures}/box_fade.frag | 0 .../{primitives => fixtures}/box_fade.vert | 0 .../flutter/impeller/playground/playground.mm | 2 +- .../src/flutter/impeller/primitives/BUILD.gn | 35 ------------------ .../flutter/impeller/primitives/primitive.h | 36 ------------------- .../flutter/impeller/primitives/primitive.mm | 18 ---------- 11 files changed, 31 insertions(+), 102 deletions(-) rename engine/src/flutter/impeller/{primitives/primitives_unittests.mm => compositor/compositor_unittests.mm} (96%) rename engine/src/flutter/impeller/{primitives => fixtures}/box_fade.frag (100%) rename engine/src/flutter/impeller/{primitives => fixtures}/box_fade.vert (100%) delete mode 100644 engine/src/flutter/impeller/primitives/BUILD.gn delete mode 100644 engine/src/flutter/impeller/primitives/primitive.h delete mode 100644 engine/src/flutter/impeller/primitives/primitive.mm diff --git a/engine/src/flutter/impeller/BUILD.gn b/engine/src/flutter/impeller/BUILD.gn index 1d77a23fc6..6d76110214 100644 --- a/engine/src/flutter/impeller/BUILD.gn +++ b/engine/src/flutter/impeller/BUILD.gn @@ -15,7 +15,6 @@ group("impeller") { "entity", "geometry", "image", - "primitives", ] } @@ -32,6 +31,5 @@ executable("impeller_unittests") { "geometry:geometry_unittests", "image:image_unittests", "playground", - "primitives:primitives_unittests", ] } diff --git a/engine/src/flutter/impeller/compositor/BUILD.gn b/engine/src/flutter/impeller/compositor/BUILD.gn index c29c5b976c..e6d5abcac1 100644 --- a/engine/src/flutter/impeller/compositor/BUILD.gn +++ b/engine/src/flutter/impeller/compositor/BUILD.gn @@ -87,12 +87,14 @@ source_set("compositor_unittests") { testonly = true sources = [ + "compositor_unittests.mm", "device_buffer_unittests.mm", "host_buffer_unittests.mm", ] deps = [ ":compositor", + "../fixtures", "../playground", "//flutter/testing:testing_lib", ] diff --git a/engine/src/flutter/impeller/primitives/primitives_unittests.mm b/engine/src/flutter/impeller/compositor/compositor_unittests.mm similarity index 96% rename from engine/src/flutter/impeller/primitives/primitives_unittests.mm rename to engine/src/flutter/impeller/compositor/compositor_unittests.mm index d8dfee10c2..da028490b1 100644 --- a/engine/src/flutter/impeller/primitives/primitives_unittests.mm +++ b/engine/src/flutter/impeller/compositor/compositor_unittests.mm @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "flutter/fml/time/time_point.h" +#include "flutter/impeller/fixtures/box_fade.frag.h" +#include "flutter/impeller/fixtures/box_fade.vert.h" #include "flutter/testing/testing.h" #include "impeller/compositor/command.h" #include "impeller/compositor/command_buffer.h" @@ -17,15 +19,13 @@ #include "impeller/image/compressed_image.h" #include "impeller/image/decompressed_image.h" #include "impeller/playground/playground.h" -#include "impeller/primitives/box_fade.frag.h" -#include "impeller/primitives/box_fade.vert.h" namespace impeller { namespace testing { -using PrimitivesTest = Playground; +using CompositorTest = Playground; -TEST_F(PrimitivesTest, CanCreateBoxPrimitive) { +TEST_F(CompositorTest, CanCreateBoxPrimitive) { using VS = BoxFadeVertexShader; using FS = BoxFadeFragmentShader; auto context = GetContext(); @@ -89,7 +89,7 @@ TEST_F(PrimitivesTest, CanCreateBoxPrimitive) { // OpenPlaygroundHere(callback); } -TEST_F(PrimitivesTest, CanRenderMultiplePrimitives) { +TEST_F(CompositorTest, CanRenderMultiplePrimitives) { using VS = BoxFadeVertexShader; using FS = BoxFadeFragmentShader; auto context = GetContext(); @@ -160,7 +160,7 @@ TEST_F(PrimitivesTest, CanRenderMultiplePrimitives) { // OpenPlaygroundHere(callback); } -TEST_F(PrimitivesTest, CanRenderToTexture) { +TEST_F(CompositorTest, CanRenderToTexture) { using VS = BoxFadeVertexShader; using FS = BoxFadeFragmentShader; auto context = GetContext(); @@ -251,7 +251,7 @@ TEST_F(PrimitivesTest, CanRenderToTexture) { ASSERT_TRUE(r2t_pass->Commit(*context->GetTransientsAllocator())); } -TEST_F(PrimitivesTest, CanRenderPath) { +TEST_F(CompositorTest, CanRenderPath) { auto path = PathBuilder{}.AddCircle({550, 550}, 500).CreatePath(); ASSERT_FALSE(path.GetBoundingBox().IsZero()); @@ -318,7 +318,7 @@ TEST_F(PrimitivesTest, CanRenderPath) { return true; }; - OpenPlaygroundHere(callback); + // OpenPlaygroundHere(callback); } } // namespace testing diff --git a/engine/src/flutter/impeller/entity/BUILD.gn b/engine/src/flutter/impeller/entity/BUILD.gn index ef9cc7aa89..2b76285467 100644 --- a/engine/src/flutter/impeller/entity/BUILD.gn +++ b/engine/src/flutter/impeller/entity/BUILD.gn @@ -34,7 +34,6 @@ impeller_component("entity") { public_deps = [ "../compositor", "../image", - "../primitives", ] } diff --git a/engine/src/flutter/impeller/fixtures/BUILD.gn b/engine/src/flutter/impeller/fixtures/BUILD.gn index c55f7cad7e..6e664a4e2f 100644 --- a/engine/src/flutter/impeller/fixtures/BUILD.gn +++ b/engine/src/flutter/impeller/fixtures/BUILD.gn @@ -5,7 +5,17 @@ import("//flutter/impeller/tools/impeller.gni") import("//flutter/testing/testing.gni") -test_fixtures("fixtures") { +import("//flutter/impeller/tools/impeller.gni") + +impeller_shaders("shader_fixtures") { + name = "shader_fixtures" + shaders = [ + "box_fade.vert", + "box_fade.frag", + ] +} + +test_fixtures("file_fixtures") { fixtures = [ "sample.vert", "types.h", @@ -16,3 +26,12 @@ test_fixtures("fixtures") { "kalimba.jpg", ] } + +group("fixtures") { + testonly = true + + deps = [ + ":file_fixtures", + ":shader_fixtures", + ] +} diff --git a/engine/src/flutter/impeller/primitives/box_fade.frag b/engine/src/flutter/impeller/fixtures/box_fade.frag similarity index 100% rename from engine/src/flutter/impeller/primitives/box_fade.frag rename to engine/src/flutter/impeller/fixtures/box_fade.frag diff --git a/engine/src/flutter/impeller/primitives/box_fade.vert b/engine/src/flutter/impeller/fixtures/box_fade.vert similarity index 100% rename from engine/src/flutter/impeller/primitives/box_fade.vert rename to engine/src/flutter/impeller/fixtures/box_fade.vert diff --git a/engine/src/flutter/impeller/playground/playground.mm b/engine/src/flutter/impeller/playground/playground.mm index 3373594c05..8104b9bd7f 100644 --- a/engine/src/flutter/impeller/playground/playground.mm +++ b/engine/src/flutter/impeller/playground/playground.mm @@ -34,7 +34,7 @@ static std::string ShaderLibraryDirectory() { } Playground::Playground() - : renderer_(ShaderLibraryDirectory(), "impeller.metallib") {} + : renderer_(ShaderLibraryDirectory(), "shader_fixtures.metallib") {} Playground::~Playground() = default; diff --git a/engine/src/flutter/impeller/primitives/BUILD.gn b/engine/src/flutter/impeller/primitives/BUILD.gn deleted file mode 100644 index 6d50bbf25e..0000000000 --- a/engine/src/flutter/impeller/primitives/BUILD.gn +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//flutter/impeller/tools/impeller.gni") - -impeller_shaders("impeller_shaders") { - name = "impeller" - shaders = [ - "box_fade.vert", - "box_fade.frag", - ] -} - -impeller_component("primitives") { - sources = [ - "primitive.h", - "primitive.mm", - ] - - public_deps = [ - ":impeller_shaders", - "../compositor", - ] -} - -impeller_component("primitives_unittests") { - testonly = true - sources = [ "primitives_unittests.mm" ] - deps = [ - ":primitives", - "../image", - "../playground", - ] -} diff --git a/engine/src/flutter/impeller/primitives/primitive.h b/engine/src/flutter/impeller/primitives/primitive.h deleted file mode 100644 index 755abde8df..0000000000 --- a/engine/src/flutter/impeller/primitives/primitive.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#pragma once - -#include - -#include "flutter/fml/macros.h" -#include "impeller/compositor/context.h" -#include "impeller/compositor/pipeline.h" -#include "impeller/compositor/render_pass.h" - -namespace impeller { - -class Primitive { - public: - Primitive(std::shared_ptr); - - virtual std::shared_ptr GetPipeline() const = 0; - - virtual ~Primitive(); - - virtual bool IsValid() const = 0; - - std::shared_ptr GetContext() const; - - virtual bool Encode(RenderPass& pass) const = 0; - - private: - std::shared_ptr context_; - - FML_DISALLOW_COPY_AND_ASSIGN(Primitive); -}; - -} // namespace impeller diff --git a/engine/src/flutter/impeller/primitives/primitive.mm b/engine/src/flutter/impeller/primitives/primitive.mm deleted file mode 100644 index ef24844db9..0000000000 --- a/engine/src/flutter/impeller/primitives/primitive.mm +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "impeller/primitives/primitive.h" - -namespace impeller { - -Primitive::Primitive(std::shared_ptr context) - : context_(std::move(context)) {} - -Primitive::~Primitive() = default; - -std::shared_ptr Primitive::GetContext() const { - return context_; -} - -} // namespace impeller