diff options
| author | Rob Carr <racarr@google.com> | 2019-01-09 21:23:15 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-01-09 21:23:15 +0000 |
| commit | c9fd5fc46bcfaa6f13b21975cd5346dfd593d19b (patch) | |
| tree | bdcb46e6ac0c026a692b17ad4a97340d5bb2a513 /core/java/android | |
| parent | 972da3c7a350414b57776f1909cea5b72f9eb750 (diff) | |
| parent | 8810b69fc483456df1cb3ca465f6e88099b17db7 (diff) | |
Merge changes from topic "sf-remove-remove-layer"
* changes:
SurfaceFlinger: Remove removeLayer
Fix memory leak in SurfaceControl#copyFrom
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 0b6beba06555..acad5d76f0b5 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -158,7 +158,6 @@ public class SurfaceControl implements Parcelable { private static native void nativeSeverChildren(long transactionObj, long nativeObject); private static native void nativeSetOverrideScalingMode(long transactionObj, long nativeObject, int scalingMode); - private static native void nativeDestroy(long transactionObj, long nativeObject); private static native IBinder nativeGetHandle(long nativeObject); private static native boolean nativeGetTransformToDisplayInverse(long nativeObject); @@ -360,11 +359,18 @@ public class SurfaceControl implements Parcelable { */ public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731; + private void assignNativeObject(long nativeObject) { + if (mNativeObject != 0) { + release(); + } + mNativeObject = nativeObject; + } + public void copyFrom(SurfaceControl other) { mName = other.mName; mWidth = other.mWidth; mHeight = other.mHeight; - mNativeObject = nativeCopyFromSurfaceControl(other.mNativeObject); + assignNativeObject(nativeCopyFromSurfaceControl(other.mNativeObject)); } /** @@ -685,12 +691,11 @@ public class SurfaceControl implements Parcelable { mWidth = in.readInt(); mHeight = in.readInt(); - release(); + long object = 0; if (in.readInt() != 0) { - mNativeObject = nativeReadFromParcel(in); - } else { - mNativeObject = 0; + object = nativeReadFromParcel(in); } + assignNativeObject(object); } @Override @@ -1765,30 +1770,6 @@ public class SurfaceControl implements Parcelable { return this; } - /** - * Same as {@link #destroy()} except this is invoked in a transaction instead of - * immediately. - */ - public Transaction destroy(SurfaceControl sc) { - sc.checkNotReleased(); - - /** - * Perhaps it's safer to transfer the close guard to the Transaction - * but then we have a whole wonky scenario regarding merging, multiple - * close-guards per transaction etc...the whole scenario is kind of wonky - * and it seems really we'd like to just be able to call release here - * but the WindowManager has some code that looks like - * --- destroyInTransaction(a) - * --- reparentChildrenInTransaction(a) - * so we need to ensure the SC remains valid until the transaction - * is applied. - */ - sc.mCloseGuard.close(); - - nativeDestroy(mNativeObject, sc.mNativeObject); - return this; - } - public Transaction setDisplaySurface(IBinder displayToken, Surface surface) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); |
