Merge primitives into compositor.

This commit is contained in:
Chinmay Garde
2021-10-18 14:52:29 -07:00
committed by Dan Field
parent 7ac751e9ad
commit e7e2555ec6
11 changed files with 31 additions and 102 deletions

View File

@@ -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",
]
}

View File

@@ -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",
]

View File

@@ -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

View File

@@ -34,7 +34,6 @@ impeller_component("entity") {
public_deps = [
"../compositor",
"../image",
"../primitives",
]
}

View File

@@ -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",
]
}

View File

@@ -34,7 +34,7 @@ static std::string ShaderLibraryDirectory() {
}
Playground::Playground()
: renderer_(ShaderLibraryDirectory(), "impeller.metallib") {}
: renderer_(ShaderLibraryDirectory(), "shader_fixtures.metallib") {}
Playground::~Playground() = default;

View File

@@ -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",
]
}

View File

@@ -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 <memory>
#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<Context>);
virtual std::shared_ptr<Pipeline> GetPipeline() const = 0;
virtual ~Primitive();
virtual bool IsValid() const = 0;
std::shared_ptr<Context> GetContext() const;
virtual bool Encode(RenderPass& pass) const = 0;
private:
std::shared_ptr<Context> context_;
FML_DISALLOW_COPY_AND_ASSIGN(Primitive);
};
} // namespace impeller

View File

@@ -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)
: context_(std::move(context)) {}
Primitive::~Primitive() = default;
std::shared_ptr<Context> Primitive::GetContext() const {
return context_;
}
} // namespace impeller