-
Notifications
You must be signed in to change notification settings - Fork 6k
Image.toByteData and Picture.toImage implementations (#2) #20326
Conversation
Implement toByteData()
Implement toByteData()
Null-aware.
Sk* to Ck*
Null-aware
Type arguments
Same for CkAnimatedImage
Implement toByteData()
Implement toByteData()
external bool isEmpty(); | ||
external bool isOpaque(); | ||
external SkRect bounds(); | ||
external int width(); |
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.
These should be getters I imagine. However, getters don't need the ()
, for example external bool get isEmpty;
(notice no ()
at the end).
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 any more. The doc I finally found explicitely says they are functions, using ().
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.
Hmm. Interesting. According to the @JS
bindings it's a plain object (in JS you'd write { width: x, height: y, aphaType: z, colorSpace: a, colorType: b }
). Perhaps there's a difference between SkImageInfo
constructed by JS and one returned by CanvasKit?
Why don't you do what works now, and we can clean this up later?
/cc @kjlubick
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.
According to CanvasKit bindings it should be a POJO: https://github.com/google/skia/blob/1d4b92d87806e0d3ed8b4155da98d7d0ac757bd6/modules/canvaskit/canvaskit_bindings.cpp#L1873
That is, there shouldn't be any methods/functions on SkImageInfo
, only properties.
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.
That is correct, the SkImageInfo is just a POJO
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.
OK, I do, I do.
.build() | ||
.webOnlyRootElement); | ||
|
||
await matchGoldenFile('canvas_to_picture.png', region: region, write: true); |
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.
For this to pass on CI you'll need to remove write: true
. However, you will also need to add the new screenshot file to https://github.com/flutter/goldens (example PR: flutter/goldens#103).
If that's too much ceremony, feel free to comment out this line in this PR, and I can do the dance with the screenshots in a follow up PR.
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 simply can't get the screenshot. The test doesn't run on either Windows or Linux for me locally (on Windows by design, on Linux it should work but it doesn't, Chrome starts and then nothing ever happens).
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.
Commenting out renders the test inactive. If it's OK like this, let's do so.
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.
Filed flutter/flutter#63711 to follow up later.
Same error with Linux Web Engine. I can't find any reference to color spaces in that log. |
@deakjahn Sorry, I renamed the It looks like this PR is almost good to go. The only remaining issue is an unused import. |
An import? Did I add it? Which one? I don't remember needing to add any import at all but that doesn't mean a thing. :-) Never mind, I could have read before I speak... |
You made me comment out the image comparison test at the end but this means that the test itself times out, doesn't it? |
I'm not sure. Would you be able to squash this PR into a single commit so I could try it on my computer? I tried rebasing this PR on top of latest master branch but my |
That's the problem over here, too, I never did anything similar in git. Time to start to read up, I guess. |
I can't even squash two, let alone 70-plus... :-( |
I have a suggestion that might help us. It's only six files, after all. So, if
that might fly, I guess. |
That plan SGTM. I'm wondering if Github allows downloading a PR as a patch file that could be applied locally as a single commit 🤔 |
It would if I squashed it into one. But then there would be no need... |
Description
Image.toByteData()
was not implemented in either DomCanvas or CanvasKit. This PR covers both.Picture.toImage()
was not implemented in either DomCanvas or CanvasKit. This PR covers CanvasKit (I also have a solution for DomCanvas but that would need some discussion, it might clash with functionality somewhere else; details in a comment below).Related Issues
Picture.toImage
,Scene.toImage
in CanvasKit flutter#42767Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.