[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Color management\n\nAndroid 8.1 and higher include support for color management that can be used to provide a\nconsistent experience across display technologies. Apps running on\nAndroid can access the full capabilities of a wide-gamut display to get the\nmost out of a display device.\n\nPrevious Android releases didn't include color management support and\ninstead relied on content and displays being compatible (a goal often aided by\nthe TV industry). However, recent display technologies allow for much larger\ngamut displays that don't display existing content as expected. With Android\n8.1 and higher, devices that use a wide-gamut display (for example, active-matrix organic\nlight-emitting diode or AMOLED, some LCDs) can see wide-gamut\ncontent from apps.\n\nDetermine device support\n------------------------\n\nDevices with wide-color displays running Android 8.1 or higher should support color\nmanagement (wide-color). Before enabling this feature, ensure that the device meets\nthe following requirements:\n\n- 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.\n- 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.\n\nIf these requirements are met, you can enable the color management\nfeature for the device.\n\nImplement color management\n--------------------------\n\nTo implement color management, first update the\n[Hardware Composer 2 (HWC2)](/docs/core/graphics/implement-hwc) driver\nto understand color modes and to apply those modes to the hardware.\nSpecifically, the HWC2 composer must report the Display-P3 and sRGB\ncolor modes using `HWCDisplay::GetColorModes`.\n| **Key Term:** Display-P3 uses Digital Cinema Initiatives primaries and sRGB transfer function.\n\nNext, enable the necessary OpenGL extensions and library support to\ntranslate OpenGL color spaces to HAL data spaces. Required OpenGL extensions\ninclude:\n\n- [`EGL_EXT_pixel_format_float`](https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_pixel_format_float.txt). 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.\n- [`EGL_KHR_gl_colorspace`](https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_gl_colorspace.txt). 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.\n\nAndroid also provides the following optional extensions:\n\n- [`EGL_EXT_colorspace_scrgb_linear`](https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_gl_colorspace_scrgb_linear.txt). 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).\n- [`EGL_EXT_gl_colorspace_display_p3`\n and `EGL_EXT_gl_colorspace_display_p3_linear`](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_gl_colorspace_display_p3.txt). 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.\n- [`VK_EXT_swapchain_colorspace`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#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.\n\nCustomization\n-------------\n\nYou can customize the color management feature by including support for a\nvariety of color standards such as DCI-P3, AdobeRGB, Rec709, and Rec2020. Other\ncustomizations include:\n\n- **Hardware support for color conversion in the display\n pipeline.** Enables support for multiple color transforms in hardware.\n- **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).\n\nTesting\n-------\n\nTo test color management, use the following resources in\n`opengl/tests`:\n\n- `gl2_basic` is a simple OpenGL demo that requests a Display-P3 colorspace.\n- [`EGL_test`](https://android.googlesource.com/platform/frameworks/native/+/android16-release/opengl/tests/EGLTest/EGL_test.cpp) tests for necessary extension and config support (10:10:10:2 and FP16).\n- `test_wide_color` creates a surface in same manner as SurfaceFlinger (for example, config, color space, and pixel format).\n\nReference implementation\n------------------------\n\nFor a reference implementation, refer to `frameworks/native`. For\nheaders, refer to:\n\n- [`system/core/include/system/graphics.h`](https://android.googlesource.com/platform/system/core/+/android16-release/libsystem/include/system/graphics.h)\n- [`system/core/include/system/graphics-base.h`](https://android.googlesource.com/platform/system/core/+/android16-release/libsystem/include/system/graphics-base.h)\n - `HAL_DATASPACE_*`\n - `HAL_COLOR_MODE_*`"]]