-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix CkBrowserImageDecoder conversion of images to ImageByteFormat.rawRgba and rawStraightRgba #52089
Fix CkBrowserImageDecoder conversion of images to ImageByteFormat.rawRgba and rawStraightRgba #52089
Conversation
…Rgba and rawStraightRgba VideoFrames of decoded images typically contain BGRA format. The CkBrowserImageDecoder implementation of toByteData needs to convert that into RGBA format. If the output format is rawRgba then it also needs to apply premultipled alpha. Also fixes an issue where _bgrToRgba was not converting all pixels in the image. Fixes flutter/flutter#135409 Fixes flutter/flutter#144770
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.
Thank you for fixing my bugs!
} | ||
|
||
/// Based on Chromium's SetRGBAPremultiply. | ||
int _premultiply(int value, int alpha) { |
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.
It might make sense to inline this function using @pragma('dart2js:tryInline')
as images can be pretty big and could take advantage of faster pixel processing logic.
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.
Added the inlining annotation
} | ||
|
||
// Last resort, just return the original pixels. | ||
return pixels.asByteData(); | ||
} | ||
|
||
/// Mutates the [pixels], converting them from BGRX/BGRA to RGBA. | ||
void _bgrToRgba(ByteBuffer pixels) { | ||
final int pixelCount = pixels.lengthInBytes ~/ 4; | ||
void _bgrToStraightRgba(ByteBuffer pixels, bool isBgrx) { |
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.
This could be inlined too so that the compiler specializes the function for possible values of isBgrx
, true and false.
…Format.rawRgba and rawStraightRgba (flutter/engine#52089)
…146959) flutter/engine@624730f...725ebd7 2024-04-17 [email protected] Roll Skia from 5958cd52db48 to a3a016537a8c (3 revisions) (flutter/engine#52208) 2024-04-17 [email protected] Roll Dart SDK from bd7627bca67b to 45dd87c2329c (1 revision) (flutter/engine#52207) 2024-04-17 [email protected] Fix CkBrowserImageDecoder conversion of images to ImageByteFormat.rawRgba and rawStraightRgba (flutter/engine#52089) 2024-04-17 [email protected] Roll Skia from a78dec0c0538 to 5958cd52db48 (2 revisions) (flutter/engine#52206) 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
…lutter#146959) flutter/engine@624730f...725ebd7 2024-04-17 [email protected] Roll Skia from 5958cd52db48 to a3a016537a8c (3 revisions) (flutter/engine#52208) 2024-04-17 [email protected] Roll Dart SDK from bd7627bca67b to 45dd87c2329c (1 revision) (flutter/engine#52207) 2024-04-17 [email protected] Fix CkBrowserImageDecoder conversion of images to ImageByteFormat.rawRgba and rawStraightRgba (flutter/engine#52089) 2024-04-17 [email protected] Roll Skia from a78dec0c0538 to 5958cd52db48 (2 revisions) (flutter/engine#52206) 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
VideoFrames of decoded images typically contain BGRA format. The CkBrowserImageDecoder implementation of toByteData needs to convert that into RGBA format. If the output format is rawRgba then it also needs to apply premultipled alpha.
Also fixes an issue where _bgrToRgba was not converting all pixels in the image.
Fixes flutter/flutter#135409
Fixes flutter/flutter#144770