summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2017-07-10 17:04:03 -0400
committerStan Iliev <stani@google.com>2017-07-19 09:22:39 -0400
commit0a3ff952a6ba9ce15f8165632e606587fabd3fea (patch)
tree47a466606d09f3320b31cb0b20c5392c78f19961 /libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
parenta554ba6e2ebc320e9227a0302c8079c0f2cb9e85 (diff)
Improve color correctness for drawing bitmaps with Skia pipeline
Fix drawing of bitmaps with color profiles. This CL is making ColorSpaceTests and Rgba16fTests CTS tests to pass with Skia pipeline. Drawing bitmaps withs pixels outside SRGB range may need more work (ColorSpaceTests#testDrawDisplayP3 test use a a wider gamut, but the actual pixels fall into the SRGB range). Test: Ran CtsUiRenderingTestCases with HWUI and Skia pipeline. Bug: 62347704 Change-Id: I8d318076bb38f7d32bfde7e5492ae7a61f4731a5
Diffstat (limited to 'libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp')
-rw-r--r--libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 10e637a65f57..925db303461f 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -303,6 +303,13 @@ sk_sp<Bitmap> SkiaOpenGLPipeline::allocateHardwareBitmap(renderthread::RenderThr
return nullptr;
}
+ auto colorSpace = info.colorSpace();
+ bool convertToSRGB = false;
+ if (colorSpace && (!colorSpace->isSRGB())) {
+ isSupported = false;
+ convertToSRGB = true;
+ }
+
SkBitmap bitmap;
if (isSupported) {
bitmap = skBitmap;
@@ -310,7 +317,7 @@ sk_sp<Bitmap> SkiaOpenGLPipeline::allocateHardwareBitmap(renderthread::RenderThr
bitmap.allocPixels(SkImageInfo::MakeN32(info.width(), info.height(), info.alphaType(),
nullptr));
bitmap.eraseColor(0);
- if (info.colorType() == kRGBA_F16_SkColorType) {
+ if (info.colorType() == kRGBA_F16_SkColorType || convertToSRGB) {
// Drawing RGBA_F16 onto ARGB_8888 is not supported
skBitmap.readPixels(bitmap.info().makeColorSpace(SkColorSpace::MakeSRGB()),
bitmap.getPixels(), bitmap.rowBytes(), 0, 0);