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

Commit 987eb1ca authored by chaviw's avatar chaviw
Browse files

Ensure opacity is update on the VRI SC when format changes

Opacity is set based on format change. Previously, WMS would recreate
the surface when the format was changed and set the new opacity.
However, since ag/13348893, format changes no longer recreate a surface.
Therefore, we also need to update the opacity flag when format is
changed in VRI.

Test: Play video from camera app
Fixes: 178062437
Change-Id: I3160a555bff24ab910235eaef9118d3aeed59355
parent 352d5a43
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -666,6 +666,8 @@ public final class ViewRootImpl implements ViewParent,

    private ScrollCaptureConnection mScrollCaptureConnection;

    private boolean mIsSurfaceOpaque;

    private final BackgroundBlurDrawable.Aggregator mBlurRegionAggregator =
            new BackgroundBlurDrawable.Aggregator(this);

@@ -2716,6 +2718,14 @@ public final class ViewRootImpl implements ViewParent,
                    mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED;
                }
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
                final boolean freeformResizing = (relayoutResult
                        & WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_FREEFORM) != 0;
                final boolean dockedResizing = (relayoutResult
                        & WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
                final boolean dragResizing = freeformResizing || dockedResizing;
                if (mSurfaceControl.isValid()) {
                    updateOpacity(params, dragResizing);
                }

                if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString()
                        + " surface=" + mSurface);
@@ -2840,11 +2850,6 @@ public final class ViewRootImpl implements ViewParent,
                    notifySurfaceReplaced();
                }

                final boolean freeformResizing = (relayoutResult
                        & WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_FREEFORM) != 0;
                final boolean dockedResizing = (relayoutResult
                        & WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
                final boolean dragResizing = freeformResizing || dockedResizing;
                if (mDragResizing != dragResizing) {
                    if (dragResizing) {
                        mResizeMode = freeformResizing
@@ -7640,6 +7645,29 @@ public final class ViewRootImpl implements ViewParent,
        return relayoutResult;
    }

    private void updateOpacity(@Nullable WindowManager.LayoutParams params, boolean dragResizing) {
        boolean opaque = false;
        if (params != null && !PixelFormat.formatHasAlpha(params.format)
                // Don't make surface with surfaceInsets opaque as they display a
                // translucent shadow.
                && params.surfaceInsets.left == 0
                && params.surfaceInsets.top == 0
                && params.surfaceInsets.right == 0
                && params.surfaceInsets.bottom == 0
                // Don't make surface opaque when resizing to reduce the amount of
                // artifacts shown in areas the app isn't drawing content to.
                && !dragResizing) {
            opaque = true;
        }

        if (mIsSurfaceOpaque == opaque) {
            return;
        }

        mTransaction.setOpaque(mSurfaceControl, opaque).apply();
        mIsSurfaceOpaque = opaque;
    }

    private void setFrame(Rect frame) {
        mWinFrame.set(frame);
        mInsetsController.onFrameChanged(frame);
+1 −12
Original line number Diff line number Diff line
@@ -443,20 +443,9 @@ class WindowStateAnimator {
        // Set up surface control with initial size.
        try {

            // This can be removed once we move all Buffer Layers to use BLAST.
            final boolean isHwAccelerated = (attrs.flags & FLAG_HARDWARE_ACCELERATED) != 0;
            final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
            if (!PixelFormat.formatHasAlpha(attrs.format)
                    // Don't make surface with surfaceInsets opaque as they display a
                    // translucent shadow.
                    && attrs.surfaceInsets.left == 0
                    && attrs.surfaceInsets.top == 0
                    && attrs.surfaceInsets.right == 0
                    && attrs.surfaceInsets.bottom == 0
                    // Don't make surface opaque when resizing to reduce the amount of
                    // artifacts shown in areas the app isn't drawing content to.
                    && !w.isDragResizing()) {
                flags |= SurfaceControl.OPAQUE;
            }

            mSurfaceController = new WindowSurfaceController(attrs.getTitle().toString(), width,
                    height, format, flags, this, windowType);