summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-05-06 13:14:33 -0700
committerRomain Guy <romainguy@google.com>2012-05-06 13:14:33 -0700
commit8a0bff5e35f63321178bbf777ec24d42544866b3 (patch)
treee49cd530eed4dff49845232a561308349385ec69 /src
parent8e21bc54113bf361d959f2c5934035b15f949379 (diff)
downloadandroid_packages_apps_Trebuchet-8a0bff5e35f63321178bbf777ec24d42544866b3.tar.gz
android_packages_apps_Trebuchet-8a0bff5e35f63321178bbf777ec24d42544866b3.tar.bz2
android_packages_apps_Trebuchet-8a0bff5e35f63321178bbf777ec24d42544866b3.zip
Remove unnecessary allocations
This change removes a couple of allocations per frame when the user is trying to scroll past the end of the workspace. The allocated object, PorterDuffXfermode, is pretty expensive and creating a new one on every frame could potentially defeat GL rendering optimizations. Change-Id: Iebaf579d29ad8f14112c5af8cb5dce8d7f4dfbaf
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 6f4759d1e..ba20a76ba 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -160,6 +160,9 @@ public class CellLayout extends ViewGroup {
private static final int INVALID_DIRECTION = -100;
private DropTarget.DragEnforcer mDragEnforcer;
+ private final static PorterDuffXfermode sAddBlendMode =
+ new PorterDuffXfermode(PorterDuff.Mode.ADD);
+
public CellLayout(Context context) {
this(context, null);
}
@@ -506,7 +509,7 @@ public class CellLayout extends ViewGroup {
if (mForegroundAlpha > 0) {
mOverScrollForegroundDrawable.setBounds(mForegroundRect);
Paint p = ((NinePatchDrawable) mOverScrollForegroundDrawable).getPaint();
- p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
+ p.setXfermode(sAddBlendMode);
mOverScrollForegroundDrawable.draw(canvas);
p.setXfermode(null);
}