Merge "Extend setBrightness to pass SDR & HDR info" into sc-dev
This commit is contained in:
@@ -200,7 +200,8 @@ public final class SurfaceControl implements Parcelable {
|
||||
private static native void nativeSyncInputWindows(long transactionObj);
|
||||
private static native boolean nativeGetDisplayBrightnessSupport(IBinder displayToken);
|
||||
private static native boolean nativeSetDisplayBrightness(IBinder displayToken,
|
||||
float brightness);
|
||||
float sdrBrightness, float sdrBrightnessNits, float displayBrightness,
|
||||
float displayBrightnessNits);
|
||||
private static native long nativeReadTransactionFromParcel(Parcel in);
|
||||
private static native void nativeWriteTransactionToParcel(long nativeObject, Parcel out);
|
||||
private static native void nativeSetShadowRadius(long transactionObj, long nativeObject,
|
||||
@@ -2405,13 +2406,50 @@ public final class SurfaceControl implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
public static boolean setDisplayBrightness(IBinder displayToken, float brightness) {
|
||||
return setDisplayBrightness(displayToken, brightness, -1, brightness, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of a display.
|
||||
*
|
||||
* @param displayToken
|
||||
* The token for the display whose brightness is set.
|
||||
* @param sdrBrightness
|
||||
* A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or -1.0f to
|
||||
* turn the backlight off. Specifies the desired brightness of SDR content.
|
||||
* @param sdrBrightnessNits
|
||||
* The value of sdrBrightness converted to calibrated nits. -1 if this isn't available.
|
||||
* @param displayBrightness
|
||||
* A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or
|
||||
* -1.0f to turn the backlight off. Specifies the desired brightness of the display itself,
|
||||
* used directly for HDR content.
|
||||
* @param displayBrightnessNits
|
||||
* The value of displayBrightness converted to calibrated nits. -1 if this isn't
|
||||
* available.
|
||||
*
|
||||
* @return Whether the method succeeded or not.
|
||||
*
|
||||
* @throws IllegalArgumentException if:
|
||||
* - displayToken is null;
|
||||
* - brightness is NaN or greater than 1.0f.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean setDisplayBrightness(IBinder displayToken, float sdrBrightness,
|
||||
float sdrBrightnessNits, float displayBrightness, float displayBrightnessNits) {
|
||||
Objects.requireNonNull(displayToken);
|
||||
if (Float.isNaN(brightness) || brightness > 1.0f
|
||||
|| (brightness < 0.0f && brightness != -1.0f)) {
|
||||
throw new IllegalArgumentException("brightness must be a number between 0.0f and 1.0f,"
|
||||
+ " or -1 to turn the backlight off: " + brightness);
|
||||
if (Float.isNaN(displayBrightness) || displayBrightness > 1.0f
|
||||
|| (displayBrightness < 0.0f && displayBrightness != -1.0f)) {
|
||||
throw new IllegalArgumentException("displayBrightness must be a number between 0.0f "
|
||||
+ " and 1.0f, or -1 to turn the backlight off: " + displayBrightness);
|
||||
}
|
||||
return nativeSetDisplayBrightness(displayToken, brightness);
|
||||
if (Float.isNaN(sdrBrightness) || sdrBrightness > 1.0f
|
||||
|| (sdrBrightness < 0.0f && sdrBrightness != -1.0f)) {
|
||||
throw new IllegalArgumentException("sdrBrightness must be a number between 0.0f "
|
||||
+ "and 1.0f, or -1 to turn the backlight off: " + displayBrightness);
|
||||
}
|
||||
return nativeSetDisplayBrightness(displayToken, sdrBrightness, sdrBrightnessNits,
|
||||
displayBrightness, displayBrightnessNits);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1528,11 +1528,17 @@ static jboolean nativeGetDisplayBrightnessSupport(JNIEnv* env, jclass clazz,
|
||||
}
|
||||
|
||||
static jboolean nativeSetDisplayBrightness(JNIEnv* env, jclass clazz, jobject displayTokenObject,
|
||||
jfloat brightness) {
|
||||
jfloat sdrBrightness, jfloat sdrBrightnessNits,
|
||||
jfloat displayBrightness, jfloat displayBrightnessNits) {
|
||||
sp<IBinder> displayToken(ibinderForJavaObject(env, displayTokenObject));
|
||||
if (displayToken == nullptr) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
gui::DisplayBrightness brightness;
|
||||
brightness.sdrWhitePoint = sdrBrightness;
|
||||
brightness.sdrWhitePointNits = sdrBrightnessNits;
|
||||
brightness.displayBrightness = displayBrightness;
|
||||
brightness.displayBrightnessNits = displayBrightnessNits;
|
||||
status_t error = SurfaceComposerClient::setDisplayBrightness(displayToken, brightness);
|
||||
return error == OK ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
@@ -1860,7 +1866,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
(void*)nativeSyncInputWindows },
|
||||
{"nativeGetDisplayBrightnessSupport", "(Landroid/os/IBinder;)Z",
|
||||
(void*)nativeGetDisplayBrightnessSupport },
|
||||
{"nativeSetDisplayBrightness", "(Landroid/os/IBinder;F)Z",
|
||||
{"nativeSetDisplayBrightness", "(Landroid/os/IBinder;FFFF)Z",
|
||||
(void*)nativeSetDisplayBrightness },
|
||||
{"nativeReadTransactionFromParcel", "(Landroid/os/Parcel;)J",
|
||||
(void*)nativeReadTransactionFromParcel },
|
||||
|
||||
Reference in New Issue
Block a user