Reducing memory impact of hardware layers in Launcher
- Disabling hardware layers in customize tray
- Destroying hardware layers for pages in All Apps that are not visible
- Re-adding CachedTextView for icons in customize tray (to regain some of the lost performance there)
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 6d1fb55..d64f3c9 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -40,6 +40,7 @@
private static int sDefaultCellDimensions = 96;
protected PagedViewCellLayoutChildren mChildren;
private PagedViewCellLayoutChildren mHolographicChildren;
+ private boolean mUseHardwareLayers = false;
public PagedViewCellLayout(Context context) {
this(context, null);
@@ -73,12 +74,29 @@
addView(mHolographicChildren);
}
+ public void enableHardwareLayers() {
+ mUseHardwareLayers = true;
+ }
+
@Override
public void setAlpha(float alpha) {
mChildren.setAlpha(alpha);
mHolographicChildren.setAlpha(1.0f - alpha);
}
+ void destroyHardwareLayers() {
+ if (mUseHardwareLayers) {
+ mChildren.destroyHardwareLayer();
+ mHolographicChildren.destroyHardwareLayer();
+ }
+ }
+ void createHardwareLayers() {
+ if (mUseHardwareLayers) {
+ mChildren.createHardwareLayer();
+ mHolographicChildren.createHardwareLayer();
+ }
+ }
+
@Override
public void cancelLongPress() {
super.cancelLongPress();
@@ -109,6 +127,9 @@
if (child instanceof PagedViewIcon) {
PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
+ if (mUseHardwareLayers) {
+ pagedViewIcon.disableCache();
+ }
mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(), index, lp);
}
return true;