diff options
author | 2018-12-11 07:56:07 -0800 | |
---|---|---|
committer | 2018-12-15 09:35:25 -0800 | |
commit | 3bff13550380f02e30f1ae77f2497d9ec89b0ec4 (patch) | |
tree | 75b2fb1ce48d7a93fa4d5e0bf5a0db31f9ab8d64 /libs/hwui/DeviceInfo.cpp | |
parent | 78c2a0de5793fd997ee716de7f4845bfa7c6a7c3 (diff) |
[HWUI] Remove hardcoding around wide color gamut.
Previously we hardcode wide color gamut in HWUI as scRGB color space with FP16
pixel format. However, the hardware composer doesn't support this combination.
This patch plumbs wide color gamut composition preference from composer API to
HWUI such that HWUI can now pick the combination of color space and pixel
format for the surface.
BUG: 111436479
Test: Build, flash and boot, verify with a demo app.
Change-Id: I7a8b4d8deca72ef40069dba9d23a3f5e90dbfe5a
Diffstat (limited to 'libs/hwui/DeviceInfo.cpp')
-rw-r--r-- | libs/hwui/DeviceInfo.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp index 0b9d82b105a3..ed167e57158e 100644 --- a/libs/hwui/DeviceInfo.cpp +++ b/libs/hwui/DeviceInfo.cpp @@ -20,6 +20,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> +#include <ui/GraphicTypes.h> #include <mutex> #include <thread> @@ -61,6 +62,50 @@ DisplayInfo QueryDisplayInfo() { return displayInfo; } +static void queryWideColorGamutPreference(SkColorSpace::Gamut* colorGamut, + sk_sp<SkColorSpace>* colorSpace, SkColorType* colorType) { + if (Properties::isolatedProcess) { + *colorGamut = SkColorSpace::Gamut::kSRGB_Gamut; + *colorSpace = SkColorSpace::MakeSRGB(); + *colorType = SkColorType::kN32_SkColorType; + return; + } + ui::Dataspace defaultDataspace, wcgDataspace; + ui::PixelFormat defaultPixelFormat, wcgPixelFormat; + status_t status = + SurfaceComposerClient::getCompositionPreference(&defaultDataspace, &defaultPixelFormat, + &wcgDataspace, &wcgPixelFormat); + LOG_ALWAYS_FATAL_IF(status, "Failed to get composition preference, error %d", status); + switch (wcgDataspace) { + case ui::Dataspace::DISPLAY_P3: + *colorGamut = SkColorSpace::Gamut::kDCIP3_D65_Gamut; + *colorSpace = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, + SkColorSpace::Gamut::kDCIP3_D65_Gamut); + break; + case ui::Dataspace::V0_SCRGB: + *colorGamut = SkColorSpace::Gamut::kSRGB_Gamut; + *colorSpace = SkColorSpace::MakeSRGB(); + break; + case ui::Dataspace::V0_SRGB: + // when sRGB is returned, it means wide color gamut is not supported. + *colorGamut = SkColorSpace::Gamut::kSRGB_Gamut; + *colorSpace = SkColorSpace::MakeSRGB(); + break; + default: + LOG_ALWAYS_FATAL("Unreachable: unsupported wide color space."); + } + switch (wcgPixelFormat) { + case ui::PixelFormat::RGBA_8888: + *colorType = SkColorType::kN32_SkColorType; + break; + case ui::PixelFormat::RGBA_FP16: + *colorType = SkColorType::kRGBA_F16_SkColorType; + break; + default: + LOG_ALWAYS_FATAL("Unreachable: unsupported pixel format."); + } +} + DeviceInfo::DeviceInfo() { #if HWUI_NULL_GPU mMaxTextureSize = NULL_GPU_MAX_TEXTURE_SIZE; @@ -68,6 +113,7 @@ DeviceInfo::DeviceInfo() { mMaxTextureSize = -1; #endif mDisplayInfo = QueryDisplayInfo(); + queryWideColorGamutPreference(&mWideColorGamut, &mWideColorSpace, &mWideColorType); } int DeviceInfo::maxTextureSize() const { |