diff options
-rw-r--r-- | core/java/android/hardware/OverlayProperties.java | 47 | ||||
-rw-r--r-- | core/java/android/hardware/display/DisplayManagerGlobal.java | 7 | ||||
-rw-r--r-- | core/java/android/view/Display.java | 13 | ||||
-rw-r--r-- | graphics/java/android/graphics/HardwareRenderer.java | 6 | ||||
-rw-r--r-- | libs/hwui/DeviceInfo.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/DeviceInfo.h | 4 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_HardwareRenderer.cpp | 8 |
7 files changed, 84 insertions, 5 deletions
diff --git a/core/java/android/hardware/OverlayProperties.java b/core/java/android/hardware/OverlayProperties.java new file mode 100644 index 000000000000..2a0956b47a7b --- /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 9294dea50b0d..79223f5d2414 100644 --- a/core/java/android/hardware/display/DisplayManagerGlobal.java +++ b/core/java/android/hardware/display/DisplayManagerGlobal.java @@ -32,6 +32,7 @@ import android.content.pm.ParceledListSlice; 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 @@ public final class DisplayManagerGlobal { 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 @@ public final class DisplayManagerGlobal { 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 21c615c26879..7199e57e7970 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -36,6 +36,7 @@ import android.graphics.ColorSpace; 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 @@ public final class Display { } } + /** @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 c6731d112b93..48dd3e6c451b 100644 --- a/graphics/java/android/graphics/HardwareRenderer.java +++ b/graphics/java/android/graphics/HardwareRenderer.java @@ -1347,7 +1347,8 @@ public class HardwareRenderer { nInitDisplayInfo(largestWidth, largestHeight, defaultDisplay.getRefreshRate(), wideColorDataspace, defaultDisplay.getAppVsyncOffsetNanos(), - defaultDisplay.getPresentationDeadlineNanos()); + defaultDisplay.getPresentationDeadlineNanos(), + defaultDisplay.getOverlaySupport().supportFp16ForHdr()); mDisplayInitialized = true; } @@ -1527,7 +1528,8 @@ public class HardwareRenderer { 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 f06fa2418003..0240c86d5f45 100644 --- a/libs/hwui/DeviceInfo.cpp +++ b/libs/hwui/DeviceInfo.cpp @@ -104,6 +104,10 @@ void DeviceInfo::setWideColorDataspace(ADataSpace dataspace) { } } +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 2e6e36a9ff22..577780bbb5e0 100644 --- a/libs/hwui/DeviceInfo.h +++ b/libs/hwui/DeviceInfo.h @@ -59,6 +59,9 @@ public: } 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 @@ private: 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 704fba9241b6..f603e231e49b 100644 --- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp +++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp @@ -867,17 +867,19 @@ static void android_view_ThreadedRenderer_setDisplayDensityDpi(JNIEnv*, jclass, 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 @@ static const JNINativeMethod gMethods[] = { {"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}, |