Android 8.1 and higher include support for color management that can be used to provide a consistent experience across display technologies. Apps running on Android can access the full capabilities of a wide-gamut display to get the most out of a display device.
Previous Android releases didn't include color management support and instead relied on content and displays being compatible (a goal often aided by the TV industry). However, recent display technologies allow for much larger gamut displays that don't display existing content as expected. With Android 8.1 and higher, devices that use a wide-gamut display (for example, active-matrix organic light-emitting diode or AMOLED, some LCDs) can see wide-gamut content from apps.
Determine device support
Devices with wide-color displays running Android 8.1 or higher should support color management (wide-color). Before enabling this feature, ensure that the device meets the following requirements:
- Device display meets the hardware requirements, which include a well-characterized display that supports the Display-P3 colorspace. If the display doesn't meet this requirement, don't enable color management. To reduce CPU and GPU impact, support for extended sRGB and HDR10 in the display pipeline is desirable.
- Device supports a factory calibration process that generates calibration data (stored on the device) to adjust for manufacturing variance in display behavior. At a minimum, calibration data should allow the display to accurately display sRGB content and D65 and D73 white points.
If these requirements are met, you can enable the color management feature for the device.
Implement color management
To implement color management, first update the
Hardware Composer 2 (HWC2) driver
to understand color modes and to apply those modes to the hardware.
Specifically, the HWC2 composer must report the Display-P3 and sRGB
color modes using HWCDisplay::GetColorModes
.
Next, enable the necessary OpenGL extensions and library support to translate OpenGL color spaces to HAL data spaces. Required OpenGL extensions include:
-
EGL_EXT_pixel_format_float
. Allows apps to create presentable EGLSurfaces with 16-bit float color components. Priority: high (expect this is the default pixel format for wide-color aware apps). Requires driver support. -
EGL_KHR_gl_colorspace
. For apps that want to use sRGB format default framebuffers to more easily achieve sRGB rendering to display devices, this extension allows creating EGLSurfaces that will be rendered to in sRGB by OpenGL contexts supporting that capability. Requires driver support for sRGB behavior.
Android also provides the following optional extensions:
-
EGL_EXT_colorspace_scrgb_linear
. This extension provides a new color space option, scRGB, that apps can choose when creating an EGLSurface. The scRGB color space defines a linear display referred space with the same white point and color primaries as sRGB (and thus is backward compatible with sRGB). This shouldn't require driver support and can be implemented in the Android EGL wrapper. To be useful, this extension requires support for 16-bit floating point (FP16). -
EGL_EXT_gl_colorspace_display_p3
andEGL_EXT_gl_colorspace_display_p3_linear
. For apps that want to use Display-P3 format default framebuffers to more easily achieve sRGB rendering to display devices, this extension allows creating EGLSurfaces that will be rendered to in Display-P3 by OpenGL contexts supporting that capability. This can be implemented in EGL driver wrapper. -
VK_EXT_swapchain_colorspace
(Vulkan). Enables apps to tag swap chains with the color space they're using. Includes a number of common color spaces such as DCI-P3, Display-P3, AdobeRGB, and BT2020.
Customization
You can customize the color management feature by including support for a variety of color standards such as DCI-P3, AdobeRGB, Rec709, and Rec2020. Other customizations include:
- Hardware support for color conversion in the display pipeline. Enables support for multiple color transforms in hardware.
- Support for independent color transform on multiple layers (for example, some layers could be sRGB and others extended-sRGB, each with their own color pipeline). When there's more than one color space visible, some color spaces need to be converted to the color space of the display. Ideally, this transform is best provided by the display engine (otherwise Android must perform GPU composition).
Testing
To test color management, use the following resources in
opengl/tests
:
gl2_basic
is a simple OpenGL demo that requests a Display-P3 colorspace.-
EGL_test
tests for necessary extension and config support (10:10:10:2 and FP16). test_wide_color
creates a surface in same manner as SurfaceFlinger (for example, config, color space, and pixel format).
Reference implementation
For a reference implementation, refer to frameworks/native
. For
headers, refer to:
system/core/include/system/graphics.h
system/core/include/system/graphics-base.h
HAL_DATASPACE_*
HAL_COLOR_MODE_*