Refactoring CellLayout into three classes
- splitting the rendering of children from the CellLayout to enhance performance, gives ~4 fps boost while scrolling on pages full of icons, and no change on pages full of widgets
- this will allow us to add hardware layer support trivially, which will increase performance while scrolling ~6-10 fps
- separated logic for caching celllayouts to bitmaps into a separate class
Change-Id: Ib6abeb19126e1504997b43c2f44af2a2fb3cd39f
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 4a0f44e..d99921f 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -109,7 +109,7 @@
protected boolean mAllowOverScroll = true;
protected int mUnboundedScrollX;
- // parameter that adjusts the layout to be optimized for CellLayouts with that scale factor
+ // parameter that adjusts the layout to be optimized for pages with that scale factor
protected float mLayoutScale = 1.0f;
protected static final int INVALID_POINTER = -1;
@@ -416,20 +416,20 @@
setMeasuredDimension(widthSize, heightSize);
}
- protected void moveToNewPageWithoutMovingCellLayouts(int newCurrentPage) {
+ protected void scrollToNewPageWithoutMovingPages(int newCurrentPage) {
int newX = getChildOffset(newCurrentPage) - getRelativeChildOffset(newCurrentPage);
int delta = newX - mScrollX;
- final int screenCount = getChildCount();
- for (int i = 0; i < screenCount; i++) {
- CellLayout cl = (CellLayout) getChildAt(i);
- cl.setX(cl.getX() + delta);
+ final int pageCount = getChildCount();
+ for (int i = 0; i < pageCount; i++) {
+ View page = (View) getChildAt(i);
+ page.setX(page.getX() + delta);
}
setCurrentPage(newCurrentPage);
}
- // A layout scale of 1.0f assumes that the CellLayouts, in their unshrunken state, have a
- // scale of 1.0f. A layout scale of 0.8f assumes the CellLayouts have a scale of 0.8f, and
+ // A layout scale of 1.0f assumes that the pages, in their unshrunken state, have a
+ // scale of 1.0f. A layout scale of 0.8f assumes the pages have a scale of 0.8f, and
// tightens the layout accordingly
public void setLayoutScale(float childrenScale) {
mLayoutScale = childrenScale;
@@ -451,7 +451,7 @@
}
// Also, the page offset has changed (since the pages are now smaller);
// update the page offset, but again preserving absolute X and Y coordinates
- moveToNewPageWithoutMovingCellLayouts(mCurrentPage);
+ scrollToNewPageWithoutMovingPages(mCurrentPage);
}
@Override