Flutter Engine
 
Loading...
Searching...
No Matches
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
12namespace impeller {
13
15 // TODO(jonahwilliams): this should probably use the Entity::ClipOperation
16 // enum, but that has transitive import errors.
18
19 /// @brief This coverage is the outer coverage of the clip.
20 ///
21 /// For example, if the clip is a circular clip, this is the rectangle that
22 /// contains the circle and not the rectangle that is contained within the
23 /// circle. This means that we cannot use the coverage alone to determine if
24 /// a clip can be culled, and instead also use the somewhat hacky
25 /// "is_difference_or_non_square" field.
26 std::optional<Rect> coverage = std::nullopt;
27};
28
30 public:
31 ClipContents(Rect coverage_rect, bool is_axis_aligned_rect);
32
34
35 /// @brief Set the pre-tessellated clip geometry.
36 void SetGeometry(GeometryResult geometry);
37
39
40 //----------------------------------------------------------------------------
41 /// @brief Given the current pass space bounding rectangle of the clip
42 /// buffer, return the expected clip coverage after this draw call.
43 /// This should only be implemented for contents that may write to the
44 /// clip buffer.
45 ///
46 /// During rendering, coverage coordinates count pixels from the top
47 /// left corner of the framebuffer.
48 ///
50 const std::optional<Rect>& current_clip_coverage) const;
51
52 bool Render(const ContentContext& renderer,
53 RenderPass& pass,
54 uint32_t clip_depth) const;
55
56 private:
57 // Pre-tessellated clip geometry.
58 GeometryResult clip_geometry_;
59 // Coverage rect of the tessellated geometry.
60 Rect coverage_rect_;
61 bool is_axis_aligned_rect_ = false;
63};
64
65/// @brief Render a restore clip.
66///
67/// This is is intended to be used for prevent overdraw mechanism. The clip
68/// depth should be the depth of the entity that is currently being drawn, and
69/// restore_coverage should be its coverage. If restore_coverage is
70/// std::nullopt, the render pass coverage is used instead.
71bool RenderClipRestore(const ContentContext& renderer,
72 RenderPass& pass,
73 uint32_t clip_depth,
74 std::optional<Rect> restore_coverage);
75
76} // namespace impeller
77
78#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_CLIP_CONTENTS_H_
void SetGeometry(GeometryResult geometry)
Set the pre-tessellated clip geometry.
ClipCoverage GetClipCoverage(const std::optional< Rect > &current_clip_coverage) const
Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage...
void SetClipOperation(Entity::ClipOperation clip_op)
bool Render(const ContentContext &renderer, RenderPass &pass, uint32_t clip_depth) const
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:30
bool RenderClipRestore(const ContentContext &renderer, RenderPass &pass, uint32_t clip_depth, std::optional< Rect > restore_coverage)
Render a restore clip.
std::optional< Rect > coverage
This coverage is the outer coverage of the clip.