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
This commit is contained in:
Romain Guy
2012-05-06 13:14:33 -07:00
parent 8e21bc5411
commit 8a0bff5e35
+4 -1
View File
@@ -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);
}