| 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 auto geom = Geometry::MakeCover();
41 contents->SetGeometry(geom.get());
42
43 Entity entity;
44 entity.SetContents(std::move(contents));
45
46 // Render the clip contents.
47
48 ASSERT_TRUE(recording_pass->GetCommands().empty());
49 ASSERT_TRUE(entity.Render(*content_context, *recording_pass));
50 ASSERT_FALSE(recording_pass->GetCommands().empty());
51 }
52
53 } // namespace testing
54 } // namespace impeller
impeller::Entity::ClipOperation::kIntersect
@ kIntersect
contents.h
entity.h
impeller::Entity::SetContents
void SetContents(std::shared_ptr< Contents > contents)
Definition: entity.cc:83
impeller::Entity
Definition: entity.h:20
impeller::Entity::Render
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition: entity.cc:156
clip_contents.h
impeller::Geometry::MakeCover
static std::unique_ptr< Geometry > MakeCover()
Definition: geometry.cc:85
impeller::testing::TEST_P
TEST_P(AiksTest, DrawAtlasNoColor)
Definition: aiks_dl_atlas_unittests.cc:78
content_context.h
impeller::EntityPlayground
Definition: entity_playground.h:16
render_target.h
impeller
Definition: allocation.cc:12
entity_playground.h