Add a flag that excludes a SurfaceControl from caching
This is a private api, intended for some system layers that may need to be excluded from surfaceflinger caching on devices that support it. Bug: 259311918 Test: Test app and inspect planner state Change-Id: If964dd6c095ab2971f6690a9882e890061bf9765
This commit is contained in:
@@ -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();
|
||||
@@ -3880,6 +3906,23 @@ public final class SurfaceControl implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user