[Impeller] Remove old clip height tracking from Entity. (#52178)
And rename clip depth accessors and members.
After this, I'm going to attempt to remove the need for tracking clip
height altogether in EntityPass as well.
diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc
index 3613191..fc0863f 100644
--- a/impeller/aiks/aiks_unittests.cc
+++ b/impeller/aiks/aiks_unittests.cc
@@ -2959,10 +2959,10 @@
picture.pass->IterateAllElements([&](EntityPass::Element& element) -> bool {
if (auto* subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
- actual.push_back(subpass->get()->GetNewClipDepth());
+ actual.push_back(subpass->get()->GetClipDepth());
}
if (Entity* entity = std::get_if<Entity>(&element)) {
- actual.push_back(entity->GetNewClipDepth());
+ actual.push_back(entity->GetClipDepth());
}
return true;
});
diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc
index 94c8d01..dfeebb3 100644
--- a/impeller/aiks/canvas.cc
+++ b/impeller/aiks/canvas.cc
@@ -163,7 +163,7 @@
void Canvas::Initialize(std::optional<Rect> cull_rect) {
initial_cull_rect_ = cull_rect;
base_pass_ = std::make_unique<EntityPass>();
- base_pass_->SetNewClipDepth(++current_depth_);
+ base_pass_->SetClipDepth(++current_depth_);
current_pass_ = base_pass_.get();
transform_stack_.emplace_back(CanvasStackEntry{.cull_rect = cull_rect});
FML_DCHECK(GetSaveCount() == 1u);
@@ -244,7 +244,7 @@
subpass->SetBlendMode(blend_mode);
current_pass_ = GetCurrentPass().AddSubpass(std::move(subpass));
current_pass_->SetTransform(transform_stack_.back().transform);
- current_pass_->SetClipDepth(transform_stack_.back().clip_height);
+ current_pass_->SetClipHeight(transform_stack_.back().clip_height);
}
transform_stack_.emplace_back(entry);
}
@@ -259,7 +259,7 @@
if (transform_stack_.back().rendering_mode ==
Entity::RenderingMode::kSubpass) {
- current_pass_->SetNewClipDepth(++current_depth_);
+ current_pass_->SetClipDepth(++current_depth_);
current_pass_ = GetCurrentPass().GetSuperpass();
FML_DCHECK(current_pass_);
}
@@ -336,7 +336,6 @@
void Canvas::DrawPath(const Path& path, const Paint& paint) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(CreatePathContentsWithFilters(paint, path));
@@ -346,7 +345,6 @@
void Canvas::DrawPaint(const Paint& paint) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(CreateCoverContentsWithFilters(paint));
@@ -427,7 +425,6 @@
Entity blurred_rrect_entity;
blurred_rrect_entity.SetTransform(GetCurrentTransform());
- blurred_rrect_entity.SetClipDepth(GetClipHeight());
blurred_rrect_entity.SetBlendMode(rrect_paint.blend_mode);
rrect_paint.mask_blur_descriptor = std::nullopt;
@@ -447,7 +444,6 @@
// Then, draw the non-blurred RRect on top.
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(rrect_paint.blend_mode);
entity.SetContents(CreateContentsForGeometryWithFilters(
rrect_paint, Geometry::MakeRoundRect(rect, corner_radii)));
@@ -474,7 +470,6 @@
void Canvas::DrawLine(const Point& p0, const Point& p1, const Paint& paint) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(CreateContentsForGeometryWithFilters(
paint, Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap)));
@@ -494,7 +489,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(
CreateContentsForGeometryWithFilters(paint, Geometry::MakeRect(rect)));
@@ -521,7 +515,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(
CreateContentsForGeometryWithFilters(paint, Geometry::MakeOval(rect)));
@@ -539,7 +532,6 @@
if (paint.style == Paint::Style::kFill) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(CreateContentsForGeometryWithFilters(
paint, Geometry::MakeRoundRect(rect, corner_radii)));
@@ -568,7 +560,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
auto geometry =
paint.style == Paint::Style::kStroke
@@ -680,7 +671,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
entity.SetContents(std::move(contents));
- entity.SetClipDepth(GetClipHeight());
GetCurrentPass().PushClip(std::move(entity));
@@ -735,7 +725,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(CreateContentsForGeometryWithFilters(
paint,
@@ -791,7 +780,6 @@
Entity entity;
entity.SetBlendMode(paint.blend_mode);
- entity.SetClipDepth(GetClipHeight());
entity.SetContents(paint.WithFilters(contents));
entity.SetTransform(GetCurrentTransform());
@@ -824,7 +812,7 @@
}
void Canvas::AddEntityToCurrentPass(Entity entity) {
- entity.SetNewClipDepth(++current_depth_);
+ entity.SetClipDepth(++current_depth_);
GetCurrentPass().AddEntity(std::move(entity));
}
@@ -867,7 +855,6 @@
Point position,
const Paint& paint) {
Entity entity;
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
auto text_contents = std::make_shared<TextContents>();
@@ -919,7 +906,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
// If there are no vertex color or texture coordinates. Or if there
@@ -1012,7 +998,6 @@
Entity entity;
entity.SetTransform(GetCurrentTransform());
- entity.SetClipDepth(GetClipHeight());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(contents));
diff --git a/impeller/entity/contents/clip_contents.cc b/impeller/entity/contents/clip_contents.cc
index e38e73c..966070b 100644
--- a/impeller/entity/contents/clip_contents.cc
+++ b/impeller/entity/contents/clip_contents.cc
@@ -19,8 +19,8 @@
// Draw the clip at the max of the clip entity's depth slice, so that other
// draw calls with this same depth value will be culled even if they have a
// perspective transform.
- return std::nextafterf(
- Entity::GetShaderClipDepth(entity.GetNewClipDepth() + 1), 0.0f);
+ return std::nextafterf(Entity::GetShaderClipDepth(entity.GetClipDepth() + 1),
+ 0.0f);
}
/*******************************************************************************
diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc
index 4db4270..46cfab8 100644
--- a/impeller/entity/contents/filters/filter_contents.cc
+++ b/impeller/entity/contents/filters/filter_contents.cc
@@ -144,7 +144,7 @@
if (!maybe_entity.has_value()) {
return true;
}
- maybe_entity->SetNewClipDepth(entity.GetNewClipDepth());
+ maybe_entity->SetClipDepth(entity.GetClipDepth());
return maybe_entity->Render(renderer, pass);
}
diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
index 0840679..3d32423 100644
--- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
+++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
@@ -226,10 +226,10 @@
blur_transform](const ContentContext& renderer, const Entity& entity,
RenderPass& pass) mutable {
bool result = true;
- clipper.SetNewClipDepth(entity.GetNewClipDepth());
+ clipper.SetClipDepth(entity.GetClipDepth());
clipper.SetTransform(entity.GetTransform() * entity_transform);
result = clipper.Render(renderer, pass) && result;
- blur_entity.SetNewClipDepth(entity.GetNewClipDepth());
+ blur_entity.SetClipDepth(entity.GetClipDepth());
blur_entity.SetTransform(entity.GetTransform() * blur_transform);
result = blur_entity.Render(renderer, pass) && result;
return result;
@@ -277,12 +277,12 @@
const Entity& entity,
RenderPass& pass) mutable {
bool result = true;
- blur_entity.SetNewClipDepth(entity.GetNewClipDepth());
+ blur_entity.SetClipDepth(entity.GetClipDepth());
blur_entity.SetTransform(entity.GetTransform() * blurred_transform);
result = result && blur_entity.Render(renderer, pass);
snapshot_entity.SetTransform(entity.GetTransform() *
snapshot_transform);
- snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth());
+ snapshot_entity.SetClipDepth(entity.GetClipDepth());
result = result && snapshot_entity.Render(renderer, pass);
return result;
}),
diff --git a/impeller/entity/entity.cc b/impeller/entity/entity.cc
index add9806..9111a61 100644
--- a/impeller/entity/entity.cc
+++ b/impeller/entity/entity.cc
@@ -103,16 +103,8 @@
return clip_depth_;
}
-void Entity::SetNewClipDepth(uint32_t clip_depth) {
- new_clip_depth_ = clip_depth;
-}
-
-uint32_t Entity::GetNewClipDepth() const {
- return new_clip_depth_;
-}
-
Scalar Entity::GetShaderClipDepth() const {
- return Entity::GetShaderClipDepth(new_clip_depth_);
+ return Entity::GetShaderClipDepth(clip_depth_);
}
Scalar Entity::GetShaderClipDepth(uint32_t clip_depth) {
@@ -120,10 +112,6 @@
return std::min(result, 1.0f - kDepthEpsilon);
}
-void Entity::IncrementStencilDepth(uint32_t increment) {
- clip_depth_ += increment;
-}
-
void Entity::SetBlendMode(BlendMode blend_mode) {
blend_mode_ = blend_mode;
}
diff --git a/impeller/entity/entity.h b/impeller/entity/entity.h
index 27e7484..d2d4eb9 100644
--- a/impeller/entity/entity.h
+++ b/impeller/entity/entity.h
@@ -101,14 +101,8 @@
void SetClipDepth(uint32_t clip_depth);
- void IncrementStencilDepth(uint32_t increment);
-
uint32_t GetClipDepth() const;
- void SetNewClipDepth(uint32_t clip_depth);
-
- uint32_t GetNewClipDepth() const;
-
float GetShaderClipDepth() const;
static float GetShaderClipDepth(uint32_t clip_depth);
@@ -141,8 +135,7 @@
Matrix transform_;
std::shared_ptr<Contents> contents_;
BlendMode blend_mode_ = BlendMode::kSourceOver;
- uint32_t clip_depth_ = 0u;
- uint32_t new_clip_depth_ = 1u;
+ uint32_t clip_depth_ = 1u;
mutable Capture capture_;
};
diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc
index 89a2d90..f16a92e 100644
--- a/impeller/entity/entity_pass.cc
+++ b/impeller/entity/entity_pass.cc
@@ -133,7 +133,7 @@
FML_DCHECK(active_clips_.back() < elements_.size());
Entity* element = std::get_if<Entity>(&elements_[active_clips_.back()]);
FML_DCHECK(element);
- element->SetNewClipDepth(depth);
+ element->SetClipDepth(depth);
active_clips_.pop_back();
}
}
@@ -592,7 +592,7 @@
Point(), // local_pass_position
pass_depth, // pass_depth
clip_coverage_stack, // clip_coverage_stack
- clip_depth_, // clip_height_floor
+ clip_height_, // clip_height_floor
nullptr, // backdrop_filter_contents
pass_context.GetRenderPass(pass_depth) // collapsed_parent_pass
)) {
@@ -691,7 +691,7 @@
// save layers may transform the subpass texture after it's rendered,
// causing parent clip coverage to get misaligned with the actual area that
// the subpass will affect in the parent pass.
- clip_coverage_stack.PushSubpass(subpass_coverage, subpass->clip_depth_);
+ clip_coverage_stack.PushSubpass(subpass_coverage, subpass->clip_height_);
// Stencil textures aren't shared between EntityPasses (as much of the
// time they are transient).
@@ -705,7 +705,7 @@
global_pass_position, // local_pass_position
++pass_depth, // pass_depth
clip_coverage_stack, // clip_coverage_stack
- subpass->clip_depth_, // clip_height_floor
+ subpass->clip_height_, // clip_height_floor
subpass_backdrop_filter_contents // backdrop_filter_contents
)) {
// Validation error messages are triggered for all `OnRender()` failure
@@ -739,10 +739,9 @@
Entity element_entity;
Capture subpass_texture_capture =
capture.CreateChild("Entity (Subpass texture)");
- element_entity.SetNewClipDepth(subpass->new_clip_depth_);
+ element_entity.SetClipDepth(subpass->clip_depth_);
element_entity.SetCapture(subpass_texture_capture);
element_entity.SetContents(std::move(offscreen_texture_contents));
- element_entity.SetClipDepth(subpass->clip_depth_);
element_entity.SetBlendMode(subpass->blend_mode_);
element_entity.SetTransform(subpass_texture_capture.AddMatrix(
"Transform",
@@ -801,7 +800,7 @@
Entity msaa_backdrop_entity;
msaa_backdrop_entity.SetContents(std::move(msaa_backdrop_contents));
msaa_backdrop_entity.SetBlendMode(BlendMode::kSource);
- msaa_backdrop_entity.SetNewClipDepth(std::numeric_limits<uint32_t>::max());
+ msaa_backdrop_entity.SetClipDepth(std::numeric_limits<uint32_t>::max());
if (!msaa_backdrop_entity.Render(renderer, *result.pass)) {
VALIDATION_LOG << "Failed to render MSAA backdrop filter entity.";
return false;
@@ -919,8 +918,7 @@
backdrop_entity.SetContents(std::move(backdrop_filter_contents));
backdrop_entity.SetTransform(
Matrix::MakeTranslation(Vector3(-local_pass_position)));
- backdrop_entity.SetClipDepth(clip_height_floor);
- backdrop_entity.SetNewClipDepth(std::numeric_limits<uint32_t>::max());
+ backdrop_entity.SetClipDepth(std::numeric_limits<uint32_t>::max());
RenderElement(backdrop_entity, clip_height_floor, pass_context, pass_depth,
renderer, clip_coverage_stack, global_pass_position);
@@ -1156,22 +1154,22 @@
transform_ = transform;
}
+void EntityPass::SetClipHeight(size_t clip_height) {
+ clip_height_ = clip_height;
+}
+
+size_t EntityPass::GetClipHeight() const {
+ return clip_height_;
+}
+
void EntityPass::SetClipDepth(size_t clip_depth) {
clip_depth_ = clip_depth;
}
-size_t EntityPass::GetClipDepth() const {
+uint32_t EntityPass::GetClipDepth() const {
return clip_depth_;
}
-void EntityPass::SetNewClipDepth(size_t clip_depth) {
- new_clip_depth_ = clip_depth;
-}
-
-uint32_t EntityPass::GetNewClipDepth() const {
- return new_clip_depth_;
-}
-
void EntityPass::SetBlendMode(BlendMode blend_mode) {
blend_mode_ = blend_mode;
flood_clip_ = Entity::IsBlendModeDestructive(blend_mode);
diff --git a/impeller/entity/entity_pass.h b/impeller/entity/entity_pass.h
index 555921b..72c22e7 100644
--- a/impeller/entity/entity_pass.h
+++ b/impeller/entity/entity_pass.h
@@ -161,13 +161,13 @@
void SetTransform(Matrix transform);
+ void SetClipHeight(size_t clip_height);
+
+ size_t GetClipHeight() const;
+
void SetClipDepth(size_t clip_depth);
- size_t GetClipDepth() const;
-
- void SetNewClipDepth(size_t clip_depth);
-
- uint32_t GetNewClipDepth() const;
+ uint32_t GetClipDepth() const;
void SetBlendMode(BlendMode blend_mode);
@@ -337,8 +337,8 @@
EntityPass* superpass_ = nullptr;
Matrix transform_;
- size_t clip_depth_ = 0u;
- uint32_t new_clip_depth_ = 1u;
+ size_t clip_height_ = 0u;
+ uint32_t clip_depth_ = 1u;
BlendMode blend_mode_ = BlendMode::kSourceOver;
bool flood_clip_ = false;
bool enable_offscreen_debug_checkerboard_ = false;
diff --git a/impeller/entity/entity_pass_clip_stack.cc b/impeller/entity/entity_pass_clip_stack.cc
index 94fe9b7..68dcf22 100644
--- a/impeller/entity/entity_pass_clip_stack.cc
+++ b/impeller/entity/entity_pass_clip_stack.cc
@@ -103,7 +103,7 @@
FML_DCHECK(restoration_index < subpass_state.clip_coverage.size());
// We only need to restore the area that covers the coverage of the
- // clip rect at target depth + 1.
+ // clip rect at target height + 1.
std::optional<Rect> restore_coverage =
(restoration_index + 1 < subpass_state.clip_coverage.size())
? subpass_state.clip_coverage[restoration_index + 1].coverage
diff --git a/impeller/entity/entity_pass_unittests.cc b/impeller/entity/entity_pass_unittests.cc
index b2897ed..fd25599 100644
--- a/impeller/entity/entity_pass_unittests.cc
+++ b/impeller/entity/entity_pass_unittests.cc
@@ -97,7 +97,6 @@
// Push a clip.
Entity entity;
- entity.SetClipDepth(0);
EntityPassClipStack::ClipStateResult result = recorder.ApplyClipState(
Contents::ClipCoverage{
.type = Contents::ClipCoverage::Type::kAppend,
@@ -166,7 +165,6 @@
// Push a clip.
Entity entity;
- entity.SetClipDepth(0u);
{
EntityPassClipStack::ClipStateResult result = recorder.ApplyClipState(
Contents::ClipCoverage{
@@ -190,7 +188,6 @@
EXPECT_EQ(recorder.GetClipCoverageLayers()[0].coverage,
Rect::MakeLTRB(50, 50, 55, 55));
- entity.SetClipDepth(1);
{
EntityPassClipStack::ClipStateResult result = recorder.ApplyClipState(
Contents::ClipCoverage{