From 01f2d7fa4b24b21543012060305d693899b4beaa Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Tue, 1 Oct 2013 14:41:56 -0700 Subject: [PATCH] Disable hardware layer on custom screen Whereas standard ShortcutAndWidgetContainers are static during screen transition, the custom screen may animate during its transition. Disabling the hardware layer reduces the cost of this animation significantly. bug:10810505 Change-Id: I560d209f651951f54c224862a706e8a243dc71af --- src/com/android/launcher3/CellLayout.java | 8 ++------ src/com/android/launcher3/Workspace.java | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 81f9af2e1c..72a6ce2e10 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -296,12 +296,8 @@ public class CellLayout extends ViewGroup { addView(mShortcutsAndWidgets); } - public void enableHardwareLayers() { - mShortcutsAndWidgets.setLayerType(LAYER_TYPE_HARDWARE, sPaint); - } - - public void disableHardwareLayers() { - mShortcutsAndWidgets.setLayerType(LAYER_TYPE_NONE, sPaint); + public void enableHardwareLayer(boolean hasLayer) { + mShortcutsAndWidgets.setLayerType(hasLayer ? LAYER_TYPE_HARDWARE : LAYER_TYPE_NONE, sPaint); } public void buildHardwareLayer() { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index ea348ef8ab..82b10fee8b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1046,7 +1046,7 @@ public class Workspace extends SmoothPagedView mLauncher.updateVoiceButtonProxyVisible(false); } } - }; + } protected void setWallpaperDimension() { String spKey = WallpaperCropActivity.getSharedPreferencesKey(); @@ -1572,7 +1572,7 @@ public class Workspace extends SmoothPagedView } else { for (int i = 0; i < getPageCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); - cl.disableHardwareLayers(); + cl.enableHardwareLayer(false); } } } @@ -1592,17 +1592,16 @@ public class Workspace extends SmoothPagedView leftScreen--; } } + + final CellLayout customScreen = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID); for (int i = 0; i < screenCount; i++) { final CellLayout layout = (CellLayout) getPageAt(i); - if (!(leftScreen <= i && i <= rightScreen && shouldDrawChild(layout))) { - layout.disableHardwareLayers(); - } - } - for (int i = 0; i < screenCount; i++) { - final CellLayout layout = (CellLayout) getPageAt(i); - if (leftScreen <= i && i <= rightScreen && shouldDrawChild(layout)) { - layout.enableHardwareLayers(); - } + + // enable layers between left and right screen inclusive, except for the + // customScreen, which may animate its content during transitions. + boolean enableLayer = layout != customScreen && + leftScreen <= i && i <= rightScreen && shouldDrawChild(layout); + layout.enableHardwareLayer(enableLayer); } } }