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

Commit 4a6db046 authored by Dohyun Lee's avatar Dohyun Lee Committed by Steve Kondik
Browse files

DimLayer : remove unnecessary surface transaction calls



There is the case that adjustSurface()  get called even if
the size of the surface of DimLayer is not changed actually.
Since changing the size of a surface is processed synchronously
in the SurfacFlinger, there is usually a few milliseconds delay
(up to 1 vsync interval) when we launch an application.
This patch avoids such cases.

Change-Id: Ib1f76d54f9f2364ac54b70120e4b781e8534e750
Signed-off-by: default avatarDohyun Lee <dohyun.lee@lge.com>
parent b9510123
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -140,10 +140,9 @@ public class DimLayer {
    }

    /**
     * @param layer The new layer value.
     * @param inTransaction Whether the call is made within a surface transaction.
     * NOTE: Must be called with Surface transaction open.
     */
    void adjustSurface(int layer, boolean inTransaction) {
    private void adjustBounds() {
        final int dw, dh;
        final float xPos, yPos;
        if (!mStack.isFullscreen()) {
@@ -163,29 +162,31 @@ public class DimLayer {
            yPos = -1 * dh / 6;
        }

        mDimSurface.setPosition(xPos, yPos);
        mDimSurface.setSize(dw, dh);

        mLastBounds.set(mBounds);
    }

    /**
     * @param bounds The new bounds to set
     * @param inTransaction Whether the call is made within a surface transaction.
     */
    void setBounds(Rect bounds, boolean inTransaction) {
        mBounds.set(bounds);
        if (isDimming() && !mLastBounds.equals(bounds)) {
            try {
                if (!inTransaction) {
                    SurfaceControl.openTransaction();
                }
            mDimSurface.setPosition(xPos, yPos);
            mDimSurface.setSize(dw, dh);
            mDimSurface.setLayer(layer);
                adjustBounds();
            } catch (RuntimeException e) {
            Slog.w(TAG, "Failure setting size or layer", e);
                Slog.w(TAG, "Failure setting size", e);
            } finally {
                if (!inTransaction) {
                    SurfaceControl.closeTransaction();
                }
            }
        mLastBounds.set(mBounds);
        mLayer = layer;
    }

    // Assumes that surface transactions are currently closed.
    void setBounds(Rect bounds) {
        mBounds.set(bounds);
        if (isDimming() && !mLastBounds.equals(bounds)) {
            adjustSurface(mLayer, false);
        }
    }

@@ -224,9 +225,10 @@ public class DimLayer {
            return;
        }

        if (!mLastBounds.equals(mBounds) || mLayer != layer) {
            adjustSurface(layer, true);
        if (!mLastBounds.equals(mBounds)) {
            adjustBounds();
        }
        setLayer(layer);

        long curTime = SystemClock.uptimeMillis();
        final boolean animating = isAnimating();
+2 −2
Original line number Diff line number Diff line
@@ -132,8 +132,8 @@ public class TaskStack {
            return false;
        }

        mDimLayer.setBounds(bounds);
        mAnimationBackgroundSurface.setBounds(bounds);
        mDimLayer.setBounds(bounds, false);
        mAnimationBackgroundSurface.setBounds(bounds, false);
        mBlurLayer.setBounds(bounds);
        mBounds.set(bounds);