Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5b56774 authored by Winson Chung's avatar Winson Chung
Browse files

Skip some unnecessary allocations

- Move new matrix/rect construction to if the param is set on the
  builder, we only apply the params if the flags are set anyways
  and if the caller doesn't set those params then we are allocating
  new objects unnecessarily
- Always recycle motion event

Bug: 183756396
Test: Take memory profile when dragging pip
Change-Id: Ie7457c8c508ee61bd27daeebe486c39a5cebe7d7
parent bbf0d298
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class SyncRtSurfaceTransactionApplier {
             * @return this Builder
             */
            public Builder withMatrix(Matrix matrix) {
                this.matrix = matrix;
                this.matrix = new Matrix(matrix);
                flags |= FLAG_MATRIX;
                return this;
            }
@@ -201,7 +201,7 @@ public class SyncRtSurfaceTransactionApplier {
             * @return this Builder
             */
            public Builder withWindowCrop(Rect windowCrop) {
                this.windowCrop = windowCrop;
                this.windowCrop = new Rect(windowCrop);
                flags |= FLAG_WINDOW_CROP;
                return this;
            }
@@ -272,8 +272,8 @@ public class SyncRtSurfaceTransactionApplier {
            this.flags = params;
            this.surface = surface;
            this.alpha = alpha;
            this.matrix = new Matrix(matrix);
            this.windowCrop = new Rect(windowCrop);
            this.matrix = matrix;
            this.windowCrop = windowCrop;
            this.layer = layer;
            this.cornerRadius = cornerRadius;
            this.backgroundBlurRadius = backgroundBlurRadius;
+1 −0
Original line number Diff line number Diff line
@@ -625,6 +625,7 @@ public class PipTouchHandler {
            }

            mMenuController.handlePointerEvent(cloneEvent);
            cloneEvent.recycle();
        }

        return true;
+4 −4
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
             * @return this Builder
             */
            public Builder withMatrix(Matrix matrix) {
                this.matrix = matrix;
                this.matrix = new Matrix(matrix);
                flags |= FLAG_MATRIX;
                return this;
            }
@@ -241,7 +241,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
             * @return this Builder
             */
            public Builder withWindowCrop(Rect windowCrop) {
                this.windowCrop = windowCrop;
                this.windowCrop = new Rect(windowCrop);
                flags |= FLAG_WINDOW_CROP;
                return this;
            }
@@ -324,8 +324,8 @@ public class SyncRtSurfaceTransactionApplierCompat {
            this.flags = flags;
            this.surface = surface;
            this.alpha = alpha;
            this.matrix = new Matrix(matrix);
            this.windowCrop = windowCrop != null ? new Rect(windowCrop) : null;
            this.matrix = matrix;
            this.windowCrop = windowCrop;
            this.layer = layer;
            this.relativeTo = relativeTo;
            this.relativeLayer = relativeLayer;