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

Conversation

@knopp
Copy link
Member

@knopp knopp commented Aug 22, 2022

Fixes flutter/flutter#110002

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • X ] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard

This comment was marked as outdated.

canvas.save();
// Make sure raster cache doesn't bleed to physical pixels outside of original
// bounds. https://github.com/flutter/flutter/issues/110002
canvas.clipRect(SkRect::Make(bounds.roundOut()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a clip here is going to be expensive in aggregate, especially if it is only needed for low DPR devices. Is there another way to do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The clip is hard edge on pixel boundaries. Is it that expensive? Not sure what you mean by low DPR. The example shows artifacts on 2x iPhone, but I'd assume it will happen on 3x device as well.

I think we might be able to determine situation where the bleeding can't happen i.e. (bounds.fLeft + imageWidth) <= ceil(bounds.fRight)

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 changed the code to only clip if raster image actually exceeds original pixel boundaries. This should remove the clip in vast majority of cases. Still working on tests for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another possible approach would be to shrink the src and destination rect for the drawImage by replacing it with drawImageRect. lets consider that if we land this and performance degrades, but otherwise a simple check should be good.

@knopp knopp force-pushed the raster_cache_bleeding branch from bd9dd2a to 2644346 Compare August 22, 2022 15:34
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@knopp knopp merged commit 9513c34 into flutter:main Aug 22, 2022
@knopp knopp deleted the raster_cache_bleeding branch August 22, 2022 17:23
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raster cache bleeding to adjacent pixels

2 participants