OSDN Git Service

Make WindowContainer surfaces container layers by default.
authorChavi Weingarten <chaviw@google.com>
Thu, 7 Feb 2019 16:28:45 +0000 (16:28 +0000)
committerchaviw <chaviw@google.com>
Wed, 20 Feb 2019 23:33:30 +0000 (15:33 -0800)
This reverts commit f6ef18334b4b90f025fa0ece969c2ce2f92221b1.

Reason for revert: ag/6227549 fixes underlying issue

Change-Id: Id1456529ef0009f8e28575ef591d9559c43db4a5
Fixes: 122561221
Test: go/wm-smoke

13 files changed:
core/java/android/app/ActivityView.java
core/java/android/view/SurfaceControl.java
core/java/android/view/SurfaceView.java
services/core/java/com/android/server/display/ColorFade.java
services/core/java/com/android/server/wm/BlackFrame.java
services/core/java/com/android/server/wm/Dimmer.java
services/core/java/com/android/server/wm/DisplayContent.java
services/core/java/com/android/server/wm/DragState.java
services/core/java/com/android/server/wm/InputConsumerImpl.java
services/core/java/com/android/server/wm/Letterbox.java
services/core/java/com/android/server/wm/TaskPositioningController.java
services/core/java/com/android/server/wm/TaskSnapshotSurface.java
services/core/java/com/android/server/wm/TaskStack.java

index e0ae4e3..38d2f34 100644 (file)
@@ -400,7 +400,7 @@ public class ActivityView extends ViewGroup {
         final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
 
         mRootSurfaceControl = new SurfaceControl.Builder(surfaceSession)
-                .setContainerLayer(true)
+                .setContainerLayer()
                 .setParent(mSurfaceView.getSurfaceControl())
                 .setName(DISPLAY_NAME)
                 .build();
index 1212df0..e5db44e 100644 (file)
@@ -489,7 +489,16 @@ public final class SurfaceControl implements Parcelable {
             }
             mWidth = width;
             mHeight = height;
-            return this;
+            // set this as a buffer layer since we are specifying a buffer size.
+            return setFlags(FX_SURFACE_NORMAL, FX_SURFACE_MASK);
+        }
+
+        /**
+         * Set the initial size of the controlled surface's buffers in pixels.
+         */
+        private void unsetBufferSize() {
+            mWidth = 0;
+            mHeight = 0;
         }
 
         /**
@@ -607,16 +616,11 @@ public final class SurfaceControl implements Parcelable {
          * Color layers will not have an associated BufferQueue and will instead always render a
          * solid color (that is, solid before plane alpha). Currently that color is black.
          *
-         * @param isColorLayer Whether to create a color layer.
          * @hide
          */
