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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user