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

Commit 2fd2d700 authored by Cairn Overturf's avatar Cairn Overturf
Browse files

Disable elevation shadows when box shadows are enabled

Bug: 367464660
Bug: 421025291
Test: Enable com.android.wm.shell.enable_pip_box_shadows and run the following test. Take a perfetto trace during the test and ensure that elevation (drawShadow) and box shadows (BoxShadows) aren't rendered simultaneously.  atest systemui-desktopmode-drag-1-jank-suite    --request-upload-result    -- --enable-module-dynamic-download    --module-arg systemui-desktopmode-drag-1-jank-suite:strict-include-metric-filter:'perfetto_ft_systemui-missed_sf_frames-mean'    --test-arg com.android.tradefed.testtype.AndroidJUnitTest:class:android.platform.test.scenario.sysui.desktopmode.DragAppWindowMultiWindowAndPipMicrobenchmark
Flag: EXEMPT bugfix
Change-Id: I01193e3819160f379e267dbc9a86e4b002387e44
parent 2190e504
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -332,6 +332,15 @@ public class PipSurfaceTransactionHelper {
    public PipSurfaceTransactionHelper shadow(SurfaceControl.Transaction tx, SurfaceControl leash,
            boolean applyShadowRadius) {
        if (Flags.enablePipBoxShadows()) {
            // Override and disable elevation shadows set by freeform transition.
            //
            // PiP uses box shadows but freeform windows use
            // elevation shadows (i.e. setShadowRadius).
            // To avoid having double shadows applied, disable the shadows set by freeform.
            //
            // TODO(b/367464660): Remove this once freeform box shadows are enabled
            tx.setShadowRadius(leash, 0);

            if (applyShadowRadius) {
                tx.setBoxShadowSettings(leash, mBoxShadowSettings);
                tx.setBorderSettings(leash, mBorderSettings);
+9 −0
Original line number Diff line number Diff line
@@ -221,6 +221,15 @@ public class PipSurfaceTransactionHelper implements PipDisplayLayoutState.Displa
    public PipSurfaceTransactionHelper shadow(SurfaceControl.Transaction tx, SurfaceControl leash,
            boolean applyShadowRadius) {
        if (Flags.enablePipBoxShadows()) {
            // Override and disable elevation shadows set by freeform transition.
            //
            // PiP uses box shadows but freeform windows use
            // elevation shadows (i.e. setShadowRadius).
            // To avoid having double shadows applied, disable the shadows set by freeform.
            //
            // TODO(b/367464660): Remove this once freeform box shadows are enabled
            tx.setShadowRadius(leash, 0);

            if (applyShadowRadius) {
                tx.setBoxShadowSettings(leash, mBoxShadowSettings);
                tx.setBorderSettings(leash, mBorderSettings);
+6 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.intThat;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -208,7 +207,8 @@ public class PipSurfaceTransactionHelperTest {

        verify(mMockTransaction).setBoxShadowSettings(eq(mTestLeash), boxShadow.capture());
        verify(mMockTransaction).setBorderSettings(eq(mTestLeash), border.capture());
        verify(mMockTransaction, never()).setShadowRadius(any(), anyFloat());
        // Ensure that box shadow clears elevation shadow which may be set by window decorations.
        verify(mMockTransaction).setShadowRadius(eq(mTestLeash), eq(0.0f));

        assertEquals(0, boxShadow.getValue().boxShadows.length);
        assertEquals(0, border.getValue().strokeWidth, 0.0);
@@ -227,7 +227,8 @@ public class PipSurfaceTransactionHelperTest {
        verify(mMockTransaction).setBoxShadowSettings(eq(mTestLeash),
                eq(mDarkBoxShadowSettings));
        verify(mMockTransaction).setBorderSettings(eq(mTestLeash), eq(mDarkBorderSettings));
        verify(mMockTransaction, never()).setShadowRadius(any(), anyFloat());
        // Ensure that box shadow clears elevation shadow which may be set by window decorations.
        verify(mMockTransaction).setShadowRadius(eq(mTestLeash), eq(0.0f));
    }


@@ -243,7 +244,8 @@ public class PipSurfaceTransactionHelperTest {
        verify(mMockTransaction).setBoxShadowSettings(eq(mTestLeash),
                eq(mLightBoxShadowSettings));
        verify(mMockTransaction).setBorderSettings(eq(mTestLeash), eq(mLightBorderSettings));
        verify(mMockTransaction, never()).setShadowRadius(any(), anyFloat());
        // Ensure that box shadow clears elevation shadow which may be set by window decorations.
        verify(mMockTransaction).setShadowRadius(eq(mTestLeash), eq(0.0f));
    }

    @Test