summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/wm
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-05-19 19:31:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-19 19:31:58 +0000
commit0bb478b7ff32ac3cd8f583f3852742e18a9c4bd6 (patch)
tree8ef55fcfc4bd3652c09f1b0ef2ea4cb44e53d3c0 /services/core/java/com/android/server/wm
parent4a21a7fab6c0cca2c668650969e9af50c9c5068e (diff)
parent80181b99c7be562b24095ee495712f7197229c74 (diff)
downloadframeworks_base-0bb478b7ff32ac3cd8f583f3852742e18a9c4bd6.zip
frameworks_base-0bb478b7ff32ac3cd8f583f3852742e18a9c4bd6.tar.gz
frameworks_base-0bb478b7ff32ac3cd8f583f3852742e18a9c4bd6.tar.bz2
Merge "Don't recreate the surface unnecessarily" into mnc-dev
Diffstat (limited to 'services/core/java/com/android/server/wm')
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java11
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java26
2 files changed, 33 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index b84b506..d956d76 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3187,10 +3187,13 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) {
- // To change the format, we need to re-build the surface.
- winAnimator.destroySurfaceLocked();
- toBeDisplayed = true;
- surfaceChanged = true;
+ // 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) {
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 424e2e2..e9023fd 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -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
@@ -845,6 +848,7 @@ class WindowStateAnimator {
flags |= SurfaceControl.OPAQUE;
}
+ mSurfaceFormat = format;
if (DEBUG_SURFACE_TRACE) {
mSurfaceControl = new SurfaceTrace(
mSession.mSurfaceSession,
@@ -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;