Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Dec 3, 2022

Make ColorFilterLayer accept an offset so the framework can make the RO a repaint boundary.

See also: flutter/flutter#101941

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Dec 3, 2022
@skia-gold
Copy link

Gold has detected about 72 new digest(s) on patchset 2.
View them at https://flutter-engine-gold.skia.org/cl/github/38055

@skia-gold
Copy link

Gold has detected about 37 new digest(s) on patchset 3.
View them at https://flutter-engine-gold.skia.org/cl/github/38055

@jonahwilliams jonahwilliams marked this pull request as ready for review December 13, 2022 18:45
@jonahwilliams jonahwilliams requested a review from flar December 13, 2022 21:35
void ColorFilterLayer::Preroll(PrerollContext* context) {
auto mutator = context->state_stack.save();
mutator.translate(offset_);

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to adjust the paint bounds accordingly. The paint_bounds are measured in the parent coordinate system (which used to be a transform layer so it would be the agent applying the offset to the child's bounds to create its own bounds). But now that this layer is doing its own translation, it needs to adjust the bounds it reports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, but I noticed that there is a difference in how the image filter layer and this layer behave w.r.t child bounds transformation. I assume that is because matrix filters or blur can increase the size of things beyond the offseT?

Copy link
Contributor

Choose a reason for hiding this comment

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

The bounds should always be offset because the translation is always applied in Paint. There is a bug in image_filter_layer in that it doesn't offset the bounds if there is no filter. Do not replicate that bug here the way you have - and fix IFL while you're at it if you please.

The bounds need to match what is rendered (modulo we haven't been replicating the integral transform code into the layer Preroll methods, which has been a topic of discussion with @knopp as we migrate Diff to use the LayerStateStack).

But, this offset is always applied in Paint and should always be applied to the paint bounds in both CFL and IFL.

@jonahwilliams jonahwilliams requested a review from flar December 14, 2022 00:09
void ColorFilterLayer::Preroll(PrerollContext* context) {
auto mutator = context->state_stack.save();
mutator.translate(offset_);

Copy link
Contributor

Choose a reason for hiding this comment

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

The bounds should always be offset because the translation is always applied in Paint. There is a bug in image_filter_layer in that it doesn't offset the bounds if there is no filter. Do not replicate that bug here the way you have - and fix IFL while you're at it if you please.

The bounds need to match what is rendered (modulo we haven't been replicating the integral transform code into the layer Preroll methods, which has been a topic of discussion with @knopp as we migrate Diff to use the LayerStateStack).

But, this offset is always applied in Paint and should always be applied to the paint bounds in both CFL and IFL.

@jonahwilliams
Copy link
Contributor Author

I've updated both image and color filter layers to always apply the offset in preroll and added unit tests for both cases, PTAL

@jonahwilliams jonahwilliams requested a review from flar January 4, 2023 17:45
Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

A minor fix and then we should work with the IFL PR below to make sure we manage translation during caching correctly. I only skimmed a couple of the files on this pass pending those eventual changes.

: 0;
} else {
// else - we can apply whatever our children can apply.
set_paint_bounds(child_bounds);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is not conditional, why is it applied in both halves of the if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

FML_DCHECK(needs_painting(context));

auto mutator = context.state_stack.save();
mutator.translate(offset_);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a bug in IFL that we are currently fixing where this line here causes the offset to be applied doubly when caching children. See #38567 on our discussion about how the interplay of offset/integralTransform/caching should play out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I leave this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it sounds like from reading the issue this change here would introduce a raster caching bug. I'll put this on hold until 38567 has a solution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants