Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Use the scissor to limit all draws by clip coverage. #51698

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Jonah review
  • Loading branch information
bdero committed Mar 27, 2024
commit 64ae64ddaf75e164022da4c6ff636d8e5a5932ac
7 changes: 3 additions & 4 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,8 @@ static void SetClipScissor(std::optional<Rect> clip_coverage,
IRect scissor;
if (clip_coverage.has_value()) {
clip_coverage = clip_coverage->Shift(-global_pass_position);
scissor = IRect::MakeLTRB(std::floor(clip_coverage->GetLeft()),
std::floor(clip_coverage->GetTop()),
std::ceil(clip_coverage->GetRight()),
std::ceil(clip_coverage->GetBottom()));
scissor = IRect::RoundOut(clip_coverage.value());
// The scissor rect must not exceed the size of the render target.
scissor = scissor.Intersection(IRect::MakeSize(pass.GetRenderTargetSize()))
.value_or(IRect());
}
Expand Down Expand Up @@ -856,6 +854,7 @@ bool EntityPass::RenderElement(Entity& element_entity,
global_pass_position);

if (clip_state_result.clip_did_change) {
// We only need to update the pass scissor if the clip state has changed.
SetClipScissor(clip_coverage_stack.CurrentClipCoverage(), *result.pass,
global_pass_position);
}
Expand Down
4 changes: 4 additions & 0 deletions impeller/entity/entity_pass_clip_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class EntityPassClipStack {
};

struct ClipStateResult {
/// Whether or not the Entity should be rendered. If false, the Entity may
/// be safely skipped.
bool should_render = false;
/// Whether or not the current clip coverage changed during the call to
/// `ApplyClipState`.
bool clip_did_change = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should_render is sort of documemted on the method body, can you document what clip_did_change means?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

};

Expand Down