Skip to content

Commit 1271e2c

Browse files
committed
Remove USE_DISPLAY_LIST_PROPERTIES flag
This flag was still hanging around pending any need to disable DisplayList properties. But things seem stable, so it's time to clean up and simplify the code. At the same time, I reduced redundance in DisplayList dimensions. We used to call drawDisplayList() with width/height parameters that were used to do a clip reject. This is redundant with the DisplayList properties that set the bounds of the DisplayList; the left/right and top/bottom properties represent the same width/height properties formerly used in drawDisplayList(). The new approach is to not pass dimensions to drawDisplayList(), but to instead pull those dimensions directly from the DisplayList when needed. Change-Id: I8871beff03b1d4be95f7c6e079c31a71d31e0c56
1 parent 003952b commit 1271e2c

14 files changed

+199
-321
lines changed

core/java/android/view/GLES20Canvas.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,13 @@ static void setDisplayListName(int displayList, String name) {
358358
private static native void nSetDisplayListName(int displayList, String name);
359359

360360
@Override
361-
public int drawDisplayList(DisplayList displayList, int width, int height,
362-
Rect dirty, int flags) {
361+
public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
363362
return nDrawDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList(),
364-
width, height, dirty, flags);
363+
dirty, flags);
365364
}
366365

367366
private static native int nDrawDisplayList(int renderer, int displayList,
368-
int width, int height, Rect dirty, int flags);
367+
Rect dirty, int flags);
369368

