Varying HDR capabilities across Android devices can lead to fragmented HDR display outputs. A look-up table (LUT) is a new color correction solution designed to resolve this inconsistency. This inconsistency is resolved by prescribing a way to color correct, rather than delegating to an undefined per-device color correction mechanism.
SDK prerequisites
To implement LUTs, your SDK version must 36 or higher.
Implement a LUT
Follow these steps to apply a LUT to a SurfaceControl:
- Create a
DisplayLutsinstance. - Create
DisplayLuts.Entryinstance(s) with the LUT data buffer, LUT dimension, and the sampling key of the LUT. For more information, seeLutPropertiesdocumentation. - Call
DisplayLuts#set(DisplayLuts.Entry luts)orDisplayLuts#set(DisplayLuts.Entry first, DisplayLuts.Entry second)to set LUT entries. The framework supports 1D LUT, 3D LUT, or a combination of 1D and 3D LUTs. - Call
SurfaceControl.Transaction#setLutsto apply the LUTs to the layer.
val sc = SurfaceControl.Builder().build() val luts = DisplayLuts() val entry = DisplayLuts.Entry( floatArrayOf(0.5f, 0.5f, 0.5f, 0.5f), LutProperties.ONE_DIMENSION, LutProperties.SAMPLING_KEY_MAX_RGB ) luts.set(entry) SurfaceControl.Transaction().setLuts(sc, luts).apply()
You can also use OverlayProperties.getLutProperties() to understand the
LUT properties of the device, and determine if the Hardware Composer can handle
the selected LUT. Starting in Android 17 (API level 37), getLutProperties()
is annotated with @Nullable, so check for a null return value before
reading the returned array.