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

Commit f0ae9acf authored by Vishnu Nair's avatar Vishnu Nair
Browse files

ViewRootImpl: Update opaque flag if SurfaceControl changes from relayout

The opaque flag is necessary for the compositor to blend the layers
correctly and prevent translucent pixels from showing the layer
underneath during animations.

Test: manually punch holes in apps and verify opaque apps don't show the layer underneath
Test: automated tests to follow
Bug: 198924563
Change-Id: I1116c51b2efd4e9c0fe2acbca080291f3950245c
parent 50d7e14c
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -2836,8 +2836,13 @@ public final class ViewRootImpl implements ViewParent,
                    }
                }

                final boolean surfaceControlChanged =
                        (relayoutResult & RELAYOUT_RES_SURFACE_CHANGED)
                                == RELAYOUT_RES_SURFACE_CHANGED;

                if (mSurfaceControl.isValid()) {
                    updateOpacity(mWindowAttributes, dragResizing);
                    updateOpacity(mWindowAttributes, dragResizing,
                            surfaceControlChanged /*forceUpdate */);
                }

                if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString()
@@ -2872,9 +2877,7 @@ public final class ViewRootImpl implements ViewParent,
                // RELAYOUT_RES_SURFACE_CHANGED since it should indicate that WMS created a new
                // SurfaceControl.
                surfaceReplaced = (surfaceGenerationId != mSurface.getGenerationId()
                        || (relayoutResult & RELAYOUT_RES_SURFACE_CHANGED)
                        == RELAYOUT_RES_SURFACE_CHANGED)
                        && mSurface.isValid();
                        || surfaceControlChanged) && mSurface.isValid();
                if (surfaceReplaced) {
                    mSurfaceSequenceId++;
                }
@@ -7824,7 +7827,8 @@ public final class ViewRootImpl implements ViewParent,
        return relayoutResult;
    }

    private void updateOpacity(WindowManager.LayoutParams params, boolean dragResizing) {
    private void updateOpacity(WindowManager.LayoutParams params, boolean dragResizing,
            boolean forceUpdate) {
        boolean opaque = false;

        if (!PixelFormat.formatHasAlpha(params.format)
@@ -7840,7 +7844,7 @@ public final class ViewRootImpl implements ViewParent,
            opaque = true;
        }

        if (mIsSurfaceOpaque == opaque) {
        if (!forceUpdate && mIsSurfaceOpaque == opaque) {
            return;
        }