-
Notifications
You must be signed in to change notification settings - Fork 6k
Draw images directly into the canvas when compositing for data purposes #36058
Draw images directly into the canvas when compositing for data purposes #36058
Conversation
yjbanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // element onto the canvas. | ||
| // TODO(jacksongardner): Make this actually work with color filters. | ||
| setUpPaint(paint, null); | ||
| _canvasPool.drawImage(imgElement as DomHTMLImageElement, p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we guarantee that this cast will succeed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why all these methods just pass around DomHTMLElement when they all are DomHTMLImageElement. I guess I could clean that up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, there is actually one case where it's a div.
|
Gold has detected about 1 new digest(s) on patchset 3. |
|
Gold has detected about 1 new digest(s) on patchset 4. |
|
Gold has detected about 1 new digest(s) on patchset 5. |
|
Gold has detected about 1 new digest(s) on patchset 6. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |

This fixes 110599
Previously, the
BitmapCanvaswould always insert DOM elements for images. However, this doesn't work if the user is using the canvas to composite data (i.e._preserveImageDatais set). Make it so that we draw images directly into the canvas if this is set.Also, if a data URL is requested from the canvas pool and we have no canvas, we have to create a canvas and create the data URL anyway, otherwise we end up with exceptions if the user hasn't actually drawn anything to the canvas.