-        public Builder setColorLayer(boolean isColorLayer) {
-            if (isColorLayer) {
-                mFlags |= FX_SURFACE_DIM;
-            } else {
-                mFlags &= ~FX_SURFACE_DIM;
-            }
-            return this;
+        public Builder setColorLayer() {
+            unsetBufferSize();
+            return setFlags(FX_SURFACE_DIM, FX_SURFACE_MASK);
         }
 
         private boolean isColorLayerSet() {
@@ -629,16 +633,11 @@ public final class SurfaceControl implements Parcelable {
          * Container layers will not be rendered in any fashion and instead are used
          * as a parent of renderable layers.
          *
-         * @param isContainerLayer Whether to create a container layer.
          * @hide
          */
-        public Builder setContainerLayer(boolean isContainerLayer) {
-            if (isContainerLayer) {
-                mFlags |= FX_SURFACE_CONTAINER;
-            } else {
-                mFlags &= ~FX_SURFACE_CONTAINER;
-            }
-            return this;
+        public Builder setContainerLayer() {
+            unsetBufferSize();
+            return setFlags(FX_SURFACE_CONTAINER, FX_SURFACE_MASK);
         }
 
         private boolean isContainerLayerSet() {
@@ -646,7 +645,7 @@ public final class SurfaceControl implements Parcelable {
         }
 
         /**
-         * Set 'Surface creation flags' such as {@link HIDDEN}, {@link SECURE}.
+         * Set 'Surface creation flags' such as {@link #HIDDEN}, {@link #SECURE}.
          *
          * TODO: Finish conversion to individual builder methods?
          * @param flags The combined flags
@@ -656,6 +655,11 @@ public final class SurfaceControl implements Parcelable {
             mFlags = flags;
             return this;
         }
+
+        private Builder setFlags(int flags, int mask) {
+            mFlags = (mFlags & ~mask) | flags;
+            return this;
+        }
     }
 
     /**
index 9f0800f..fe9aa23 100644 (file)
@@ -33,7 +33,6 @@ import android.graphics.Region;
 import android.graphics.RenderNode;
 import android.os.Build;
 import android.os.Handler;
-import android.os.IBinder;
 import android.os.Looper;
 import android.os.SystemClock;
 import android.util.AttributeSet;
@@ -588,7 +587,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                     mBackgroundControl = new SurfaceControl.Builder(mSurfaceSession)
                         .setName("Background for -" + name)
                         .setOpaque(true)
-                        .setColorLayer(true)
+                        .setColorLayer()
                         .setParent(mSurfaceControl)
                         .build();
 
index 31b497d..36d9c0e 100644 (file)
@@ -582,7 +582,7 @@ final class ColorFade {
                 final SurfaceControl.Builder builder =
                         new SurfaceControl.Builder(mSurfaceSession).setName("ColorFade");
                 if (mMode == MODE_FADE) {
-                    builder.setColorLayer(true);
+                    builder.setColorLayer();
                 } else {
                     builder.setBufferSize(mDisplayWidth, mDisplayHeight);
                 }
index 497e412..84ba5ca 100644 (file)
@@ -48,7 +48,7 @@ public class BlackFrame {
 
             surface = dc.makeOverlay()
                     .setName("BlackSurface")
-                    .setColorLayer(true)
+                    .setColorLayer()
                     .setParent(null) // TODO: Work-around for b/69259549
                     .build();
             transaction.setWindowCrop(surface, w, h);
index 1373e18..ee28084 100644 (file)
@@ -164,7 +164,7 @@ class Dimmer {
     private SurfaceControl makeDimLayer() {
         return mHost.makeChildSurface(null)
                 .setParent(mHost.getSurfaceControl())
-                .setColorLayer(true)
+                .setColorLayer()
                 .setName("Dim Layer for - " + mHost.getName())
                 .build();
     }
index 4795555..28cd930 100644 (file)
@@ -896,7 +896,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
         mDividerControllerLocked = new DockedStackDividerController(service, this);
         mPinnedStackControllerLocked = new PinnedStackController(service, this);
 
-        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(mSession).setOpaque(true);
+        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(mSession)
+                .setOpaque(true)
+                .setContainerLayer();
         mWindowingLayer = b.setName("Display Root").build();
         mOverlayLayer = b.setName("Display Overlays").build();
 
@@ -4639,7 +4641,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     @Override
     SurfaceControl.Builder makeChildSurface(WindowContainer child) {
         SurfaceSession s = child != null ? child.getSession() : getSession();
-        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(s);
+        final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(s).setContainerLayer();
         if (child == null) {
             return b;
         }
index 3f77e1c..2b2231a 100644 (file)
@@ -164,7 +164,7 @@ class DragState {
 
         if (mInputSurface == null) {
             mInputSurface = mService.makeSurfaceBuilder(mService.mRoot.getDisplayContent(displayId)
-                    .getSession()).setContainerLayer(true)
+                    .getSession()).setContainerLayer()
                     .setName("Drag and Drop Input Consumer").build();
         }
         final InputWindowHandle h = getInputWindowHandle();
index 4df5a0b..ab95e4b 100644 (file)
@@ -22,13 +22,11 @@ import android.os.IBinder;
 import android.os.Process;
 import android.os.RemoteException;
 import android.os.UserHandle;
-import android.view.InputChannel;
-import android.view.WindowManager;
-
 import android.view.InputApplicationHandle;
+import android.view.InputChannel;
 import android.view.InputWindowHandle;
 import android.view.SurfaceControl;
-import android.util.Slog;
+import android.view.WindowManager;
 
 import java.io.PrintWriter;
 
@@ -89,7 +87,7 @@ class InputConsumerImpl implements IBinder.DeathRecipient {
         mWindowHandle.scaleFactor = 1.0f;
 
         mInputSurface = mService.makeSurfaceBuilder(mService.mRoot.getDisplayContent(displayId)
-                .getSession()).setContainerLayer(true).setName("Input Consumer " + name)
+                .getSession()).setContainerLayer().setName("Input Consumer " + name)
                 .build();
     }
 
index d67193e..f8f693c 100644 (file)
@@ -233,7 +233,7 @@ public class Letterbox {
 
         private void createSurface() {
             mSurface = mFactory.get().setName("Letterbox - " + mType)
-                    .setFlags(HIDDEN).setColorLayer(true).build();
+                    .setFlags(HIDDEN).setColorLayer().build();
             mSurface.setLayer(-1);
             mSurface.setColor(new float[]{0, 0, 0});
         }
index 9163165..cdcb857 100644 (file)
@@ -83,7 +83,7 @@ class TaskPositioningController {
         final DisplayContent dc = mService.mRoot.getDisplayContent(displayId);
         if (mInputSurface == null) {
             mInputSurface = mService.makeSurfaceBuilder(dc.getSession())
-                    .setContainerLayer(true)
+                    .setContainerLayer()
                     .setName("Drag and Drop Input Consumer").build();
         }
 
index 2d3e3ae..938c8b4 100644 (file)
@@ -61,12 +61,12 @@ import android.util.MergedConfiguration;
 import android.util.Slog;
 import android.view.DisplayCutout;
 import android.view.IWindowSession;
+import android.view.InsetsState;
 import android.view.Surface;
 import android.view.SurfaceControl;
 import android.view.SurfaceSession;
 import android.view.View;
 import android.view.ViewGroup.LayoutParams;
-import android.view.InsetsState;
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
 
index b915199..b8dae83 100644 (file)
@@ -818,7 +818,7 @@ public class TaskStack extends WindowContainer<Task> implements
 
         updateSurfaceBounds();
         if (mAnimationBackgroundSurface == null) {
-            mAnimationBackgroundSurface = makeChildSurface(null).setColorLayer(true)
+            mAnimationBackgroundSurface = makeChildSurface(null).setColorLayer()
                     .setName("animation background stackId=" + mStackId)
                     .build();
         }