mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-06 02:46:57 +00:00
Fix occasional Home/All Apps slowdowns
Bug # 5581817 Change-Id: I0ee75ebe073325f89d89669b562ffc4db28f3004
This commit is contained in:
@@ -123,6 +123,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
protected boolean mCenterPagesVertically;
|
||||
protected boolean mAllowOverScroll = true;
|
||||
protected int mUnboundedScrollX;
|
||||
protected int[] mTempVisiblePagesRange = new int[2];
|
||||
|
||||
// parameter that adjusts the layout to be optimized for pages with that scale factor
|
||||
protected float mLayoutScale = 1.0f;
|
||||
@@ -671,20 +672,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
updateScrollingIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
int halfScreenSize = getMeasuredWidth() / 2;
|
||||
int screenCenter = mScrollX + halfScreenSize;
|
||||
|
||||
if (screenCenter != mLastScreenCenter) {
|
||||
screenScrolled(screenCenter);
|
||||
updateAdjacentPagesAlpha();
|
||||
mLastScreenCenter = screenCenter;
|
||||
}
|
||||
|
||||
// Find out which screens are visible; as an optimization we only call draw on them
|
||||
// As an optimization, this code assumes that all pages have the same width as the 0th
|
||||
// page.
|
||||
protected void getVisiblePages(int[] range) {
|
||||
final int pageCount = getChildCount();
|
||||
if (pageCount > 0) {
|
||||
final int pageWidth = getScaledMeasuredWidth(getPageAt(0));
|
||||
@@ -702,6 +690,31 @@ public abstract class PagedView extends ViewGroup {
|
||||
x += getScaledMeasuredWidth(getPageAt(rightScreen)) + mPageSpacing;
|
||||
}
|
||||
rightScreen = Math.min(getChildCount() - 1, rightScreen);
|
||||
range[0] = leftScreen;
|
||||
range[1] = rightScreen;
|
||||
} else {
|
||||
range[0] = -1;
|
||||
range[1] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
int halfScreenSize = getMeasuredWidth() / 2;
|
||||
int screenCenter = mScrollX + halfScreenSize;
|
||||
|
||||
if (screenCenter != mLastScreenCenter) {
|
||||
screenScrolled(screenCenter);
|
||||
updateAdjacentPagesAlpha();
|
||||
mLastScreenCenter = screenCenter;
|
||||
}
|
||||
|
||||
// Find out which screens are visible; as an optimization we only call draw on them
|
||||
final int pageCount = getChildCount();
|
||||
if (pageCount > 0) {
|
||||
getVisiblePages(mTempVisiblePagesRange);
|
||||
final int leftScreen = mTempVisiblePagesRange[0];
|
||||
final int rightScreen = mTempVisiblePagesRange[1];
|
||||
|
||||
final long drawingTime = getDrawingTime();
|
||||
// Clip to the bounds
|
||||
|
||||
@@ -1255,6 +1255,19 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (mChildrenLayersEnabled) {
|
||||
getVisiblePages(mTempVisiblePagesRange);
|
||||
final int leftScreen = mTempVisiblePagesRange[0];
|
||||
final int rightScreen = mTempVisiblePagesRange[1];
|
||||
if (leftScreen != -1 && rightScreen != -1) {
|
||||
// calling setChildrenLayersEnabled on a view that's not visible/rendered
|
||||
// causes slowdowns on some graphics cards, so we set it here to be sure
|
||||
// it's only called when it's safe (ie when the view will be rendered)
|
||||
for (int i = leftScreen; i <= rightScreen; i++) {
|
||||
((ViewGroup)getPageAt(i)).setChildrenLayersEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
|
||||
@@ -1359,8 +1372,13 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
if (enableChildrenLayers != mChildrenLayersEnabled) {
|
||||
mChildrenLayersEnabled = enableChildrenLayers;
|
||||
for (int i = 0; i < getPageCount(); i++) {
|
||||
((ViewGroup)getChildAt(i)).setChildrenLayersEnabled(enableChildrenLayers);
|
||||
// calling setChildrenLayersEnabled on a view that's not visible/rendered
|
||||
// causes slowdowns on some graphics cards, so we only disable it here and leave
|
||||
// the enabling to dispatchDraw
|
||||
if (!enableChildrenLayers) {
|
||||
for (int i = 0; i < getPageCount(); i++) {
|
||||
((ViewGroup)getChildAt(i)).setChildrenLayersEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user