Plumb getOverlaySupport() into Display Manager for HWUI.
- HWUI can understand if Fp16 for HDR can be supported.
Bug: 242588489
Test: builds
Change-Id: I603ded84a5fbe6142afd167224903cf4010a309f
diff --git a/core/java/android/hardware/OverlayProperties.java b/core/java/android/hardware/OverlayProperties.java
new file mode 100644
index 0000000..2a0956b
--- /dev/null
+++ b/core/java/android/hardware/OverlayProperties.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware;
+
+import java.util.List;
+
+/**
+ * // TODO(b/242588489): Continue work, the class needs a jni-specific constructor and DisplayInfo
+ * // side constructs the object.
+ *
+ * @hide
+ */
+public final class OverlayProperties {
+ private final SupportedBufferCombinations[] mCombinations = null;
+ private final boolean mSupportFp16ForHdr = false;
+
+ static class SupportedBufferCombinations {
+ @HardwareBuffer.Format List<Integer> mHardwareBufferFormats;
+ @DataSpace.NamedDataSpace List<Integer> mDataSpaces;
+ SupportedBufferCombinations(@HardwareBuffer.Format List<Integer> hardwareBufferFormats,
+ @DataSpace.NamedDataSpace List<Integer> dataSpaces) {
+ mHardwareBufferFormats = hardwareBufferFormats;
+ mDataSpaces = dataSpaces;
+ }
+ }
+
+ /***
+ * @return if the device can support fp16.
+ */
+ public boolean supportFp16ForHdr() {
+ return mSupportFp16ForHdr;
+ }
+}
diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java
index 9294dea..79223f5 100644
--- a/core/java/android/hardware/display/DisplayManagerGlobal.java
+++ b/core/java/android/hardware/display/DisplayManagerGlobal.java
@@ -32,6 +32,7 @@
import android.content.res.Resources;
import android.graphics.ColorSpace;
import android.graphics.Point;
+import android.hardware.OverlayProperties;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.graphics.common.DisplayDecorationSupport;
import android.media.projection.IMediaProjection;
@@ -112,6 +113,7 @@
private final SparseArray<DisplayInfo> mDisplayInfoCache = new SparseArray<>();
private final ColorSpace mWideColorSpace;
+ private final OverlayProperties mOverlayProperties = new OverlayProperties();
private int[] mDisplayIdCache;
private int mWifiDisplayScanNestCount;
@@ -726,6 +728,11 @@
return mWideColorSpace;
}
+ /** @hide */
+ public OverlayProperties getOverlaySupport() {
+ return mOverlayProperties;
+ }
+
/**
* Sets the global brightness configuration for a given user.
*
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 21c615c..7199e57 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -36,6 +36,7 @@
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
+import android.hardware.OverlayProperties;
import android.hardware.display.BrightnessInfo;
import android.hardware.display.DeviceProductInfo;
import android.hardware.display.DisplayManager;
@@ -1290,6 +1291,18 @@
}
}
+ /** @hide */
+ @Nullable
+ public OverlayProperties getOverlaySupport() {
+ synchronized (mLock) {
+ updateDisplayInfoLocked();
+ if (mDisplayInfo.type != TYPE_VIRTUAL) {
+ return mGlobal.getOverlaySupport();
+ }
+ return new OverlayProperties();
+ }
+ }
+
/**
* Gets the supported color modes of this device.
* @hide
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java
index c6731d1..48dd3e6 100644
--- a/graphics/java/android/graphics/HardwareRenderer.java
+++ b/graphics/java/android/graphics/HardwareRenderer.java
@@ -1347,7 +1347,8 @@
nInitDisplayInfo(largestWidth, largestHeight, defaultDisplay.getRefreshRate(),
wideColorDataspace, defaultDisplay.getAppVsyncOffsetNanos(),
- defaultDisplay.getPresentationDeadlineNanos());
+ defaultDisplay.getPresentationDeadlineNanos(),
+ defaultDisplay.getOverlaySupport().supportFp16ForHdr());
mDisplayInitialized = true;
}
@@ -1527,7 +1528,8 @@
private static native void nSetDisplayDensityDpi(int densityDpi);
private static native void nInitDisplayInfo(int width, int height, float refreshRate,
- int wideColorDataspace, long appVsyncOffsetNanos, long presentationDeadlineNanos);
+ int wideColorDataspace, long appVsyncOffsetNanos, long presentationDeadlineNanos,
+ boolean supportsFp16ForHdr);
private static native void nSetDrawingEnabled(boolean drawingEnabled);
diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp
index f06fa24..0240c86 100644
--- a/libs/hwui/DeviceInfo.cpp
+++ b/libs/hwui/DeviceInfo.cpp
@@ -104,6 +104,10 @@
}
}
+void DeviceInfo::setSupportFp16ForHdr(bool supportFp16ForHdr) {
+ get()->mSupportFp16ForHdr = supportFp16ForHdr;
+}
+
void DeviceInfo::onRefreshRateChanged(int64_t vsyncPeriod) {
mVsyncPeriod = vsyncPeriod;
}
diff --git a/libs/hwui/DeviceInfo.h b/libs/hwui/DeviceInfo.h
index 2e6e36a..577780b 100644
--- a/libs/hwui/DeviceInfo.h
+++ b/libs/hwui/DeviceInfo.h
@@ -59,6 +59,9 @@
}
static void setWideColorDataspace(ADataSpace dataspace);
+ static void setSupportFp16ForHdr(bool supportFp16ForHdr);
+ static bool isSupportFp16ForHdr() { return get()->mSupportFp16ForHdr; };
+
// this value is only valid after the GPU has been initialized and there is a valid graphics
// context or if you are using the HWUI_NULL_GPU
int maxTextureSize() const;
@@ -88,6 +91,7 @@
int mMaxTextureSize;
sk_sp<SkColorSpace> mWideColorSpace = SkColorSpace::MakeSRGB();
+ bool mSupportFp16ForHdr = false;
SkColorType mWideColorType = SkColorType::kN32_SkColorType;
int mDisplaysSize = 0;
int mPhysicalDisplayIndex = -1;
diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
index 704fba9..f603e23 100644
--- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
@@ -867,17 +867,19 @@
DeviceInfo::setDensity(density);
}
-static void android_view_ThreadedRenderer_initDisplayInfo(JNIEnv*, jclass, jint physicalWidth,
+static void android_view_ThreadedRenderer_initDisplayInfo(JNIEnv* env, jclass, jint physicalWidth,
jint physicalHeight, jfloat refreshRate,
jint wideColorDataspace,
jlong appVsyncOffsetNanos,
- jlong presentationDeadlineNanos) {
+ jlong presentationDeadlineNanos,
+ jboolean supportFp16ForHdr) {
DeviceInfo::setWidth(physicalWidth);
DeviceInfo::setHeight(physicalHeight);
DeviceInfo::setRefreshRate(refreshRate);
DeviceInfo::setWideColorDataspace(static_cast<ADataSpace>(wideColorDataspace));
DeviceInfo::setAppVsyncOffsetNanos(appVsyncOffsetNanos);
DeviceInfo::setPresentationDeadlineNanos(presentationDeadlineNanos);
+ DeviceInfo::setSupportFp16ForHdr(supportFp16ForHdr);
}
static void android_view_ThreadedRenderer_setDrawingEnabled(JNIEnv*, jclass, jboolean enabled) {
@@ -1027,7 +1029,7 @@
{"nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark},
{"nSetDisplayDensityDpi", "(I)V",
(void*)android_view_ThreadedRenderer_setDisplayDensityDpi},
- {"nInitDisplayInfo", "(IIFIJJ)V", (void*)android_view_ThreadedRenderer_initDisplayInfo},
+ {"nInitDisplayInfo", "(IIFIJJZ)V", (void*)android_view_ThreadedRenderer_initDisplayInfo},
{"preload", "()V", (void*)android_view_ThreadedRenderer_preload},
{"isWebViewOverlaysEnabled", "()Z",
(void*)android_view_ThreadedRenderer_isWebViewOverlaysEnabled},