Attach color space after performing a readback

Bug: 78463311
Test: I28713c3e5ce38dea15c75542801f9aef0e5b5b0a

Bitmap::getSkBitmap() is used by Bitmap#compress before encoding. If the
Bitmap has Config HARDWARE, we have to do a readback first. We cannot
necessarily do the readback using the SkColorSpace of the Bitmap, since
that requires creating an SkSurface, which does not support all
SkColorSpaces. Instead, continue using nullptr for the readback, and
then change the info and reattach the SkPixelRef.

This fixes a bug where encoding a non-SRGB HARDWARE Bitmap and then
decoding it results in a Bitmap with the wrong ColorSpace.

Change-Id: If55b2dbfeb17d81ceaf9594b32ed69b6a9058f06
1 file changed