summaryrefslogtreecommitdiff
path: root/libs/hwui/utils
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2019-01-22 13:56:25 -0500
committerDerek Sollenberger <djsollen@google.com>2019-01-23 16:31:52 -0500
commit6e35e63740e9becb0976f3dc54ea0cd5ffc26564 (patch)
tree28ed578f4c0d437261904bcc27f401981dbd4f6e /libs/hwui/utils
parent38c8934b67d7cb2904b25eaa422a7b56160dcfae (diff)
Don't assume all FP16 bitmaps are linearly encoded.
The bitmap.create() function that does not take a colorspace does not enforce that the bitmap is linearly encoded and as such it is possible for us to end up with FP16 bitmaps that are sRGB encoded. Given that we want to remove that restriction (see b/120870651) we update getColorSpace to report the actual colorSpace of the underlying bitmap. This pulls a thread that causes a chain of updates to various classes to ensure proper handling of the native colorspace. Bug: 120904891 Test: CtsUiRenderingTestCases Change-Id: I27780aa603138b0e48f9320c2837bc53e22cdf95
Diffstat (limited to 'libs/hwui/utils')
-rw-r--r--libs/hwui/utils/Color.cpp14
-rw-r--r--libs/hwui/utils/Color.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/libs/hwui/utils/Color.cpp b/libs/hwui/utils/Color.cpp
index 4415a593f6ee..d14116f7b555 100644
--- a/libs/hwui/utils/Color.cpp
+++ b/libs/hwui/utils/Color.cpp
@@ -45,6 +45,20 @@ android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType) {
}
}
+SkColorType PixelFormatToColorType(android::PixelFormat format) {
+ switch (format) {
+ case PIXEL_FORMAT_RGBX_8888: return kRGB_888x_SkColorType;
+ case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_SkColorType;
+ case PIXEL_FORMAT_RGBA_FP16: return kRGBA_F16_SkColorType;
+ case PIXEL_FORMAT_RGB_565: return kRGB_565_SkColorType;
+ case PIXEL_FORMAT_RGBA_1010102: return kRGBA_1010102_SkColorType;
+ case PIXEL_FORMAT_RGBA_4444: return kARGB_4444_SkColorType;
+ default:
+ ALOGW("Unsupported PixelFormat: %d, return kUnknown_SkColorType by default", format);
+ return kUnknown_SkColorType;
+ }
+}
+
sk_sp<SkColorSpace> DataSpaceToColorSpace(android_dataspace dataspace) {
skcms_Matrix3x3 gamut;
diff --git a/libs/hwui/utils/Color.h b/libs/hwui/utils/Color.h
index 388025207ed6..b67d10d4249c 100644
--- a/libs/hwui/utils/Color.h
+++ b/libs/hwui/utils/Color.h
@@ -112,6 +112,7 @@ static constexpr float EOCF(float srgb) {
}
android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType);
+ANDROID_API SkColorType PixelFormatToColorType(android::PixelFormat format);
ANDROID_API sk_sp<SkColorSpace> DataSpaceToColorSpace(android_dataspace dataspace);