mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Merge "Removing unnecessary new object creation in dispatchDraw" into ub-launcher3-burnaby-polish
This commit is contained in:
@@ -28,6 +28,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
@@ -87,8 +88,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
private int mFreeScrollMinScrollX = -1;
|
||||
private int mFreeScrollMaxScrollX = -1;
|
||||
|
||||
static final int AUTOMATIC_PAGE_SPACING = -1;
|
||||
|
||||
protected int mFlingThresholdVelocity;
|
||||
protected int mMinFlingVelocity;
|
||||
protected int mMinSnapVelocity;
|
||||
@@ -133,8 +132,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
protected final static int TOUCH_STATE_NEXT_PAGE = 3;
|
||||
protected final static int TOUCH_STATE_REORDERING = 4;
|
||||
|
||||
protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f;
|
||||
|
||||
protected int mTouchState = TOUCH_STATE_REST;
|
||||
protected boolean mForceScreenScrolled = false;
|
||||
|
||||
@@ -144,12 +141,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
private int mMaximumVelocity;
|
||||
protected int mPageLayoutWidthGap;
|
||||
protected int mPageLayoutHeightGap;
|
||||
protected int mCellCountX = 0;
|
||||
protected int mCellCountY = 0;
|
||||
protected boolean mCenterPagesVertically;
|
||||
protected boolean mAllowOverScroll = true;
|
||||
protected int[] mTempVisiblePagesRange = new int[2];
|
||||
protected boolean mForceDrawAllChildrenNextFrame;
|
||||
|
||||
protected static final int INVALID_POINTER = -1;
|
||||
|
||||
@@ -198,6 +192,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
private static final float[] sTmpPoint = new float[2];
|
||||
private static final int[] sTmpIntPoint = new int[2];
|
||||
private static final Rect sTmpRect = new Rect();
|
||||
private static final RectF sTmpRectF = new RectF();
|
||||
|
||||
protected final Rect mInsets = new Rect();
|
||||
protected final boolean mIsRtl;
|
||||
@@ -1057,22 +1052,26 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
|
||||
protected void getVisiblePages(int[] range) {
|
||||
final int pageCount = getChildCount();
|
||||
sTmpIntPoint[0] = sTmpIntPoint[1] = 0;
|
||||
|
||||
range[0] = -1;
|
||||
range[1] = -1;
|
||||
|
||||
if (pageCount > 0) {
|
||||
int viewportWidth = getViewportWidth();
|
||||
final int visibleLeft = -getLeft();
|
||||
final int visibleRight = visibleLeft + getViewportWidth();
|
||||
int curScreen = 0;
|
||||
|
||||
int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View currPage = getPageAt(i);
|
||||
|
||||
sTmpIntPoint[0] = 0;
|
||||
Utilities.getDescendantCoordRelativeToParent(currPage, this, sTmpIntPoint, false);
|
||||
if (sTmpIntPoint[0] > viewportWidth) {
|
||||
// Verify if the page bounds are within the visible range.
|
||||
sTmpRectF.left = 0;
|
||||
sTmpRectF.right = currPage.getMeasuredWidth();
|
||||
currPage.getMatrix().mapRect(sTmpRectF);
|
||||
sTmpRectF.offset(currPage.getLeft() - getScrollX(), 0);
|
||||
getMatrix().mapRect(sTmpRectF);
|
||||
|
||||
if (sTmpRectF.left > visibleRight || sTmpRectF.right < visibleLeft) {
|
||||
if (range[0] == -1) {
|
||||
continue;
|
||||
} else {
|
||||
@@ -1080,15 +1079,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
}
|
||||
}
|
||||
|
||||
sTmpIntPoint[0] = currPage.getMeasuredWidth();
|
||||
Utilities.getDescendantCoordRelativeToParent(currPage, this, sTmpIntPoint, false);
|
||||
if (sTmpIntPoint[0] < 0) {
|
||||
if (range[0] == -1) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
curScreen = i;
|
||||
if (range[0] < 0) {
|
||||
range[0] = curScreen;
|
||||
@@ -1136,8 +1126,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
for (int i = pageCount - 1; i >= 0; i--) {
|
||||
final View v = getPageAt(i);
|
||||
if (v == mDragView) continue;
|
||||
if (mForceDrawAllChildrenNextFrame ||
|
||||
(leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
|
||||
if (leftScreen <= i && i <= rightScreen && shouldDrawChild(v)) {
|
||||
drawChild(canvas, v, drawingTime);
|
||||
}
|
||||
}
|
||||
@@ -1146,7 +1135,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
drawChild(canvas, mDragView, drawingTime);
|
||||
}
|
||||
|
||||
mForceDrawAllChildrenNextFrame = false;
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user