Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Conversation

@bdero
Copy link
Member

@bdero bdero commented Feb 17, 2022

Fixes flutter/flutter#98631.

Restoration works with a single draw call:

  • When clip paths are added, they increase the stencil height only if the stencil matches the current depth. So higher depths are always a subset of lower depths.
  • When popping the canvas stack, an entity is appended to run a draw call which max bounds the stencil to the previous depth.

@bdero bdero force-pushed the bdero/nested-clips branch from 4ef07bf to 4d9171b Compare February 17, 2022 13:59
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks! There is a drive by comment about a separate optimization but please do not rework this patch to account for that API issue. We'll fix it separately.

// Clip restoration pipeline.
{
auto clip_pipeline_descriptor =
clip_pipelines_[{}]->WaitAndGet()->GetDescriptor();
Copy link
Member

Choose a reason for hiding this comment

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

Just a drive by comment that you absolutely should not account for here because the right™ fix is account for the issue with having to wait for a pipeline future just to get its descriptor it to rework pipeline futures.

A restore pipeline is a variant of the clip pipeline which is a variant of the solid fill pipeline. And you have already awaited for the fill pipeline so you already have the descriptor. You could reuse that descriptor directly instead of awaiting the full initialization of the clip pipeline to prepare the restore variant.

Either way though, this is correct and an issue with the API forcing an await for a descriptor when it should only do so for the actual pipeline itself.

Copy link
Member

Choose a reason for hiding this comment

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

Consider filing an issue and writing a TODO for follow-up work.

Copy link
Member

Choose a reason for hiding this comment

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

Wilco.

Copy link
Member

Choose a reason for hiding this comment

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

I filed flutter/flutter#98684 specifically for this issue. Backfilling the issues in the bug tracker now (adding the impeller label). Will update the TODOs to reference the bugs once all issues are filed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yup, makes sense and sgtm. I added a TODO referencing that issue nearby.

void Canvas::RestoreClip() {
Entity entity;
entity.SetTransformation(GetCurrentTransformation());
entity.SetPath({});
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here that the the path is empty because it clear the entire render target? Just for clarity.

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.

@bdero bdero merged commit 0142859 into flutter:main Feb 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impeller: Fix nested clipping in Aiks

3 participants