summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sally Qi <sallyqi@google.com> 2022-03-21 19:30:19 -0700
committer Sally Qi <sallyqi@google.com> 2022-03-30 16:24:02 +0000
commitcf8913451f550f12bf988438f2f3decafe4692a9 (patch)
tree291422ba31cf0dd8b00d6813d1dce43f4c0ef502
parent771ad1e7d185ad5d03dbf6d048d1c4e94c11ce23 (diff)
Disable HDR dimming when screen rotates.
- Disable dimming for screenshot layer This is to fix HDR flicker in picture-in-picture mode. Because the screenshot layer of rotation is an SDR image containing tone-mapping HDR content, and this would cause HDR part to be suddenly dimmed during rotation along with the entire screenshot, even though DisplayManager maintains different HDR and SDR while white points during during rotation animation. Therefore, we add a hidden api to allow to dim a particular layer. This effectively sets the white point for that layer to be same as the display brightness. Then the screenshot with this flag can be used a part of the rotation animation in order to remove flikering effects. Bug: 224860402 Test: check HDR vidoes when rotation Change-Id: Ib5c02635928cb9779e6f7968d2ec0ac9e659420b Merged-In: Ib5c02635928cb9779e6f7968d2ec0ac9e659420b
-rw-r--r--core/java/android/view/SurfaceControl.java23
-rw-r--r--core/jni/android_view_SurfaceControl.cpp11
-rw-r--r--services/core/java/com/android/server/wm/ScreenRotationAnimation.java4
3 files changed, 37 insertions, 1 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index da582c5b4b2f..b5bbc7537391 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -221,6 +221,8 @@ public final class SurfaceControl implements Parcelable {
@DataSpace.NamedDataSpace int dataSpace);
private static native void nativeSetDamageRegion(long transactionObj, long nativeObject,
Region region);
+ private static native void nativeSetDimmingEnabled(long transactionObj, long nativeObject,
+ boolean dimmingEnabled);
private static native void nativeOverrideHdrTypes(IBinder displayToken, int[] modes);
@@ -3838,6 +3840,27 @@ public final class SurfaceControl implements Parcelable {
}
/**
+ * Set if the layer can be dimmed.
+ *
+ * <p>Dimming is to adjust brightness of the layer.
+ * Default value is {@code true}, which means the layer can be dimmed.
+ * Disabling dimming means the brightness of the layer can not be changed, i.e.,
+ * keep the white point for the layer same as the display brightness.</p>
+ *
+ * @param sc The SurfaceControl on which to enable or disable dimming.
+ * @param dimmingEnabled The dimming flag.
+ * @return this.
+ *
+ * @hide
+ */
+ public @NonNull Transaction setDimmingEnabled(@NonNull SurfaceControl sc,
+ boolean dimmingEnabled) {
+ checkPreconditions(sc);
+ nativeSetDimmingEnabled(mNativeObject, sc.mNativeObject, dimmingEnabled);
+ return this;
+ }
+
+ /**
* Set the color space for the SurfaceControl. The supported color spaces are SRGB
* and Display P3, other color spaces will be treated as SRGB. This can only be used for
* SurfaceControls that were created as type {@link #FX_SURFACE_BLAST}
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 39f192b662ee..518fc09dee5a 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -851,6 +851,14 @@ static void nativeSetDamageRegion(JNIEnv* env, jclass clazz, jlong transactionOb
transaction->setSurfaceDamageRegion(surfaceControl, region);
}
+static void nativeSetDimmingEnabled(JNIEnv* env, jclass clazz, jlong transactionObj,
+ jlong nativeObject, jboolean dimmingEnabled) {
+ auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
+
+ SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
+ transaction->setDimmingEnabled(ctrl, dimmingEnabled);
+}
+
static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong transactionObj,
jlong nativeObject, jfloat alpha) {
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2095,8 +2103,9 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetSize },
{"nativeSetTransparentRegionHint", "(JJLandroid/graphics/Region;)V",
(void*)nativeSetTransparentRegionHint },
- { "nativeSetDamageRegion", "(JJLandroid/graphics/Region;)V",
+ {"nativeSetDamageRegion", "(JJLandroid/graphics/Region;)V",
(void*)nativeSetDamageRegion },
+ {"nativeSetDimmingEnabled", "(JJZ)V", (void*)nativeSetDimmingEnabled },
{"nativeSetAlpha", "(JJF)V",
(void*)nativeSetAlpha },
{"nativeSetColor", "(JJ[F)V",
diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
index 6bb63d933353..65ae3fcb4c90 100644
--- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -216,6 +216,10 @@ class ScreenRotationAnimation {
t.setLayer(mScreenshotLayer, SCREEN_FREEZE_LAYER_BASE);
t.reparent(mBackColorSurface, displayContent.getSurfaceControl());
+ // If hdr layers are on-screen, e.g. picture-in-picture mode, the screenshot of
+ // rotation animation is an sdr image containing tone-mapping hdr content, then
+ // disable dimming effect to get avoid of hdr content being dimmed during animation.
+ t.setDimmingEnabled(mScreenshotLayer, false);
t.setLayer(mBackColorSurface, -1);
t.setColor(mBackColorSurface, new float[]{mStartLuma, mStartLuma, mStartLuma});
t.setAlpha(mBackColorSurface, 1);