From eeadda59687478704ee7f7f45fd6868e3ec6eb3f Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 2 Oct 2012 17:32:38 -0700 Subject: [PATCH] Always enable hardware layers in widgets in keyguard while dragging. This fixes a performance issue on the 7" tablet where disabling hardware layers in landscape mode resulted in extremely bad drawing performance. The code now enables hardware layers for all the widgets while the user is dragging. Fixes bug 7274971 Change-Id: Iafd18fb317fcd3caad45791fe5a0f111d40a1ed4 --- .../impl/keyguard/KeyguardWidgetFrame.java | 7 ------- .../impl/keyguard/KeyguardWidgetPager.java | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java index fe1005f964ab3..9d9b0431a1761 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java @@ -117,14 +117,7 @@ public class KeyguardWidgetFrame extends FrameLayout { mOverScrollAmount = r; mForegroundGradient = left ? mLeftToRightGradient : mRightToLeftGradient; mForegroundAlpha = (int) Math.round((0.85f * r * 255)); - if (getLayerType() != LAYER_TYPE_HARDWARE) { - setLayerType(LAYER_TYPE_HARDWARE, null); - } invalidate(); - } else { - if (getLayerType() != LAYER_TYPE_NONE) { - setLayerType(LAYER_TYPE_NONE, null); - } } } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java index a1603dcda961a..9dfbba8096830 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java @@ -76,6 +76,25 @@ public class KeyguardWidgetPager extends PagedView { } } + @Override + protected void onPageBeginMoving() { + // Enable hardware layers while pages are moving + // TODO: We should only do this for the two views that are actually moving + int children = getChildCount(); + for (int i = 0; i < children; i++) { + getChildAt(i).setLayerType(LAYER_TYPE_HARDWARE, null); + } + } + + @Override + protected void onPageEndMoving() { + // Disable hardware layers while pages are moving + int children = getChildCount(); + for (int i = 0; i < children; i++) { + getChildAt(i).setLayerType(LAYER_TYPE_NONE, null); + } + } + /* * This interpolator emulates the rate at which the perceived scale of an object changes * as its distance from a camera increases. When this interpolator is applied to a scale