Loading services/core/java/com/android/server/wm/WindowManagerService.java +7 −4 Original line number Diff line number Diff line Loading @@ -3187,11 +3187,14 @@ public class WindowManagerService extends IWindowManager.Stub } } if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) { // To change the format, we need to re-build the surface. // If the format can be changed in place yaay! // If not, fall back to a surface re-build if (!winAnimator.tryChangeFormatInPlaceLocked()) { winAnimator.destroySurfaceLocked(); toBeDisplayed = true; surfaceChanged = true; } } try { if (!win.mHasSurface) { surfaceChanged = true; Loading services/core/java/com/android/server/wm/WindowStateAnimator.java +26 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ class WindowStateAnimator { boolean mKeyguardGoingAwayAnimation; /** The pixel format of the underlying SurfaceControl */ int mSurfaceFormat; /** This is set when there is no Surface */ static final int NO_SURFACE = 0; /** This is set after the Surface has been created but before the window has been drawn. During Loading Loading @@ -845,6 +848,7 @@ class WindowStateAnimator { flags |= SurfaceControl.OPAQUE; } mSurfaceFormat = format; if (DEBUG_SURFACE_TRACE) { mSurfaceControl = new SurfaceTrace( mSession.mSurfaceSession, Loading Loading @@ -1610,6 +1614,28 @@ class WindowStateAnimator { } } /** * Try to change the pixel format without recreating the surface. This * will be common in the case of changing from PixelFormat.OPAQUE to * PixelFormat.TRANSLUCENT in the hardware-accelerated case as both * requested formats resolve to the same underlying SurfaceControl format * @return True if format was succesfully changed, false otherwise */ boolean tryChangeFormatInPlaceLocked() { if (mSurfaceControl == null) { return false; } final LayoutParams attrs = mWin.getAttrs(); final boolean isHwAccelerated = (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format; if (format == mSurfaceFormat) { setOpaqueLocked(!PixelFormat.formatHasAlpha(attrs.format)); return true; } return false; } void setOpaqueLocked(boolean isOpaque) { if (mSurfaceControl == null) { return; Loading Loading
services/core/java/com/android/server/wm/WindowManagerService.java +7 −4 Original line number Diff line number Diff line Loading @@ -3187,11 +3187,14 @@ public class WindowManagerService extends IWindowManager.Stub } } if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) { // To change the format, we need to re-build the surface. // If the format can be changed in place yaay! // If not, fall back to a surface re-build if (!winAnimator.tryChangeFormatInPlaceLocked()) { winAnimator.destroySurfaceLocked(); toBeDisplayed = true; surfaceChanged = true; } } try { if (!win.mHasSurface) { surfaceChanged = true; Loading
services/core/java/com/android/server/wm/WindowStateAnimator.java +26 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ class WindowStateAnimator { boolean mKeyguardGoingAwayAnimation; /** The pixel format of the underlying SurfaceControl */ int mSurfaceFormat; /** This is set when there is no Surface */ static final int NO_SURFACE = 0; /** This is set after the Surface has been created but before the window has been drawn. During Loading Loading @@ -845,6 +848,7 @@ class WindowStateAnimator { flags |= SurfaceControl.OPAQUE; } mSurfaceFormat = format; if (DEBUG_SURFACE_TRACE) { mSurfaceControl = new SurfaceTrace( mSession.mSurfaceSession, Loading Loading @@ -1610,6 +1614,28 @@ class WindowStateAnimator { } } /** * Try to change the pixel format without recreating the surface. This * will be common in the case of changing from PixelFormat.OPAQUE to * PixelFormat.TRANSLUCENT in the hardware-accelerated case as both * requested formats resolve to the same underlying SurfaceControl format * @return True if format was succesfully changed, false otherwise */ boolean tryChangeFormatInPlaceLocked() { if (mSurfaceControl == null) { return false; } final LayoutParams attrs = mWin.getAttrs(); final boolean isHwAccelerated = (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format; if (format == mSurfaceFormat) { setOpaqueLocked(!PixelFormat.formatHasAlpha(attrs.format)); return true; } return false; } void setOpaqueLocked(boolean isOpaque) { if (mSurfaceControl == null) { return; Loading