13 subpass_state_.push_back(SubpassState{
25 return subpass_state_.back().clip_coverage.back().coverage;
29 return !subpass_state_.back().clip_coverage.empty();
34 subpass_state_.push_back(SubpassState{
38 .clip_height = clip_height},
44 subpass_state_.pop_back();
47const std::vector<ClipCoverageLayer>
49 return subpass_state_.back().clip_coverage;
55 size_t clip_height_floor,
56 Point global_pass_position) {
59 auto& subpass_state = GetCurrentSubpassState();
60 switch (global_clip_coverage.
type) {
67 size_t previous_clip_height = 0;
68 if (!subpass_state.clip_coverage.empty()) {
69 previous_clip_height = subpass_state.clip_coverage.back().clip_height;
73 previous_clip_height = clip_height_floor;
76 subpass_state.clip_coverage.push_back(
78 .clip_height = previous_clip_height + 1});
79 result.clip_did_change =
true;
81 FML_DCHECK(subpass_state.clip_coverage.back().clip_height ==
82 subpass_state.clip_coverage.front().clip_height +
83 subpass_state.clip_coverage.size() - 1);
85 if (!op.has_value()) {
96 if (subpass_state.clip_coverage.back().clip_height <= restore_height) {
101 auto restoration_index =
102 restore_height - subpass_state.clip_coverage.front().clip_height;
103 FML_DCHECK(restoration_index < subpass_state.clip_coverage.size());
107 std::optional<Rect> restore_coverage =
108 (restoration_index + 1 < subpass_state.clip_coverage.size())
109 ? subpass_state.clip_coverage[restoration_index + 1].coverage
111 if (restore_coverage.has_value()) {
113 restore_coverage = restore_coverage->Shift(-global_pass_position);
115 subpass_state.clip_coverage.resize(restoration_index + 1);
116 result.clip_did_change =
true;
119 if (subpass_state.clip_coverage.back().coverage.has_value()) {
128 subpass_state.clip_coverage.back().coverage);
130 result.should_render =
true;
136 std::optional<Rect> clip_coverage) {
137 auto& subpass_state = GetCurrentSubpassState();
142 subpass_state.rendered_clip_entities.push_back(
143 {.entity = entity.
Clone(), .clip_coverage = clip_coverage});
146 if (!subpass_state.rendered_clip_entities.empty()) {
147 subpass_state.rendered_clip_entities.pop_back();
153EntityPassClipStack::SubpassState&
154EntityPassClipStack::GetCurrentSubpassState() {
155 return subpass_state_.back();
158const std::vector<EntityPassClipStack::ReplayResult>&
160 return subpass_state_.back().rendered_clip_entities;
size_t GetRestoreHeight() const
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,...
EntityPassClipStack(const Rect &initial_coverage_rect)
Create a new [EntityPassClipStack] with an initialized coverage rect.
const std::vector< ClipCoverageLayer > GetClipCoverageLayers() const
void RecordEntity(const Entity &entity, Contents::ClipCoverage::Type type, std::optional< Rect > clip_coverage)
const std::shared_ptr< Contents > & GetContents() const
#define FML_DCHECK(condition)
std::optional< Rect > coverage
std::optional< Rect > coverage