Skip to content

Commit

Permalink
Add workaround for AOSP bug with decoding single channel hardware gai…
Browse files Browse the repository at this point in the history
…nmaps using BitmapFactory.

Android U devices that use skiagl for hwui renderering (currently the vast majority) have a bug
where uplading single channel bitmaps to hardware bitmaps fails. This bug essentially breaks
single channel gainmap rendering using hardware bitmaps, which is a common use case on devices
that have Ultra HDR as the default capture format. See #5357
for more details.

The workaround is as follows:
1. Detect the presence of the bug by attempting to copy a 1x1 single channel bitmap to hardware.
2. Memoize the result
3. For BitmapFactory.decode* calls, if the input bitmap has a gainmap, copy it to a three-channel
gainmap. This step seems wasteful, but in practice, the Android OS already does some copying when
creating hardware bitmaps. Also, more importantly, there is an AOSP fix for this bug, and as
devices are updated with this fix, this flow will no longer be exercised.
  • Loading branch information
falhassen authored and kanelbulle committed Feb 2, 2024
1 parent e85c765 commit 8ca2db2
Show file tree
Hide file tree
Showing 7 changed files with 654 additions and 41 deletions.
Loading

0 comments on commit 8ca2db2

Please sign in to comment.