370369
@Override
371370
void outputDisplayList(DisplayList displayList) {

core/java/android/view/HardwareCanvas.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ public void setBitmap(Bitmap bitmap) {
4848
* Invoked after all drawing operation have been performed.
4949
*/
5050
public abstract void onPostDraw();
51-
51+
5252
/**
5353
* Draws the specified display list onto this canvas.
54-
*
54+
*
5555
* @param displayList The display list to replay.
56-
* @param width The width of the display list.
57-
* @param height The height of the display list.
5856
* @param dirty The dirty region to redraw in the next pass, matters only
5957
* if this method returns true, can be null.
6058
* @param flags Optional flags about drawing, see {@link DisplayList} for
@@ -63,8 +61,7 @@ public void setBitmap(Bitmap bitmap) {
6361
* @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW} or
6462
* {@link DisplayList#STATUS_INVOKE}
6563
*/
66-
public abstract int drawDisplayList(DisplayList displayList, int width, int height,
67-
Rect dirty, int flags);
64+
public abstract int drawDisplayList(DisplayList displayList, Rect dirty, int flags);
6865

6966
/**
7067
* Outputs the specified display list to the log. This method exists for use by

core/java/android/view/HardwareRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,7 @@ boolean draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callba
10991099
drawDisplayListStartTime = System.nanoTime();
11001100
}
11011101

1102-
int status = canvas.drawDisplayList(displayList,
1103-
view.getWidth(), view.getHeight(), mRedrawClip,
1102+
int status = canvas.drawDisplayList(displayList, mRedrawClip,
11041103
DisplayList.FLAG_CLIP_CHILDREN);
11051104

11061105
if (mProfileEnabled) {

core/java/android/view/View.java

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,14 +1530,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
15301530
*/
15311531
static final ThreadLocal<Rect> sThreadLocal = new ThreadLocal<Rect>();
15321532

1533-
/**
1534-
* Temporary flag, used to enable processing of View properties in the native DisplayList
1535-
* object instead of during draw(). Soon to be enabled by default for hardware-accelerated
1536-
* apps.
1537-
* @hide
1538-
*/
1539-
public static final boolean USE_DISPLAY_LIST_PROPERTIES = true;
1540-
15411533
/**
15421534
* Map used to store views' tags.
15431535
*/
@@ -8269,7 +8261,7 @@ public void setCameraDistance(float distance) {
82698261
info.mMatrixDirty = true;
82708262

82718263
invalidateViewProperty(false, false);
8272-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8264+
if (mDisplayList != null) {
82738265
mDisplayList.setCameraDistance(-Math.abs(distance) / dpi);
82748266
}
82758267
}
@@ -8311,7 +8303,7 @@ public void setRotation(float rotation) {
83118303
info.mRotation = rotation;
83128304
info.mMatrixDirty = true;
83138305
invalidateViewProperty(false, true);
8314-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8306+
if (mDisplayList != null) {
83158307
mDisplayList.setRotation(rotation);
83168308
}
83178309
}
@@ -8358,7 +8350,7 @@ public void setRotationY(float rotationY) {
83588350
info.mRotationY = rotationY;
83598351
info.mMatrixDirty = true;
83608352
invalidateViewProperty(false, true);
8361-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8353+
if (mDisplayList != null) {
83628354
mDisplayList.setRotationY(rotationY);
83638355
}
83648356
}
@@ -8405,7 +8397,7 @@ public void setRotationX(float rotationX) {
84058397
info.mRotationX = rotationX;
84068398
info.mMatrixDirty = true;
84078399
invalidateViewProperty(false, true);
8408-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8400+
if (mDisplayList != null) {
84098401
mDisplayList.setRotationX(rotationX);
84108402
}
84118403
}
@@ -8444,7 +8436,7 @@ public void setScaleX(float scaleX) {
84448436
info.mScaleX = scaleX;
84458437
info.mMatrixDirty = true;
84468438
invalidateViewProperty(false, true);
8447-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8439+
if (mDisplayList != null) {
84488440
mDisplayList.setScaleX(scaleX);
84498441
}
84508442
}
@@ -8483,7 +8475,7 @@ public void setScaleY(float scaleY) {
84838475
info.mScaleY = scaleY;
84848476
info.mMatrixDirty = true;
84858477
invalidateViewProperty(false, true);
8486-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8478+
if (mDisplayList != null) {
84878479
mDisplayList.setScaleY(scaleY);
84888480
}
84898481
}
@@ -8530,7 +8522,7 @@ public void setPivotX(float pivotX) {
85308522
info.mPivotX = pivotX;
85318523
info.mMatrixDirty = true;
85328524
invalidateViewProperty(false, true);
8533-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8525+
if (mDisplayList != null) {
85348526
mDisplayList.setPivotX(pivotX);
85358527
}
85368528
}
@@ -8576,7 +8568,7 @@ public void setPivotY(float pivotY) {
85768568
info.mPivotY = pivotY;
85778569
info.mMatrixDirty = true;
85788570
invalidateViewProperty(false, true);
8579-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8571+
if (mDisplayList != null) {
85808572
mDisplayList.setPivotY(pivotY);
85818573
}
85828574
}
@@ -8642,7 +8634,7 @@ public void setAlpha(float alpha) {
86428634
} else {
86438635
mPrivateFlags &= ~ALPHA_SET;
86448636
invalidateViewProperty(true, false);
8645-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8637+
if (mDisplayList != null) {
86468638
mDisplayList.setAlpha(alpha);
86478639
}
86488640
}
@@ -8669,7 +8661,7 @@ boolean setAlphaNoInvalidation(float alpha) {
86698661
return true;
86708662
} else {
86718663
mPrivateFlags &= ~ALPHA_SET;
8672-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8664+
if (mDisplayList != null) {
86738665
mDisplayList.setAlpha(alpha);
86748666
}
86758667
}
@@ -8721,7 +8713,7 @@ public final void setTop(int top) {
87218713
int oldHeight = mBottom - mTop;
87228714

87238715
mTop = top;
8724-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8716+
if (mDisplayList != null) {
87258717
mDisplayList.setTop(mTop);
87268718
}
87278719

@@ -8790,7 +8782,7 @@ public final void setBottom(int bottom) {
87908782
int oldHeight = mBottom - mTop;
87918783

87928784
mBottom = bottom;
8793-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8785+
if (mDisplayList != null) {
87948786
mDisplayList.setBottom(mBottom);
87958787
}
87968788

@@ -8853,7 +8845,7 @@ public final void setLeft(int left) {
88538845
int height = mBottom - mTop;
88548846

88558847
mLeft = left;
8856-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8848+
if (mDisplayList != null) {
88578849
mDisplayList.setLeft(left);
88588850
}
88598851

@@ -8869,9 +8861,6 @@ public final void setLeft(int left) {
88698861
}
88708862
mBackgroundSizeChanged = true;
88718863
invalidateParentIfNeeded();
8872-
if (USE_DISPLAY_LIST_PROPERTIES) {
8873-
8874-
}
88758864
}
88768865
}
88778866

@@ -8916,7 +8905,7 @@ public final void setRight(int right) {
89168905
int height = mBottom - mTop;
89178906

89188907
mRight = right;
8919-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
8908+
if (mDisplayList != null) {
89208909
mDisplayList.setRight(mRight);
89218910
}
89228911

@@ -9013,7 +9002,7 @@ public void setTranslationX(float translationX) {
90139002
info.mTranslationX = translationX;
90149003
info.mMatrixDirty = true;
90159004
invalidateViewProperty(false, true);
9016-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9005+
if (mDisplayList != null) {
90179006
mDisplayList.setTranslationX(translationX);
90189007
}
90199008
}
@@ -9050,7 +9039,7 @@ public void setTranslationY(float translationY) {
90509039
info.mTranslationY = translationY;
90519040
info.mMatrixDirty = true;
90529041
invalidateViewProperty(false, true);
9053-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9042+
if (mDisplayList != null) {
90549043
mDisplayList.setTranslationY(translationY);
90559044
}
90569045
}
@@ -9161,7 +9150,7 @@ public void offsetTopAndBottom(int offset) {
91619150
final boolean matrixIsIdentity = mTransformationInfo == null
91629151
|| mTransformationInfo.mMatrixIsIdentity;
91639152
if (matrixIsIdentity) {
9164-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9153+
if (mDisplayList != null) {
91659154
invalidateViewProperty(false, false);
91669155
} else {
91679156
final ViewParent p = mParent;
@@ -9189,7 +9178,7 @@ public void offsetTopAndBottom(int offset) {
91899178

91909179
mTop += offset;
91919180
mBottom += offset;
9192-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9181+
if (mDisplayList != null) {
91939182
mDisplayList.offsetTopBottom(offset);
91949183
invalidateViewProperty(false, false);
91959184
} else {
@@ -9212,7 +9201,7 @@ public void offsetLeftAndRight(int offset) {
92129201
final boolean matrixIsIdentity = mTransformationInfo == null
92139202
|| mTransformationInfo.mMatrixIsIdentity;
92149203
if (matrixIsIdentity) {
9215-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9204+
if (mDisplayList != null) {
92169205
invalidateViewProperty(false, false);
92179206
} else {
92189207
final ViewParent p = mParent;
@@ -9237,7 +9226,7 @@ public void offsetLeftAndRight(int offset) {
92379226

92389227
mLeft += offset;
92399228
mRight += offset;
9240-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
9229+
if (mDisplayList != null) {
92419230
mDisplayList.offsetLeftRight(offset);
92429231
invalidateViewProperty(false, false);
92439232
} else {
@@ -9666,8 +9655,7 @@ void invalidate(boolean invalidateCache) {
96669655
* list properties are not being used in this view
96679656
*/
96689657
void invalidateViewProperty(boolean invalidateParent, boolean forceRedraw) {
9669-
if (!USE_DISPLAY_LIST_PROPERTIES || mDisplayList == null ||
9670-
(mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION) {
9658+
if (mDisplayList == null || (mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION) {
96719659
if (invalidateParent) {
96729660
invalidateParentCaches();
96739661
}
@@ -11759,7 +11747,7 @@ private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) {
1175911747
int layerType = (
1176011748
!(mParent instanceof ViewGroup) || ((ViewGroup)mParent).mDrawLayers) ?
1176111749
getLayerType() : LAYER_TYPE_NONE;
11762-
if (!isLayer && layerType != LAYER_TYPE_NONE && USE_DISPLAY_LIST_PROPERTIES) {
11750+
if (!isLayer && layerType != LAYER_TYPE_NONE) {
1176311751
if (layerType == LAYER_TYPE_HARDWARE) {
1176411752
final HardwareLayer layer = getHardwareLayer();
1176511753
if (layer != null && layer.isValid()) {
@@ -11782,9 +11770,6 @@ private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) {
1178211770

1178311771
computeScroll();
1178411772

11785-
if (!USE_DISPLAY_LIST_PROPERTIES) {
11786-
restoreCount = canvas.save();
11787-
}
1178811773
canvas.translate(-mScrollX, -mScrollY);
1178911774
if (!isLayer) {
1179011775
mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
@@ -11799,16 +11784,11 @@ private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) {
1179911784
}
1180011785
}
1180111786
} finally {
11802-
if (USE_DISPLAY_LIST_PROPERTIES) {
11803-
canvas.restoreToCount(restoreCount);
11804-
}
1180511787
canvas.onPostDraw();
1180611788

1180711789
displayList.end();
11808-
if (USE_DISPLAY_LIST_PROPERTIES) {
11809-
displayList.setCaching(caching);
11810-
}
11811-
if (isLayer && USE_DISPLAY_LIST_PROPERTIES) {
11790+
displayList.setCaching(caching);
11791+
if (isLayer) {
1181211792
displayList.setLeftTopRightBottom(0, 0, width, height);
1181311793
} else {
1181411794
setDisplayListProperties(displayList);
@@ -12400,7 +12380,7 @@ void setDisplayListProperties() {
1240012380
* previously-set transform values
1240112381
*/
1240212382
void setDisplayListProperties(DisplayList displayList) {
12403-
if (USE_DISPLAY_LIST_PROPERTIES && displayList != null) {
12383+
if (displayList != null) {
1240412384
displayList.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom);
1240512385
displayList.setHasOverlappingRendering(hasOverlappingRendering());
1240612386
if (mParent instanceof ViewGroup) {
@@ -12460,8 +12440,7 @@ void setDisplayListProperties(DisplayList displayList) {
1246012440
* to be called from anywhere else other than ViewGroup.drawChild().
1246112441
*/
1246212442
boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
12463-
boolean useDisplayListProperties = USE_DISPLAY_LIST_PROPERTIES && mAttachInfo != null &&
12464-
mAttachInfo.mHardwareAccelerated;
12443+
boolean useDisplayListProperties = mAttachInfo != null && mAttachInfo.mHardwareAccelerated;
1246512444
boolean more = false;
1246612445
final boolean childHasIdentityMatrix = hasIdentityMatrix();
1246712446
final int flags = parent.mGroupFlags;
@@ -12722,8 +12701,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1272212701
}
1272312702
} else {
1272412703
mPrivateFlags &= ~DIRTY_MASK;
12725-
((HardwareCanvas) canvas).drawDisplayList(displayList,
12726-
mRight - mLeft, mBottom - mTop, null, flags);
12704+
((HardwareCanvas) canvas).drawDisplayList(displayList, null, flags);
1272712705
}
1272812706
}
1272912707
} else if (cache != null) {
@@ -13211,7 +13189,7 @@ protected boolean setFrame(int left, int top, int right, int bottom) {
1321113189
mTop = top;
1321213190
mRight = right;
1321313191
mBottom = bottom;
13214-
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
13192+
if (mDisplayList != null) {
1321513193
mDisplayList.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom);
1321613194
}
1321713195

core/java/android/view/ViewGroup.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,12 +2898,10 @@ public void setClipChildren(boolean clipChildren) {
28982898
boolean previousValue = (mGroupFlags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN;
28992899
if (clipChildren != previousValue) {
29002900
setBooleanFlag(FLAG_CLIP_CHILDREN, clipChildren);
2901-
if (USE_DISPLAY_LIST_PROPERTIES) {
2902-
for (int i = 0; i < mChildrenCount; ++i) {
2903-
View child = getChildAt(i);
2904-
if (child.mDisplayList != null) {
2905-
child.mDisplayList.setClipChildren(clipChildren);
2906-
}
2901+
for (int i = 0; i < mChildrenCount; ++i) {
2902+
View child = getChildAt(i);
2903+
if (child.mDisplayList != null) {
2904+
child.mDisplayList.setClipChildren(clipChildren);
29072905
}
29082906
}
29092907
}
@@ -4229,7 +4227,7 @@ public void offsetChildrenTopAndBottom(int offset) {
42294227
final View v = children[i];
42304228
v.mTop += offset;
42314229
v.mBottom += offset;
4232-
if (USE_DISPLAY_LIST_PROPERTIES && v.mDisplayList != null) {
4230+
if (v.mDisplayList != null) {
42334231
v.mDisplayList.offsetTopBottom(offset);
42344232
invalidateViewProperty(false, false);
42354233
}

core/java/android/view/ViewPropertyAnimator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ private void animatePropertyBy(int constantName, float startValue, float byValue
835835
*/
836836
private void setValue(int propertyConstant, float value) {
837837
final View.TransformationInfo info = mView.mTransformationInfo;
838-
DisplayList displayList = View.USE_DISPLAY_LIST_PROPERTIES ? mView.mDisplayList : null;
838+
final DisplayList displayList = mView.mDisplayList;
839839
switch (propertyConstant) {
840840
case TRANSLATION_X:
841841
info.mTranslationX = value;
@@ -997,8 +997,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
997997
// Shouldn't happen, but just to play it safe
998998
return;
999999
}
1000-
boolean useDisplayListProperties = View.USE_DISPLAY_LIST_PROPERTIES &&
1001-
mView.mDisplayList != null;
1000+
boolean useDisplayListProperties = mView.mDisplayList != null;
10021001

10031002
// alpha requires slightly different treatment than the other (transform) properties.
10041003
// The logic in setAlpha() is not simply setting mAlpha, plus the invalidation

0 commit comments

Comments
 (0)