Android 设备之间的 HDR 功能各不相同,这可能会导致 HDR 显示输出不一致。查找表 (LUT) 是一种旨在解决此不一致性的全新色彩校正解决方案。此不一致性通过规定颜色校正方式(而不是委托给未定义的设备专属颜色校正机制)来解决。
SDK 前提条件
如需实现 LUT,您的 SDK 版本必须为 36 或更高版本。
实现 LUT
如需将 LUT 应用于 SurfaceControl
,请按以下步骤操作:
- 创建
DisplayLuts
实例。 - 使用 LUT 数据缓冲区、LUT 维度和 LUT 的采样键创建
DisplayLuts.Entry
实例。如需了解详情,请参阅LutProperties
文档。 - 调用
DisplayLuts#set(DisplayLuts.Entry luts)
或DisplayLuts#set(DisplayLuts.Entry first, DisplayLuts.Entry second)
来设置 LUT 条目。该框架支持 1D LUT、3D LUT 或 1D 和 3D LUT 的组合。 - 调用
SurfaceControl.Transaction#setLuts
以将 LUT 应用于图层。
Kotlin
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()
Java
SurfaceControl sc = new SurfaceControl.Builder().build();
DisplayLuts luts = new DisplayLuts();
DisplayLuts.Entry entry = new DisplayLuts.Entry(
new float[]{0.5f, 0.5f, 0.5f, 0.5f},
LutProperties.ONE_DIMENSION,
LutProperties.SAMPLING_KEY_MAX_RGB
);
luts.set(entry);
new SurfaceControl.Transaction().setLuts(sc, luts).apply();
您还可以使用 OverlayProperties.getLutProperties()
了解设备的 LUT 属性,并确定硬件混合渲染器是否可以处理所选的 LUT。