Address VRI review comments

Test: make
Bug: 266628247
Change-Id: I8652d1e33ad01be48a2efa4c323f60f6f65e73bd
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java
index c3eb7aa..0488b9d 100644
--- a/graphics/java/android/graphics/HardwareRenderer.java
+++ b/graphics/java/android/graphics/HardwareRenderer.java
@@ -668,7 +668,7 @@
 
     /** @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 e45db01..959cf74 100644
--- a/libs/hwui/ColorMode.h
+++ b/libs/hwui/ColorMode.h
@@ -27,6 +27,9 @@
     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 09c3120..fd2f6f0 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -621,6 +621,11 @@
             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::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 c0f3086..5b51b64 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -289,7 +289,8 @@
 
 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 @@
     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 5b7cf753..4fb114b 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -455,6 +455,7 @@
                 // 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 f8e2dee..cdfbf02 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -134,7 +134,7 @@
 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 2efa5d6..21b6c44 100644
--- a/libs/hwui/renderthread/VulkanSurface.cpp
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -201,7 +201,7 @@
     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 @@
         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 @@
                         "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)",