Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Prev Previous commit
Next Next commit
fixed tests and turned off hack
  • Loading branch information
gaaclarke committed Dec 19, 2023
commit f17e00acae37529e44fbb240b36c2c68d57c244d
2 changes: 0 additions & 2 deletions impeller/entity/contents/filters/filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ std::shared_ptr<FilterContents> FilterContents::MakeDirectionalGaussianBlur(
return blur;
}

#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1

std::shared_ptr<FilterContents> FilterContents::MakeGaussianBlur(
const FilterInput::Ref& input,
Sigma sigma_x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
Rect source_rect = Rect::MakeSize(input_snapshot->texture->GetSize());
Rect source_rect_padded = source_rect;
Matrix padding_snapshot_adjustment;
if (coverage_hint.has_value() && input_snapshot_coverage.has_value() &&
!input_snapshot_coverage->Contains(coverage_hint.value())) {
if (!coverage_hint.has_value() ||
(input_snapshot_coverage.has_value() &&
!input_snapshot_coverage->Contains(coverage_hint.value()))) {
Copy link
Member

Choose a reason for hiding this comment

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

A couple of things come to mind while thinking about this:

  1. Did you mean to compare against the expanded coverage hint instead? At the end of the downsample pass, we need to have enough content in the downsample pass to cover sampling from the entire expanded coverage area area for the full area of the expanded coverage hint.
  2. Should this check be flipped? Like if the expanded_coverage_hint is equal to or a subset of the input_snapshot_coverage, then I suppose that would indicate that the snapshot rendered content into a big enough square that we don't need to worry about creating more with the proper tiling mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, the input_snapshot_coverage is incorporating the expanded coverage hint.

This is basically saying: I requested an expanded_coverage_hint and the snapshot you gave me for that doesn't contain all of the area of the coverage_hint. Therefore, some part of the halo will be visible and we'll add padding.

Copy link
Member Author

Choose a reason for hiding this comment

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

Check out the test, that should make this clear. The coverage_hint is saying we are going to render a small portion of the image, so there is no need to add the halo gutter.

Copy link
Member

@bdero bdero Dec 20, 2023

Choose a reason for hiding this comment

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

Ah, I actually missed the not operator in front of the Contains check here.

I still think this isn't quite working for all cases. I made an interactive playground (will push a PR for it) to demonstrate an issue with Decal tiling:

Screen.Recording.2023-12-20.at.5.08.59.AM.mov

The color jumping is explained by flutter/flutter#140193 (comment) and isn't the focus of the video. The main problem is that the edge of the blurred image turns opaque when the clip becomes contained by the input snapshot coverage.

Copy link
Member

Choose a reason for hiding this comment

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

(Made a PR for the interactive toy here: #49283)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh right, the coverage_hint has to be inside of the snapshot image coverage while accounting for the blur radius. I'll fix that although I wonder if that will make this optimization hardly applicable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed the problem, but there is a jump in the rendering because of the downsampling issue. It also catches way less cases now because it isn't cutting off the padding when hitting the edge of the input. I'm going to keep all the refactors and land it as a refactor since I have PRs that depend on this. I can circle back.

I also ran into a fun Rect floating point bug =( flutter/flutter#140464

// This means that the snapshot does not contain all the data it needs to
// render, so we add extra padding for the blur halo to render.
// TODO(gaaclarke): This adds a gutter for the blur halo that is uniform,
Expand Down