Skip to content

Commit 526057b

Browse files
committed
Remove redundant computeScroll() call for hw-accelerated views
View.draw() calls computeScroll() to initialize scrolling values correctly. But getDisplayList() also calls computeScroll() for the same reason, resulting in 2 calls to that method for hw-accelerated views. Fix: avoid calling computeScroll() in View.draw() for views with display lists. Change-Id: I57a3862e2d554752cd0fdb862513cbb3dfb3105c
1 parent c09008f commit 526057b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

core/java/android/view/View.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12909,11 +12909,6 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1290912909
mPrivateFlags &= ~INVALIDATED;
1291012910
}
1291112911

12912-
computeScroll();
12913-
12914-
final int sx = mScrollX;
12915-
final int sy = mScrollY;
12916-
1291712912
DisplayList displayList = null;
1291812913
Bitmap cache = null;
1291912914
boolean hasDisplayList = false;
@@ -12960,6 +12955,14 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1296012955
}
1296112956
}
1296212957

12958+
int sx = 0;
12959+
int sy = 0;
12960+
if (!hasDisplayList) {
12961+
computeScroll();
12962+
sx = mScrollX;
12963+
sy = mScrollY;
12964+
}
12965+
1296312966
final boolean hasNoCache = cache == null || hasDisplayList;
1296412967
final boolean offsetForScroll = cache == null && !hasDisplayList &&
1296512968
layerType != LAYER_TYPE_HARDWARE;

0 commit comments

Comments
 (0)