Merge "[sf] Release the currently presented buffer when setBuffer is called with null" into udc-dev
This commit is contained in:
@@ -220,6 +220,7 @@ public final class SurfaceControl implements Parcelable {
|
||||
long newParentNativeObject);
|
||||
private static native void nativeSetBuffer(long transactionObj, long nativeObject,
|
||||
HardwareBuffer buffer, long fencePtr, Consumer<SyncFence> releaseCallback);
|
||||
private static native void nativeUnsetBuffer(long transactionObj, long nativeObject);
|
||||
private static native void nativeSetBufferTransform(long transactionObj, long nativeObject,
|
||||
int transform);
|
||||
private static native void nativeSetDataSpace(long transactionObj, long nativeObject,
|
||||
@@ -3663,6 +3664,22 @@ public final class SurfaceControl implements Parcelable {
|
||||
return setBuffer(sc, buffer, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets the buffer for the SurfaceControl in the current Transaction. This will not clear
|
||||
* the buffer being rendered, but resets the buffer state in the Transaction only. The call
|
||||
* will also invoke the release callback.
|
||||
*
|
||||
* Note, this call is different from passing a null buffer to
|
||||
* {@link SurfaceControl.Transaction#setBuffer} which will release the last displayed
|
||||
* buffer.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public Transaction unsetBuffer(SurfaceControl sc) {
|
||||
nativeUnsetBuffer(mNativeObject, sc.mNativeObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the HardwareBuffer displayed for the SurfaceControl.
|
||||
*
|
||||
@@ -3682,7 +3699,8 @@ public final class SurfaceControl implements Parcelable {
|
||||
* until all presentation fences have signaled, ensuring the transaction remains consistent.
|
||||
*
|
||||
* @param sc The SurfaceControl to update
|
||||
* @param buffer The buffer to be displayed
|
||||
* @param buffer The buffer to be displayed. Pass in a null buffer to release the last
|
||||
* displayed buffer.
|
||||
* @param fence The presentation fence. If null or invalid, this is equivalent to
|
||||
* {@link #setBuffer(SurfaceControl, HardwareBuffer)}
|
||||
* @return this
|
||||
|
||||
@@ -616,6 +616,12 @@ static void nativeSetBuffer(JNIEnv* env, jclass clazz, jlong transactionObj, jlo
|
||||
genReleaseCallback(env, releaseCallback));
|
||||
}
|
||||
|
||||
static void nativeUnsetBuffer(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject) {
|
||||
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
|
||||
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
|
||||
transaction->unsetBuffer(ctrl);
|
||||
}
|
||||
|
||||
static void nativeSetBufferTransform(JNIEnv* env, jclass clazz, jlong transactionObj,
|
||||
jlong nativeObject, jint transform) {
|
||||
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
|
||||
@@ -2198,6 +2204,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
(void*)nativeSetGeometry },
|
||||
{"nativeSetBuffer", "(JJLandroid/hardware/HardwareBuffer;JLjava/util/function/Consumer;)V",
|
||||
(void*)nativeSetBuffer },
|
||||
{"nativeUnsetBuffer", "(JJ)V", (void*)nativeUnsetBuffer },
|
||||
|
||||
{"nativeSetBufferTransform", "(JJI)V", (void*) nativeSetBufferTransform},
|
||||
{"nativeSetDataSpace", "(JJI)V",
|
||||
(void*)nativeSetDataSpace },
|
||||
|
||||
@@ -5634,7 +5634,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
private void dropBufferFrom(Transaction t) {
|
||||
SurfaceControl viewSurface = getClientViewRootSurface();
|
||||
if (viewSurface == null) return;
|
||||
t.setBuffer(viewSurface, (android.hardware.HardwareBuffer) null);
|
||||
t.unsetBuffer(viewSurface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user