| Flutter Impeller |

clip_contents_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <memory>
6 #include <optional>
7
8 #include "gtest/gtest.h"
9
10 #include "impeller/entity/contents/clip_contents.h"
11 #include "impeller/entity/contents/content_context.h"
12 #include "impeller/entity/contents/contents.h"
13 #include "impeller/entity/contents/test/recording_render_pass.h"
14 #include "impeller/entity/entity.h"
15 #include "impeller/entity/entity_playground.h"
16 #include "impeller/renderer/render_target.h"
17
18 namespace impeller {
19 namespace testing {
20
21 using EntityTest = EntityPlayground;
22
23 TEST_P(EntityTest, ClipContentsOptimizesFullScreenIntersectClips) {
24 // Set up mock environment.
25
26 auto content_context = GetContentContext();
27 auto buffer = content_context->GetContext()->CreateCommandBuffer();
28 auto render_target =
29 GetContentContext()->GetRenderTargetCache()->CreateOffscreenMSAA(
30 *content_context->GetContext(), {100, 100},
31 /*mip_count=*/1);
32 auto render_pass = buffer->CreateRenderPass(render_target);
33 auto recording_pass = std::make_shared<RecordingRenderPass>(
34 render_pass, GetContext(), render_target);
35
36 // Set up clip contents.
37
38 auto contents = std::make_shared<ClipContents>();
39 contents->SetClipOperation(Entity::ClipOperation::kIntersect);
40 contents->SetGeometry(Geometry::MakeCover());
41
42 Entity entity;
43 entity.SetContents(std::move(contents));
44
45 // Render the clip contents.
46
47 ASSERT_TRUE(recording_pass->GetCommands().empty());
48 ASSERT_TRUE(entity.Render(*content_context, *recording_pass));
49 ASSERT_FALSE(recording_pass->GetCommands().empty());
50 }
51
52 } // namespace testing
53 } // namespace impeller
impeller::Entity::ClipOperation::kIntersect
@ kIntersect
contents.h
entity.h
impeller::testing::TEST_P
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)
Definition: aiks_blend_unittests.cc:21
impeller::Entity::SetContents
void SetContents(std::shared_ptr< Contents > contents)
Definition: entity.cc:90
impeller::Entity
Definition: entity.h:20
impeller::Entity::Render
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition: entity.cc:173
clip_contents.h
content_context.h
impeller::EntityPlayground
Definition: entity_playground.h:17
render_target.h
impeller
Definition: aiks_blend_unittests.cc:18
impeller::Geometry::MakeCover
static std::shared_ptr< Geometry > MakeCover()
Definition: geometry.cc:85
entity_playground.h