diff options
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 43 | ||||
| -rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 9 |
2 files changed, 52 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index a99766f36ee4..4895aed60a3a 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -226,6 +226,9 @@ public final class SurfaceControl implements Parcelable { @DataSpace.NamedDataSpace int dataSpace); private static native void nativeSetExtendedRangeBrightness(long transactionObj, long nativeObject, float currentBufferRatio, float desiredRatio); + + private static native void nativeSetCachingHint(long transactionObj, + long nativeObject, int cachingHint); private static native void nativeSetDamageRegion(long transactionObj, long nativeObject, Region region); private static native void nativeSetDimmingEnabled(long transactionObj, long nativeObject, @@ -742,6 +745,29 @@ public final class SurfaceControl implements Parcelable { */ public static final int POWER_MODE_ON_SUSPEND = 4; + /** + * Hint that this SurfaceControl should not participate in layer caching within SurfaceFlinger. + * + * A system layer may request that a layer does not participate in caching when there are known + * quality limitations when caching via the compositor's GPU path. + * Use only with {@link SurfaceControl.Transaction#setCachingHint}. + * @hide + */ + public static final int CACHING_DISABLED = 0; + + /** + * Hint that this SurfaceControl should participate in layer caching within SurfaceFlinger. + * + * Use only with {@link SurfaceControl.Transaction#setCachingHint}. + * @hide + */ + public static final int CACHING_ENABLED = 1; + + /** @hide */ + @IntDef(flag = true, value = {CACHING_DISABLED, CACHING_ENABLED}) + @Retention(RetentionPolicy.SOURCE) + public @interface CachingHint {} + private void assignNativeObject(long nativeObject, String callsite) { if (mNativeObject != 0) { release(); @@ -3881,6 +3907,23 @@ public final class SurfaceControl implements Parcelable { } /** + * Sets the caching hint for the layer. By default, the caching hint is + * {@link CACHING_ENABLED}. + * + * @param sc The SurfaceControl to update + * @param cachingHint The caching hint to apply to the SurfaceControl. The CachingHint is + * not applied to any children of this SurfaceControl. + * @return this + * @hide + */ + public @NonNull Transaction setCachingHint( + @NonNull SurfaceControl sc, @CachingHint int cachingHint) { + checkPreconditions(sc); + nativeSetCachingHint(mNativeObject, sc.mNativeObject, cachingHint); + return this; + } + + /** * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the * children. The caller must hold the ACCESS_SURFACE_FLINGER permission. * @hide diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index d2d87d6916d2..03d6eece61e6 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -639,6 +639,13 @@ static void nativeSetExtendedRangeBrightness(JNIEnv* env, jclass clazz, jlong tr transaction->setExtendedRangeBrightness(ctrl, currentBufferRatio, desiredRatio); } +static void nativeSetCachingHint(JNIEnv* env, jclass clazz, jlong transactionObj, + jlong nativeObject, jint cachingHint) { + auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); + transaction->setCachingHint(ctrl, static_cast<gui::CachingHint>(cachingHint)); +} + static void nativeSetBlurRegions(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobjectArray regions, jint regionsLength) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); @@ -2204,6 +2211,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDataSpace }, {"nativeSetExtendedRangeBrightness", "(JJFF)V", (void*)nativeSetExtendedRangeBrightness }, + {"nativeSetCachingHint", "(JJI)V", + (void*)nativeSetCachingHint }, {"nativeAddWindowInfosReportedListener", "(JLjava/lang/Runnable;)V", (void*)nativeAddWindowInfosReportedListener }, {"nativeGetDisplayBrightnessSupport", "(Landroid/os/IBinder;)Z", |