Ensure raster cache doesn't bleed over to adjacent physical pixels#35602
Ensure raster cache doesn't bleed over to adjacent physical pixels#35602knopp merged 6 commits intoflutter:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
flow/raster_cache.cc
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())); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bd9dd2a to
2644346
Compare
Fixes flutter/flutter#110002
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.