[canvaskit] Detect animated WebP images#54418
Conversation
| /// Reads the header of a WebP file to determine if it is animated or not. | ||
| /// | ||
| /// See https://developers.google.com/speed/webp/docs/riff_container | ||
| class WebpHeaderReader { |
There was a problem hiding this comment.
Nit: I kinda like when these types of things are private, in their own library and just the functional thing as a top-level function bool isAnimated(bytes). With the class as private. One should only call isAnimated once, right?
There was a problem hiding this comment.
Done. isAnimated isn't even exposed outside the file. It's an implementation detail of detectImageType
| ImageType? expectedImageType; | ||
| final String testFileExtension = | ||
| testFile.substring(testFile.lastIndexOf('.') + 1); | ||
| switch (testFileExtension) { |
There was a problem hiding this comment.
might could use switch expression here?
There was a problem hiding this comment.
Nice! Didn't know about this in the language
| 'avif' => ImageType.avif, | ||
| 'bmp' => ImageType.bmp, | ||
| 'png' => ImageType.png, | ||
| String() => null, |
There was a problem hiding this comment.
or
| String() => null, | |
| _ => null, |
🤷
| final _WebpHeaderReader webpHeaderReader = | ||
| _WebpHeaderReader(data.buffer.asByteData()); | ||
| if (webpHeaderReader.isAnimated()) { |
There was a problem hiding this comment.
| final _WebpHeaderReader webpHeaderReader = | |
| _WebpHeaderReader(data.buffer.asByteData()); | |
| if (webpHeaderReader.isAnimated()) { | |
| if (_WebpHeaderReader(data.buffer.asByteData()).isAnimated()) { |
compromise?
There was a problem hiding this comment.
meh...not a biggy. I'm being picky
flutter/engine@ef820aa...0520889 2024-08-08 [email protected] [canvaskit] Detect animated WebP images (flutter/engine#54418) 2024-08-08 [email protected] Roll Dart SDK from 067c7cfcbc8c to ff0404c72fc5 (1 revision) (flutter/engine#54455) 2024-08-08 [email protected] [Impeller] move aiks text tests to DL. (flutter/engine#54293) 2024-08-08 [email protected] Roll Skia from 0c6dd1e6ff8e to 4cff580721cf (20 revisions) (flutter/engine#54454) 2024-08-08 [email protected] Add a precision to the fragment shader (flutter/engine#54109) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mdebbar
left a comment
There was a problem hiding this comment.
Sorry for the late review, but this LGTM too!
| bool _readWebpHeader() { | ||
| final String riffBytes = _readFourCC(); | ||
|
|
||
| // Read file size byte. |
There was a problem hiding this comment.
get out of here with your snark! 😜
…3132) flutter/engine@ef820aa...0520889 2024-08-08 [email protected] [canvaskit] Detect animated WebP images (flutter/engine#54418) 2024-08-08 [email protected] Roll Dart SDK from 067c7cfcbc8c to ff0404c72fc5 (1 revision) (flutter/engine#54455) 2024-08-08 [email protected] [Impeller] move aiks text tests to DL. (flutter/engine#54293) 2024-08-08 [email protected] Roll Skia from 0c6dd1e6ff8e to 4cff580721cf (20 revisions) (flutter/engine#54454) 2024-08-08 [email protected] Add a precision to the fragment shader (flutter/engine#54109) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…3132) flutter/engine@ef820aa...0520889 2024-08-08 [email protected] [canvaskit] Detect animated WebP images (flutter/engine#54418) 2024-08-08 [email protected] Roll Dart SDK from 067c7cfcbc8c to ff0404c72fc5 (1 revision) (flutter/engine#54455) 2024-08-08 [email protected] [Impeller] move aiks text tests to DL. (flutter/engine#54293) 2024-08-08 [email protected] Roll Skia from 0c6dd1e6ff8e to 4cff580721cf (20 revisions) (flutter/engine#54454) 2024-08-08 [email protected] Add a precision to the fragment shader (flutter/engine#54109) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Reads the WebP header to determine if the WebP image is animated or not. If it's not animated, we can use
<img>tag decoding for less jank.The WebP half of flutter/flutter#151911
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.