Plumb getOverlaySupport() into Display Manager for HWUI.
- HWUI can understand if Fp16 for HDR can be supported. Bug: 242588489 Test: builds Change-Id: I603ded84a5fbe6142afd167224903cf4010a309f
This commit is contained in:
47
core/java/android/hardware/OverlayProperties.java
Normal file
47
core/java/android/hardware/OverlayProperties.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user