Fix bug where using transform with image data results in twice-transformed clip path #273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was wondering why I was getting different results when downscaling my canvas. It took me a while to isolate that the issue required both clipping and image data. Here's a PoC (now a visual test):
This was blank with skia-canvas but draws a square with canvas.
It occurs since setting image data restores to save count 1, and then
set_matrixduringContext2D::popoverwrites the matrix at save count 1. When the clip path is loaded again withset_clip, it has already been transformed and undergoes the same transform again at save count 1.The Skia docs note that
restoreToCountbut the former behavior takes precedence (I think / apparently), so the matrix isn't reset during
PageRecorder::restore.I simplified things so both
set_matrixandset_clipcall restore (though this could be split up again if there are other concerns like performance).PageRecorder::restorecalls save after restoring to save count 1, so it maintains the invariant that save count 1 has no clip path and the identity matrix, whichset_matrixpreviously violated.