Make HolographicOutlineHelper a singleton.
It's a pretty heavy object, including three Paints at 74
bytes apiece, and we allocate one for every workspace and
every icon. We really only need one.
Change-Id: Ic9e12d478c3be27b13133718875c91540f7ccf4c
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 7cac8a6..7c7d93e 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -45,7 +45,7 @@
private int mPrevAlpha = -1;
- private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper();
+ private final HolographicOutlineHelper mOutlineHelper = HolographicOutlineHelper.obtain();
private final Canvas mTempCanvas = new Canvas();
private final Rect mTempRect = new Rect();
private boolean mDidInvalidateForPressedState;
diff --git a/src/com/android/launcher3/HolographicOutlineHelper.java b/src/com/android/launcher3/HolographicOutlineHelper.java
index 0344cd5..47c40b6 100644
--- a/src/com/android/launcher3/HolographicOutlineHelper.java
+++ b/src/com/android/launcher3/HolographicOutlineHelper.java
@@ -43,6 +43,8 @@
private static final int MEDIUM = 1;
private static final int EXTRA_THICK = 2;
+ static HolographicOutlineHelper INSTANCE;
+
static {
final float scale = LauncherAppState.getScreenDensity();
@@ -56,9 +58,11 @@
sExtraThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 6.0f, BlurMaskFilter.Blur.NORMAL);
sThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 4.0f, BlurMaskFilter.Blur.NORMAL);
sMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL);
+
+ INSTANCE = new HolographicOutlineHelper();
}
- HolographicOutlineHelper() {
+ private HolographicOutlineHelper() {
mHolographicPaint.setFilterBitmap(true);
mHolographicPaint.setAntiAlias(true);
mBlurPaint.setFilterBitmap(true);
@@ -68,6 +72,10 @@
mErasePaint.setAntiAlias(true);
}
+ public static HolographicOutlineHelper obtain() {
+ return INSTANCE;
+ }
+
/**
* Returns the interpolated holographic highlight alpha for the effect we want when scrolling
* pages.
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index fd32442..abf3b98 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -167,7 +167,7 @@
/** Is the user is dragging an item near the edge of a page? */
private boolean mInScrollArea = false;
- private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper();
+ private final HolographicOutlineHelper mOutlineHelper = HolographicOutlineHelper.obtain();
private Bitmap mDragOutline = null;
private final Rect mTempRect = new Rect();
private final int[] mTempXY = new int[2];