Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
18
19namespace impeller {
20namespace testing {
21
22using EntityTest = EntityPlayground;
23
24TEST_P(EntityTest, ClipContentsOptimizesFullScreenIntersectClips) {
25 // Set up mock environment.
26
27 auto content_context = GetContentContext();
28 auto buffer = content_context->GetContext()->CreateCommandBuffer();
29 auto render_target =
30 GetContentContext()->GetRenderTargetCache()->CreateOffscreenMSAA(
31 *content_context->GetContext(), {100, 100},
32 /*mip_count=*/1);
33 auto render_pass = buffer->CreateRenderPass(render_target);
34 auto recording_pass = std::make_shared<RecordingRenderPass>(
35 render_pass, GetContext(), render_target);
36
37 // Set up clip contents.
38
39 auto contents = std::make_shared<ClipContents>();
40 contents->SetClipOperation(Entity::ClipOperation::kIntersect);
41 contents->SetGeometry(Geometry::MakeCover());
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
void SetContents(std::shared_ptr< Contents > contents)
Definition entity.cc:90
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition entity.cc:173
static std::shared_ptr< Geometry > MakeCover()
Definition geometry.cc:85
static const uint8_t buffer[]
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer)