Flutter Impeller
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 
11 
12 namespace impeller {
13 
14 class ClipContents final : public Contents {
15  public:
16  ClipContents();
17 
18  ~ClipContents();
19 
20  void SetGeometry(const Geometry* geometry);
21 
23 
24  // |Contents|
25  std::optional<Rect> GetCoverage(const Entity& entity) const override;
26 
27  // |Contents|
29  const Entity& entity,
30  const std::optional<Rect>& current_clip_coverage) const override;
31 
32  // |Contents|
33  bool Render(const ContentContext& renderer,
34  const Entity& entity,
35  RenderPass& pass) const override;
36 
37  // |Contents|
38  void SetInheritedOpacity(Scalar opacity) override;
39 
40  private:
41  const Geometry* geometry_ = nullptr;
43 
44  ClipContents(const ClipContents&) = delete;
45 
46  ClipContents& operator=(const ClipContents&) = delete;
47 };
48 
49 class ClipRestoreContents final : public Contents {
50  public:
52 
54 
55  void SetRestoreHeight(size_t clip_height);
56 
57  size_t GetRestoreHeight() const;
58 
59  /// @brief The area on the pass texture where this clip restore will be
60  /// applied. If unset, the entire pass texture will be restored.
61  ///
62  /// @note This rectangle is not transformed by the entity's transform.
63  void SetRestoreCoverage(std::optional<Rect> coverage);
64 
65  // |Contents|
66  std::optional<Rect> GetCoverage(const Entity& entity) const override;
67 
68  // |Contents|
70  const Entity& entity,
71  const std::optional<Rect>& current_clip_coverage) const override;
72 
73  // |Contents|
74  bool Render(const ContentContext& renderer,
75  const Entity& entity,
76  RenderPass& pass) const override;
77 
78  // |Contents|
79  void SetInheritedOpacity(Scalar opacity) override;
80 
81  private:
82  std::optional<Rect> restore_coverage_;
83  size_t restore_height_ = 0;
84 
86 
87  ClipRestoreContents& operator=(const ClipRestoreContents&) = delete;
88 };
89 
90 } // namespace impeller
91 
92 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_CLIP_CONTENTS_H_
impeller::Entity::ClipOperation::kIntersect
@ kIntersect
contents.h
impeller::ClipRestoreContents::ClipRestoreContents
ClipRestoreContents()
impeller::Scalar
float Scalar
Definition: scalar.h:18
geometry.h
impeller::ClipRestoreContents::GetCoverage
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.
Definition: clip_contents.cc:187
entity.h
impeller::ClipContents::SetClipOperation
void SetClipOperation(Entity::ClipOperation clip_op)
Definition: clip_contents.cc:39
impeller::ClipRestoreContents::SetRestoreCoverage
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...
Definition: clip_contents.cc:182
impeller::ClipRestoreContents::GetRestoreHeight
size_t GetRestoreHeight() const
Definition: clip_contents.cc:178
impeller::ClipRestoreContents::~ClipRestoreContents
~ClipRestoreContents()
impeller::ClipContents::GetClipCoverage
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...
Definition: clip_contents.cc:47
impeller::Entity
Definition: entity.h:20
impeller::ClipContents::ClipContents
ClipContents()
impeller::ClipRestoreContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: clip_contents.cc:200
impeller::ClipContents::~ClipContents
~ClipContents()
impeller::ClipContents::GetCoverage
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.
Definition: clip_contents.cc:43
impeller::ClipContents::SetGeometry
void SetGeometry(const Geometry *geometry)
Definition: clip_contents.cc:35
impeller::ClipRestoreContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: clip_contents.cc:198
impeller::ClipRestoreContents
Definition: clip_contents.h:49
impeller::ClipContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: clip_contents.cc:81
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::Geometry
Definition: geometry.h:55
impeller::ClipRestoreContents::GetClipCoverage
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...
Definition: clip_contents.cc:192
impeller::Contents::ClipCoverage
Definition: contents.h:37
impeller::ClipContents
Definition: clip_contents.h:14
impeller::Entity::ClipOperation
ClipOperation
Definition: entity.h:61
impeller::ClipContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: clip_contents.cc:79
impeller::ClipRestoreContents::SetRestoreHeight
void SetRestoreHeight(size_t clip_height)
Definition: clip_contents.cc:174
impeller::Contents
Definition: contents.h:31
impeller
Definition: allocation.cc:12
impeller::ContentContext
Definition: content_context.h:366