Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Android 8.1 trở lên hỗ trợ tính năng quản lý màu sắc có thể dùng để mang lại trải nghiệm nhất quán trên các công nghệ hiển thị. Các ứng dụng chạy trên Android có thể khai thác toàn bộ chức năng của màn hình gam màu rộng để khai thác tối đa thiết bị hiển thị.
Các bản phát hành Android trước đây không hỗ trợ quản lý màu sắc mà thay vào đó dựa vào nội dung và màn hình tương thích (một mục tiêu thường được ngành TV hỗ trợ). Tuy nhiên, các công nghệ màn hình gần đây cho phép màn hình có gam màu lớn hơn nhiều nhưng không hiển thị nội dung hiện có như mong đợi. Với Android 8.1 trở lên, các thiết bị sử dụng màn hình gam màu rộng (ví dụ: điốt phát sáng hữu cơ ma trận động hoặc AMOLED, một số màn hình LCD) có thể xem nội dung gam màu rộng từ các ứng dụng.
Xác định khả năng hỗ trợ thiết bị
Các thiết bị có màn hình màu rộng chạy Android 8.1 trở lên phải hỗ trợ tính năng quản lý màu (màu rộng). Trước khi bật tính năng này, hãy đảm bảo rằng thiết bị đáp ứng các yêu cầu sau:
Màn hình thiết bị đáp ứng các yêu cầu về phần cứng, bao gồm cả màn hình được mô tả rõ ràng hỗ trợ không gian màu Display-P3. Nếu màn hình không đáp ứng yêu cầu này, đừng bật tính năng quản lý màu. Để giảm tác động của CPU và GPU, bạn nên hỗ trợ sRGB mở rộng và HDR10 trong quy trình hiển thị.
Thiết bị hỗ trợ quy trình hiệu chuẩn ban đầu tạo ra dữ liệu hiệu chuẩn (được lưu trữ trên thiết bị) để điều chỉnh sự khác biệt trong quá trình sản xuất về hành vi hiển thị. Ít nhất, dữ liệu hiệu chuẩn phải cho phép màn hình hiển thị chính xác nội dung sRGB và các điểm trắng D65 và D73.
Nếu đáp ứng các yêu cầu này, bạn có thể bật tính năng quản lý màu cho thiết bị.
Triển khai tính năng quản lý màu
Để triển khai tính năng quản lý màu, trước tiên, hãy cập nhật trình điều khiển Hardware Composer 2 (HWC2) để hiểu các chế độ màu và áp dụng các chế độ đó cho phần cứng.
Cụ thể, trình tổng hợp HWC2 phải báo cáo chế độ màu Display-P3 và sRGB bằng HWCDisplay::GetColorModes.
Tiếp theo, hãy bật các tiện ích OpenGL và tính năng hỗ trợ thư viện cần thiết để dịch không gian màu OpenGL sang không gian dữ liệu HAL. Các tiện ích OpenGL bắt buộc bao gồm:
EGL_EXT_pixel_format_float.
Cho phép ứng dụng tạo EGLSurfaces hiển thị được bằng các thành phần màu dấu phẩy động 16 bit. Mức độ ưu tiên: cao (dự kiến đây là định dạng pixel mặc định cho các ứng dụng nhận biết màu rộng). Yêu cầu hỗ trợ trình điều khiển.
EGL_KHR_gl_colorspace.
Đối với các ứng dụng muốn sử dụng vùng đệm khung hình mặc định ở định dạng sRGB để dễ dàng kết xuất sRGB hơn cho các thiết bị hiển thị, tiện ích này cho phép tạo EGLSurfaces sẽ được kết xuất ở sRGB theo ngữ cảnh OpenGL hỗ trợ chức năng đó. Yêu cầu trình điều khiển hỗ trợ hành vi sRGB.
Android cũng cung cấp các tiện ích không bắt buộc sau:
EGL_EXT_colorspace_scrgb_linear.
Tiện ích này cung cấp một tuỳ chọn không gian màu mới, scRGB, mà các ứng dụng có thể chọn khi tạo EGLSurface. Không gian màu scRGB xác định một không gian hiển thị được tham chiếu tuyến tính với cùng điểm trắng và màu chính như sRGB (và do đó tương thích ngược với sRGB). Việc này không yêu cầu hỗ trợ trình điều khiển và có thể được triển khai trong trình bao bọc EGL Android. Để hữu ích, tiện ích này cần hỗ trợ dấu phẩy động 16 bit (FP16).
EGL_EXT_gl_colorspace_display_p3 và EGL_EXT_gl_colorspace_display_p3_linear. Đối với các ứng dụng muốn sử dụng vùng đệm khung hình mặc định ở định dạng Display-P3 để dễ dàng kết xuất sRGB hơn cho các thiết bị hiển thị, tiện ích này cho phép tạo EGLSurfaces sẽ được kết xuất trong Display-P3 theo ngữ cảnh OpenGL hỗ trợ chức năng đó.
Bạn có thể triển khai việc này trong trình bao bọc trình điều khiển EGL.
VK_EXT_swapchain_colorspace
(Vulkan). Cho phép ứng dụng gắn thẻ chuỗi hoán đổi bằng không gian màu mà ứng dụng đang sử dụng. Bao gồm một số không gian màu phổ biến như DCI-P3, Display-P3, AdobeRGB và BT2020.
Tuỳ chỉnh
Bạn có thể tuỳ chỉnh tính năng quản lý màu bằng cách hỗ trợ nhiều tiêu chuẩn màu như DCI-P3, AdobeRGB, Rec709 và Rec2020. Các tuỳ chỉnh khác bao gồm:
Hỗ trợ phần cứng để chuyển đổi màu trong quy trình hiển thị. Cho phép hỗ trợ nhiều phép biến đổi màu trong phần cứng.
Hỗ trợ biến đổi màu độc lập trên nhiều lớp (ví dụ: một số lớp có thể là sRGB và các lớp khác là sRGB mở rộng, mỗi lớp có quy trình màu riêng). Khi có nhiều không gian màu hiển thị, một số không gian màu cần được chuyển đổi sang không gian màu của màn hình. Lý tưởng nhất là công cụ hiển thị sẽ cung cấp phép biến đổi này (nếu không, Android phải thực hiện thành phần GPU).
Thử nghiệm
Để kiểm thử tính năng quản lý màu, hãy sử dụng các tài nguyên sau trong opengl/tests:
gl2_basic là một bản minh hoạ OpenGL đơn giản yêu cầu không gian màu Display-P3.
EGL_test kiểm thử để hỗ trợ tiện ích và cấu hình cần thiết (10:10:10:2 và FP16).
test_wide_color tạo một giao diện theo cách tương tự như SurfaceFlinger (ví dụ: cấu hình, không gian màu và định dạng pixel).
Triển khai tham chiếu
Để triển khai tham chiếu, hãy tham khảo frameworks/native. Đối với tiêu đề, hãy tham khảo:
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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_*`"]]