From a5ed31ba3bdfb8cd761e87f3de86198c6233c3cc Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Mon, 28 Oct 2013 20:12:01 +0100 Subject: Adapt hardware renderer and screen rotation animation for SoftwareGL Change-Id: I0d7809e7ae408c4762982599576be9a78d54a2dc Signed-off-by: Paul Kocialkowski --- core/java/android/app/ActivityManager.java | 38 +++++++++++--------- core/java/android/view/HardwareRenderer.java | 40 +++++++++++++--------- .../android/server/wm/ScreenRotationAnimation.java | 18 ++++++---- 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index e4e0d8e..e5c0e87 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -381,25 +381,29 @@ public class ActivityManager { * @hide */ static public boolean isHighEndGfx() { - MemInfoReader reader = new MemInfoReader(); - reader.readMemInfo(); - if (reader.getTotalSize() >= (512*1024*1024)) { - // If the device has at least 512MB RAM available to the kernel, - // we can afford the overhead of graphics acceleration. - return true; - } + if (SystemProperties.get("ro.softwaregl").equals("true")) { + return false; + } else { + MemInfoReader reader = new MemInfoReader(); + reader.readMemInfo(); + if (reader.getTotalSize() >= (512*1024*1024)) { + // If the device has at least 512MB RAM available to the kernel, + // we can afford the overhead of graphics acceleration. + return true; + } - Display display = DisplayManagerGlobal.getInstance().getRealDisplay( - Display.DEFAULT_DISPLAY); - Point p = new Point(); - display.getRealSize(p); - int pixels = p.x * p.y; - if (pixels >= (1024*600)) { - // If this is a sufficiently large screen, then there are enough - // pixels on it that we'd really like to use hw drawing. - return true; + Display display = DisplayManagerGlobal.getInstance().getRealDisplay( + Display.DEFAULT_DISPLAY); + Point p = new Point(); + display.getRealSize(p); + int pixels = p.x * p.y; + if (pixels >= (1024*600)) { + // If this is a sufficiently large screen, then there are enough + // pixels on it that we'd really like to use hw drawing. + return true; + } + return false; } - return false; } /** diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 5b7a5af..aa22d97 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -166,14 +166,14 @@ public abstract class HardwareRenderer { * * @hide */ - public static boolean sRendererDisabled = false; + public static boolean sRendererDisabled = SystemProperties.get("ro.softwaregl").equals("true") ? true : false; /** * Further hardware renderer disabling for the system process. * * @hide */ - public static boolean sSystemRendererDisabled = false; + public static boolean sSystemRendererDisabled = SystemProperties.get("ro.softwaregl").equals("true") ? true : false; /** * Number of frames to profile. @@ -1436,20 +1436,28 @@ public abstract class HardwareRenderer { @Override int[] getConfig(boolean dirtyRegions) { - return new int[] { - EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_DEPTH_SIZE, 0, - EGL_CONFIG_CAVEAT, EGL_NONE, - // TODO: Find a better way to choose the stencil size - EGL_STENCIL_SIZE, mShowOverdraw ? GLES20Canvas.getStencilSize() : 0, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT | - (dirtyRegions ? EGL14.EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0), - EGL_NONE - }; + if (SystemProperties.get("ro.softwaregl").equals("true")) { + return new int[] { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG, + EGL_NONE + }; + } else { + return new int[] { + EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 0, + EGL_CONFIG_CAVEAT, EGL_NONE, + // TODO: Find a better way to choose the stencil size + EGL_STENCIL_SIZE, mShowOverdraw ? GLES20Canvas.getStencilSize() : 0, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT | + (dirtyRegions ? EGL14.EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0), + EGL_NONE + }; + } } @Override diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java index 338d706..732a32d 100644 --- a/services/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java @@ -230,14 +230,20 @@ class ScreenRotationAnimation { try { try { - if (WindowManagerService.DEBUG_SURFACE_TRACE) { - mSurface = new SurfaceTrace(session, "FreezeSurface", - mWidth, mHeight, - PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN); - } else { + if (android.os.SystemProperties.get("ro.softwaregl").equals("true")) { mSurface = new Surface(session, "FreezeSurface", mWidth, mHeight, - PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN); + PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM | Surface.HIDDEN); + } else { + if (WindowManagerService.DEBUG_SURFACE_TRACE) { + mSurface = new SurfaceTrace(session, "FreezeSurface", + mWidth, mHeight, + PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN); + } else { + mSurface = new Surface(session, "FreezeSurface", + mWidth, mHeight, + PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN); + } } if (!mSurface.isValid()) { // Screenshot failed, punt. -- cgit v1.1