summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2023-01-31 16:21:28 -0500
committer John Reck <jreck@google.com> 2023-01-31 16:21:28 -0500
commit0b3f331ef566bc9b3f17e92e25248beb3d06dcf2 (patch)
tree1212e988034596fb7097be093109555182eba455
parent91f6cdacbcac6b35cc39984f298ec43bd85ba7ba (diff)
Address VRI review comments
Test: make Bug: 266628247 Change-Id: I8652d1e33ad01be48a2efa4c323f60f6f65e73bd
-rw-r--r--graphics/java/android/graphics/HardwareRenderer.java2
-rw-r--r--libs/hwui/ColorMode.h3
-rw-r--r--libs/hwui/pipeline/skia/SkiaPipeline.cpp7
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp7
-rw-r--r--libs/hwui/renderthread/EglManager.cpp1
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp2
-rw-r--r--libs/hwui/renderthread/VulkanSurface.cpp6
7 files changed, 20 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java
index c3eb7aa454ae..0488b9d8b201 100644
--- a/graphics/java/android/graphics/HardwareRenderer.java
+++ b/graphics/java/android/graphics/HardwareRenderer.java
@@ -668,7 +668,7 @@ public class HardwareRenderer {
/** @hide */
public void setTargetSdrHdrRatio(float ratio) {
- if (ratio < 1.f || Float.isNaN(ratio) || Float.isInfinite(ratio)) ratio = 1.f;
+ if (ratio < 1.f || !Float.isFinite(ratio)) ratio = 1.f;
nSetTargetSdrHdrRatio(mNativeProxy, ratio);
}
diff --git a/libs/hwui/ColorMode.h b/libs/hwui/ColorMode.h
index e45db01c0e34..959cf742c8e4 100644
--- a/libs/hwui/ColorMode.h
+++ b/libs/hwui/ColorMode.h
@@ -27,6 +27,9 @@ enum class ColorMode {
WideColorGamut = 1,
// Extended range Display P3
Hdr = 2,
+ // Extended range Display P3 10-bit
+ // for test purposes only, not shippable due to insuffient alpha
+ Hdr10 = 3,
// Alpha 8
A8 = 4,
};
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index 09c3120a9f71..fd2f6f096783 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -621,6 +621,11 @@ void SkiaPipeline::setSurfaceColorProperties(ColorMode colorMode) {
mSurfaceColorSpace = SkColorSpace::MakeRGB(
GetExtendedTransferFunction(mTargetSdrHdrRatio), SkNamedGamut::kDisplayP3);
break;
+ case ColorMode::Hdr10:
+ mSurfaceColorType = SkColorType::kRGBA_1010102_SkColorType;
+ mSurfaceColorSpace = SkColorSpace::MakeRGB(
+ GetExtendedTransferFunction(mTargetSdrHdrRatio), SkNamedGamut::kDisplayP3);
+ break;
case ColorMode::A8:
mSurfaceColorType = SkColorType::kAlpha_8_SkColorType;
mSurfaceColorSpace = nullptr;
@@ -629,7 +634,7 @@ void SkiaPipeline::setSurfaceColorProperties(ColorMode colorMode) {
}
void SkiaPipeline::setTargetSdrHdrRatio(float ratio) {
- if (mColorMode == ColorMode::Hdr) {
+ if (mColorMode == ColorMode::Hdr || mColorMode == ColorMode::Hdr10) {
mTargetSdrHdrRatio = ratio;
mSurfaceColorSpace = SkColorSpace::MakeRGB(GetExtendedTransferFunction(mTargetSdrHdrRatio),
SkNamedGamut::kDisplayP3);
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index c0f30865d507..5b51b642c6bc 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -289,7 +289,8 @@ void CanvasContext::setOpaque(bool opaque) {
float CanvasContext::setColorMode(ColorMode mode) {
if (mode != mColorMode) {
- if (mode == ColorMode::Hdr && !mRenderPipeline->supportsExtendedRangeHdr()) {
+ const bool isHdr = mode == ColorMode::Hdr || mode == ColorMode::Hdr10;
+ if (isHdr && !mRenderPipeline->supportsExtendedRangeHdr()) {
mode = ColorMode::WideColorGamut;
}
mColorMode = mode;
@@ -299,13 +300,15 @@ float CanvasContext::setColorMode(ColorMode mode) {
switch (mColorMode) {
case ColorMode::Hdr:
return 3.f; // TODO: Refine this number
+ case ColorMode::Hdr10:
+ return 10.f;
default:
return 1.f;
}
}
float CanvasContext::targetSdrHdrRatio() const {
- if (mColorMode == ColorMode::Hdr) {
+ if (mColorMode == ColorMode::Hdr || mColorMode == ColorMode::Hdr10) {
return mTargetSdrHdrRatio;
} else {
return 1.f;
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index 5b7cf7538bd7..4fb114b71bf5 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -455,6 +455,7 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window,
// composer3 support, just treat HDR as equivalent to wide color gamut if
// the GLES path is still being hit
case ColorMode::Hdr:
+ case ColorMode::Hdr10:
case ColorMode::WideColorGamut: {
skcms_Matrix3x3 colorGamut;
LOG_ALWAYS_FATAL_IF(!colorSpace->toXYZD50(&colorGamut),
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index f8e2deebc3c6..cdfbf021805d 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -134,7 +134,7 @@ void RenderProxy::setOpaque(bool opaque) {
float RenderProxy::setColorMode(ColorMode mode) {
// We only need to figure out what the renderer supports for HDR, otherwise this can stay
// an async call since we already know the return value
- if (mode == ColorMode::Hdr) {
+ if (mode == ColorMode::Hdr || mode == ColorMode::Hdr10) {
return mRenderThread.queue().runSync(
[=]() -> float { return mContext->setColorMode(mode); });
} else {
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp
index 2efa5d691ca5..21b6c44e997e 100644
--- a/libs/hwui/renderthread/VulkanSurface.cpp
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -201,7 +201,7 @@ bool VulkanSurface::InitializeWindowInfoStruct(ANativeWindow* window, ColorMode
outWindowInfo->colorspace = colorSpace;
outWindowInfo->colorMode = colorMode;
- if (colorMode == ColorMode::Hdr) {
+ if (colorMode == ColorMode::Hdr || colorMode == ColorMode::Hdr10) {
outWindowInfo->dataspace =
static_cast<android_dataspace>(STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_EXTENDED);
} else {
@@ -509,7 +509,7 @@ void VulkanSurface::setColorSpace(sk_sp<SkColorSpace> colorSpace) {
mNativeBuffers[i].skSurface.reset();
}
- if (mWindowInfo.colorMode == ColorMode::Hdr) {
+ if (mWindowInfo.colorMode == ColorMode::Hdr || mWindowInfo.colorMode == ColorMode::Hdr10) {
mWindowInfo.dataspace =
static_cast<android_dataspace>(STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_EXTENDED);
} else {
@@ -521,7 +521,7 @@ void VulkanSurface::setColorSpace(sk_sp<SkColorSpace> colorSpace) {
"Unsupported colorspace");
if (mNativeWindow) {
- int err = native_window_set_buffers_data_space(mNativeWindow.get(), mWindowInfo.dataspace);
+ int err = ANativeWindow_setBuffersDataSpace(mNativeWindow.get(), mWindowInfo.dataspace);
if (err != 0) {
ALOGE("VulkanSurface::setColorSpace() native_window_set_buffers_data_space(%d) "
"failed: %s (%d)",