Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
entity_pass_clip_stack.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_ENTITY_PASS_CLIP_STACK_H_
6#define FLUTTER_IMPELLER_ENTITY_ENTITY_PASS_CLIP_STACK_H_
7
11
12namespace impeller {
13
15 std::optional<Rect> coverage;
16 size_t clip_height = 0;
17};
18
19/// @brief A class that tracks all clips that have been recorded in the current
20/// entity pass stencil.
21///
22/// These clips are replayed when restoring the backdrop so that the
23/// stencil buffer is left in an identical state.
25 public:
26 struct ReplayResult {
28 std::optional<Rect> clip_coverage;
29 };
30
32 /// Whether or not the Entity should be rendered. If false, the Entity may
33 /// be safely skipped.
34 bool should_render = false;
35 /// Whether or not the current clip coverage changed during the call to
36 /// `ApplyClipState`.
37 bool clip_did_change = false;
38 };
39
40 /// Create a new [EntityPassClipStack] with an initialized coverage rect.
41 explicit EntityPassClipStack(const Rect& initial_coverage_rect);
42
44
45 std::optional<Rect> CurrentClipCoverage() const;
46
47 void PushSubpass(std::optional<Rect> subpass_coverage, size_t clip_height);
48
49 void PopSubpass();
50
51 bool HasCoverage() const;
52
53 /// @brief Applies the current clip state to an Entity. If the given Entity
54 /// is a clip operation, then the clip state is updated accordingly.
56 Entity& entity,
57 size_t clip_height_floor,
58 Point global_pass_position);
59
60 // Visible for testing.
61 void RecordEntity(const Entity& entity,
63 std::optional<Rect> clip_coverage);
64
65 // Visible for testing.
66 const std::vector<ReplayResult>& GetReplayEntities() const;
67
68 // Visible for testing.
69 const std::vector<ClipCoverageLayer> GetClipCoverageLayers() const;
70
71 private:
72 struct SubpassState {
73 std::vector<ReplayResult> rendered_clip_entities;
74 std::vector<ClipCoverageLayer> clip_coverage;
75 };
76
77 SubpassState& GetCurrentSubpassState();
78
79 std::vector<SubpassState> subpass_state_;
80};
81
82} // namespace impeller
83
84#endif // FLUTTER_IMPELLER_ENTITY_ENTITY_PASS_CLIP_STACK_H_
A class that tracks all clips that have been recorded in the current entity pass stencil.
std::optional< Rect > CurrentClipCoverage() const
void PushSubpass(std::optional< Rect > subpass_coverage, size_t clip_height)
const std::vector< ReplayResult > & GetReplayEntities() const
ClipStateResult ApplyClipState(Contents::ClipCoverage global_clip_coverage, Entity &entity, size_t clip_height_floor, Point global_pass_position)
Applies the current clip state to an Entity. If the given Entity is a clip operation,...
const std::vector< ClipCoverageLayer > GetClipCoverageLayers() const
void RecordEntity(const Entity &entity, Contents::ClipCoverage::Type type, std::optional< Rect > clip_coverage)