5 #include "flutter/testing/testing.h"
6 #include "gmock/gmock.h"
18 std::shared_ptr<CommandBuffer> command_buffer =
20 if (!command_buffer) {
25 "Clear Subpass", size, command_buffer,
31 ->Submit({command_buffer})
36 if (render_target.ok()) {
37 return render_target.value().GetRenderTargetTexture();
49 std::optional<Rect> coverage =
51 ASSERT_FALSE(coverage.has_value());
59 std::optional<Rect> coverage =
71 std::optional<Rect> coverage =
89 void expectRenderCoverageEqual(
const std::optional<Entity>& result,
90 const std::optional<Rect> contents_coverage,
91 const Rect& expected) {
92 EXPECT_TRUE(result.has_value());
93 if (result.has_value()) {
95 std::optional<Rect> result_coverage = result.value().GetCoverage();
96 EXPECT_TRUE(result_coverage.has_value());
97 EXPECT_TRUE(contents_coverage.has_value());
98 if (result_coverage.has_value() && contents_coverage.has_value()) {
99 EXPECT_TRUE(
RectNear(contents_coverage.value(), expected));
100 EXPECT_TRUE(
RectNear(result_coverage.value(), expected));
107 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
114 std::shared_ptr<ContentContext> renderer = GetContentContext();
115 std::optional<Entity> result =
116 contents.
GetEntity(*renderer, entity, {});
117 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
122 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
131 std::shared_ptr<ContentContext> renderer = GetContentContext();
132 std::optional<Entity> result =
133 contents.
GetEntity(*renderer, entity, {});
134 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
139 RenderCoverageMatchesGetCoverageClippedSubpassTranslate) {
140 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
151 std::shared_ptr<ContentContext> renderer = GetContentContext();
152 std::optional<Entity> result =
153 contents.
GetEntity(*renderer, entity, {});
154 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
159 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
168 std::shared_ptr<ContentContext> renderer = GetContentContext();
169 std::optional<Entity> result =
170 contents.
GetEntity(*renderer, entity, {});
171 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
176 RenderCoverageMatchesGetCoverageClippedSubpassScale) {
177 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
188 std::shared_ptr<ContentContext> renderer = GetContentContext();
189 std::optional<Entity> result =
190 contents.
GetEntity(*renderer, entity, {});
191 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
196 std::shared_ptr<Texture> texture = MakeTexture(
ISize(100, 100));
207 std::shared_ptr<ContentContext> renderer = GetContentContext();
208 std::optional<Entity> result =
209 contents.
GetEntity(*renderer, entity, {});
210 expectRenderCoverageEqual(result, contents.
GetCoverage(entity),
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
@ kSubpassPrependSnapshotTransform
@ kSubpassAppendSnapshotTransform
std::shared_ptr< ContentContext > GetContentContext() const
std::optional< Entity > GetEntity(const ContentContext &renderer, const Entity &entity, const std::optional< Rect > &coverage_hint) const
Create an Entity that renders this filter's output.
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
void SetInputs(FilterInput::Vector inputs)
The input texture sources for this filter. Each input's emitted texture is expected to have premultip...
void SetEffectTransform(const Matrix &effect_transform)
Sets the transform which gets appended to the effect of this filter. Note that this is in addition to...
std::optional< Rect > GetFilterCoverage(const FilterInput::Vector &inputs, const Entity &entity, const Matrix &effect_transform) const override
Internal utility method for |GetLocalCoverage| that computes the output coverage of this filter acros...
void SetMatrix(Matrix matrix)
void SetRenderingMode(Entity::RenderingMode rendering_mode) override
Marks this filter chain as applying in a subpass scenario.
std::shared_ptr< Context > GetContext() const
Render passes encode render commands directed as one specific render target into an underlying comman...
std::shared_ptr< Texture > MakeTexture(ISize size)
Create a texture that has been cleared to transparent black.
inline ::testing::AssertionResult RectNear(impeller::Rect a, impeller::Rect b)
TEST(AllocationSizeTest, CanCreateTypedAllocations)
TEST_P(AiksTest, DrawAtlasNoColor)
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr Matrix MakeScale(const Vector3 &s)
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)