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

Commit de688c1b authored by Jorge Gil's avatar Jorge Gil
Browse files

Add traces for Desktop Windowing decorations

Bug: 335975211
Test: m
Change-Id: I01b5b85bf33ab4fb859198e0f2f53f744f340d70
parent 7ae46c6a
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Trace;
import android.util.Log;
import android.util.Size;
import android.view.Choreographer;
@@ -158,7 +159,9 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        mSyncQueue = syncQueue;
        mRootTaskDisplayAreaOrganizer = rootTaskDisplayAreaOrganizer;

        Trace.beginSection("DesktopModeWindowDecoration#loadAppInfo");
        loadAppInfo();
        Trace.endSection();
    }

    void setCaptionListeners(
@@ -204,6 +207,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    void relayout(ActivityManager.RunningTaskInfo taskInfo,
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskPositionAndCrop) {
        Trace.beginSection("DesktopModeWindowDecoration#relayout");
        if (isHandleMenuActive()) {
            mHandleMenu.relayout(startT);
        }
@@ -215,16 +219,22 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
        final WindowContainerTransaction wct = new WindowContainerTransaction();

        Trace.beginSection("DesktopModeWindowDecoration#relayout-inner");
        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        Trace.endSection();
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo

        Trace.beginSection("DesktopModeWindowDecoration#relayout-applyWCT");
        mTaskOrganizer.applyTransaction(wct);
        Trace.endSection();

        if (mResult.mRootView == null) {
            // This means something blocks the window decor from showing, e.g. the task is hidden.
            // Nothing is set up in this case including the decoration surface.
            Trace.endSection(); // DesktopModeWindowDecoration#relayout
            return;
        }

        if (oldRootView != mResult.mRootView) {
            if (mRelayoutParams.mLayoutResId == R.layout.desktop_mode_focused_window_decor) {
                mWindowDecorViewHolder = new DesktopModeFocusedWindowDecorationViewHolder(
@@ -252,7 +262,9 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                throw new IllegalArgumentException("Unexpected layout resource id");
            }
        }
        Trace.beginSection("DesktopModeWindowDecoration#relayout-binding");
        mWindowDecorViewHolder.bindData(mTaskInfo);
        Trace.endSection();

        if (!mTaskInfo.isFocused) {
            closeHandleMenu();
@@ -268,11 +280,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                updateExclusionRegion();
            }
            closeDragResizeListener();
            Trace.endSection(); // DesktopModeWindowDecoration#relayout
            return;
        }

        if (oldDecorationSurface != mDecorationContainerSurface || mDragResizeListener == null) {
            closeDragResizeListener();
            Trace.beginSection("DesktopModeWindowDecoration#relayout-DragResizeInputListener");
            mDragResizeListener = new DragResizeInputListener(
                    mContext,
                    mHandler,
@@ -283,6 +297,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                    mSurfaceControlBuilderSupplier,
                    mSurfaceControlTransactionSupplier,
                    mDisplayController);
            Trace.endSection();
        }

        final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
@@ -307,6 +322,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                mMaximizeMenu.positionMenu(calculateMaximizeMenuPosition(), startT);
            }
        }
        Trace.endSection(); // DesktopModeWindowDecoration#relayout
    }

    @VisibleForTesting
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Trace;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.SurfaceControl;
@@ -135,6 +136,7 @@ public class ResizeVeil {
            // Display may not be available yet, skip this until then.
            return;
        }
        Trace.beginSection("ResizeVeil#setupResizeVeil");
        mVeilSurface = mSurfaceControlBuilderFactory
                .create("Resize veil of Task=" + mTaskInfo.taskId)
                .setContainerLayer()
@@ -179,6 +181,7 @@ public class ResizeVeil {

        mViewHost = mSurfaceControlViewHostFactory.create(mContext, mDisplay, wwm, "ResizeVeil");
        mViewHost.setView(root, lp);
        Trace.endSection();
    }

    private boolean obtainDisplayOrRegisterListener() {
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.os.Trace;
import android.view.Display;
import android.view.InsetsSource;
import android.view.InsetsState;
@@ -378,6 +379,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            startT.unsetColor(mTaskSurface);
        }

        Trace.beginSection("CaptionViewHostLayout");
        if (mCaptionWindowManager == null) {
            // Put caption under a container surface because ViewRootImpl sets the destination frame
            // of windowless window layers and BLASTBufferQueue#update() doesn't support offset.
@@ -412,6 +414,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            }
            mViewHost.relayout(lp);
        }
        Trace.endSection(); // CaptionViewHostLayout
    }

    private Rect calculateBoundingRect(@NonNull OccludingCaptionElement element,