Flutter Engine
The Flutter Engine
clip_contents.h
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#ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_CLIP_CONTENTS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_CLIP_CONTENTS_H_
7
8#include <functional>
9#include <memory>
10#include <vector>
11
15
16namespace impeller {
17
18class ClipContents final : public Contents {
19 public:
21
23
24 void SetGeometry(const std::shared_ptr<Geometry>& geometry);
25
27
28 // |Contents|
29 std::optional<Rect> GetCoverage(const Entity& entity) const override;
30
31 // |Contents|
33 const Entity& entity,
34 const std::optional<Rect>& current_clip_coverage) const override;
35
36 // |Contents|
37 bool ShouldRender(const Entity& entity,
38 const std::optional<Rect> clip_coverage) const override;
39
40 // |Contents|
41 bool Render(const ContentContext& renderer,
42 const Entity& entity,
43 RenderPass& pass) const override;
44 // |Contents|
45 bool CanInheritOpacity(const Entity& entity) const override;
46
47 // |Contents|
48 void SetInheritedOpacity(Scalar opacity) override;
49
50 private:
51 std::shared_ptr<Geometry> geometry_;
53
54 ClipContents(const ClipContents&) = delete;
55
56 ClipContents& operator=(const ClipContents&) = delete;
57};
58
59class ClipRestoreContents final : public Contents {
60 public:
62
64
65 void SetRestoreHeight(size_t clip_height);
66
67 size_t GetRestoreHeight() const;
68
69 /// @brief The area on the pass texture where this clip restore will be
70 /// applied. If unset, the entire pass texture will be restored.
71 ///
72 /// @note This rectangle is not transformed by the entity's transform.
73 void SetRestoreCoverage(std::optional<Rect> coverage);
74
75 // |Contents|
76 std::optional<Rect> GetCoverage(const Entity& entity) const override;
77
78 // |Contents|
80 const Entity& entity,
81 const std::optional<Rect>& current_clip_coverage) const override;
82
83 // |Contents|
84 bool ShouldRender(const Entity& entity,
85 const std::optional<Rect> clip_coverage) const override;
86
87 // |Contents|
88 bool Render(const ContentContext& renderer,
89 const Entity& entity,
90 RenderPass& pass) const override;
91
92 // |Contents|
93 bool CanInheritOpacity(const Entity& entity) const override;
94
95 // |Contents|
96 void SetInheritedOpacity(Scalar opacity) override;
97
98 private:
99 std::optional<Rect> restore_coverage_;
100 size_t restore_height_ = 0;
101
103
104 ClipRestoreContents& operator=(const ClipRestoreContents&) = delete;
105};
106
107} // namespace impeller
108
109#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_CLIP_CONTENTS_H_
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.
ClipCoverage GetClipCoverage(const Entity &entity, const std::optional< Rect > &current_clip_coverage) const override
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
void SetClipOperation(Entity::ClipOperation clip_op)
bool ShouldRender(const Entity &entity, const std::optional< Rect > clip_coverage) const override
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
void SetGeometry(const std::shared_ptr< Geometry > &geometry)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
void SetRestoreCoverage(std::optional< Rect > coverage)
The area on the pass texture where this clip restore will be applied. If unset, the entire pass textu...
ClipCoverage GetClipCoverage(const Entity &entity, const std::optional< Rect > &current_clip_coverage) const override
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
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.
bool ShouldRender(const Entity &entity, const std::optional< Rect > clip_coverage) const override
void SetRestoreHeight(size_t clip_height)
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
float Scalar
Definition: scalar.h:18