Skip to content

Commit b85967b

Browse files
committed
Re-enabling DisplayList properties
Several issues came up after DisplayList properties were enabled, so they were disabled pending fixes. Those issues have been fixed, so DisplayList properties are once again being enabled by default. This CL both re-enables these properties (in View.java and DisplayListRenderer.h) and fixes the various issues that enabling them caused the first time around. Related issues (all currently marked as Fixed, though that was simply because DL properties were disabled - this CL provides the real fixes now that DL properties are enabled by default): Issue #6198276 Text input broken Issue #6198472 Native crash at pc 00076428 in many different apps in JRM80 Issue #6204173 Date/time picker isn't rendering all parts of UI Issue #6203941 All Apps overscroll effect is rendered weirdly/has flickering Issue #6200058 CAB rendering issue - not drawing items? Issue #6198578 Front camera shows black screen after taking picture. Issue #6232010 Layers not recreated when children change (DisplayList properties) Change-Id: I8b5f9ec342208ecb20d3e6a60d26cf7c6112ec8b
1 parent b3cbd0b commit b85967b

File tree

6 files changed

+60
-80
lines changed

6 files changed

+60
-80
lines changed

core/java/android/view/View.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
14591459
* apps.
14601460
* @hide
14611461
*/
1462-
public static final boolean USE_DISPLAY_LIST_PROPERTIES = false;
1462+
public static final boolean USE_DISPLAY_LIST_PROPERTIES = true;
14631463

14641464
/**
14651465
* Map used to store views' tags.
@@ -7401,7 +7401,7 @@ public void setCameraDistance(float distance) {
74017401

74027402
invalidateViewProperty(false, false);
74037403
if (USE_DISPLAY_LIST_PROPERTIES && mDisplayList != null) {
7404-
mDisplayList.setCameraDistance(distance);
7404+
mDisplayList.setCameraDistance(-Math.abs(distance) / dpi);
74057405
}
74067406
}
74077407

@@ -10747,16 +10747,25 @@ private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) {
1074710747
int layerType = (
1074810748
!(mParent instanceof ViewGroup) || ((ViewGroup)mParent).mDrawLayers) ?
1074910749
getLayerType() : LAYER_TYPE_NONE;
10750-
if (!isLayer && layerType == LAYER_TYPE_HARDWARE && USE_DISPLAY_LIST_PROPERTIES) {
10751-
final HardwareLayer layer = getHardwareLayer();
10752-
if (layer != null && layer.isValid()) {
10753-
canvas.drawHardwareLayer(layer, 0, 0, mLayerPaint);
10750+
if (!isLayer && layerType != LAYER_TYPE_NONE && USE_DISPLAY_LIST_PROPERTIES) {
10751+
if (layerType == LAYER_TYPE_HARDWARE) {
10752+
final HardwareLayer layer = getHardwareLayer();
10753+
if (layer != null && layer.isValid()) {
10754+
canvas.drawHardwareLayer(layer, 0, 0, mLayerPaint);
10755+
} else {
10756+
canvas.saveLayer(0, 0, mRight - mLeft, mBottom - mTop, mLayerPaint,
10757+
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
10758+
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
10759+
}
10760+
caching = true;
1075410761
} else {
10755-
canvas.saveLayer(0, 0,
10756-
mRight - mLeft, mBottom - mTop, mLayerPaint,
10757-
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
10762+
buildDrawingCache(true);
10763+
Bitmap cache = getDrawingCache(true);
10764+
if (cache != null) {
10765+
canvas.drawBitmap(cache, 0, 0, mLayerPaint);
10766+
caching = true;
10767+
}
1075810768
}
10759-
caching = true;
1076010769
} else {
1076110770

1076210771
computeScroll();
@@ -11395,7 +11404,11 @@ void setDisplayListProperties(DisplayList displayList) {
1139511404
mTransformationInfo.mRotation, mTransformationInfo.mRotationX,
1139611405
mTransformationInfo.mRotationY, mTransformationInfo.mScaleX,
1139711406
mTransformationInfo.mScaleY);
11398-
displayList.setCameraDistance(getCameraDistance());
11407+
if (mTransformationInfo.mCamera == null) {
11408+
mTransformationInfo.mCamera = new Camera();
11409+
mTransformationInfo.matrix3D = new Matrix();
11410+
}
11411+
displayList.setCameraDistance(mTransformationInfo.mCamera.getLocationZ());
1139911412
if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == PIVOT_EXPLICITLY_SET) {
1140011413
displayList.setPivotX(getPivotX());
1140111414
displayList.setPivotY(getPivotY());
@@ -11489,8 +11502,12 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1148911502
} else {
1149011503
switch (layerType) {
1149111504
case LAYER_TYPE_SOFTWARE:
11492-
buildDrawingCache(true);
11493-
cache = getDrawingCache(true);
11505+
if (useDisplayListProperties) {
11506+
hasDisplayList = canHaveDisplayList();
11507+
} else {
11508+
buildDrawingCache(true);
11509+
cache = getDrawingCache(true);
11510+
}
1149411511
break;
1149511512
case LAYER_TYPE_HARDWARE:
1149611513
if (useDisplayListProperties) {

core/java/android/view/ViewGroup.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,9 +3906,15 @@ public void invalidateChildFast(View child, final Rect dirty) {
39063906
do {
39073907
if (parent instanceof ViewGroup) {
39083908
ViewGroup parentVG = (ViewGroup) parent;
3909-
parent = parentVG.invalidateChildInParentFast(left, top, dirty);
3910-
left = parentVG.mLeft;
3911-
top = parentVG.mTop;
3909+
if (parentVG.mLayerType != LAYER_TYPE_NONE) {
3910+
// Layered parents should be recreated, not just re-issued
3911+
parentVG.invalidate();
3912+
parent = null;
3913+
} else {
3914+
parent = parentVG.invalidateChildInParentFast(left, top, dirty);
3915+
left = parentVG.mLeft;
3916+
top = parentVG.mTop;
3917+
}
39123918
} else {
39133919
// Reached the top; this calls into the usual invalidate method in
39143920
// ViewRootImpl, which schedules a traversal
@@ -4664,6 +4670,7 @@ public static int getChildMeasureSpec(int spec, int padding, int childDimension)
46644670
public void clearDisappearingChildren() {
46654671
if (mDisappearingChildren != null) {
46664672
mDisappearingChildren.clear();
4673+
invalidate();
46674674
}
46684675
}
46694676

@@ -4775,7 +4782,7 @@ public void endViewTransition(View view) {
47754782
view.mParent = null;
47764783
}
47774784
}
4778-
mGroupFlags |= FLAG_INVALIDATE_REQUIRED;
4785+
invalidate();
47794786
}
47804787
}
47814788
}

core/java/android/widget/TextView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11683,7 +11683,7 @@ void onDraw(Canvas canvas, Layout layout, Path highlight, int cursorOffsetVertic
1168311683
highlight = null;
1168411684
}
1168511685

11686-
if (false /* TEMP patch for bugs 6198276 & 6193544 */ && canHaveDisplayList() && canvas.isHardwareAccelerated()) {
11686+
if (canHaveDisplayList() && canvas.isHardwareAccelerated()) {
1168711687
drawHardwareAccelerated(canvas, layout, highlight, cursorOffsetVertical);
1168811688
} else {
1168911689
layout.draw(canvas, highlight, mHighlightPaint, cursorOffsetVertical);
@@ -11758,7 +11758,7 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
1175811758
hardwareCanvas.onPostDraw();
1175911759
blockDisplayList.end();
1176011760
if (USE_DISPLAY_LIST_PROPERTIES) {
11761-
blockDisplayList.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom);
11761+
blockDisplayList.setLeftTopRightBottom(0, 0, width, height);
1176211762
}
1176311763
}
1176411764
}

libs/hwui/DisplayListRenderer.cpp

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ DisplayList::~DisplayList() {
106106
void DisplayList::initProperties() {
107107
mLeft = 0;
108108
mTop = 0;
109-
mTop = 0;
109+
mRight = 0;
110110
mBottom = 0;
111111
mApplicationScale = -1;
112112
mClipChildren = true;
@@ -121,6 +121,7 @@ void DisplayList::initProperties() {
121121
mScaleY = 1;
122122
mPivotX = 0;
123123
mPivotY = 0;
124+
mCameraDistance = 0;
124125
mMatrixDirty = false;
125126
mMatrixFlags = 0;
126127
mPrevWidth = -1;
@@ -686,7 +687,7 @@ void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
686687
mTransformMatrix->get(8));
687688
}
688689
}
689-
if (mAlpha < 1) {
690+
if (mAlpha < 1 && !mCaching) {
690691
// TODO: should be able to store the size of a DL at record time and not
691692
// have to pass it into this call. In fact, this information might be in the
692693
// location/size info that we store with the new native transform data.
@@ -765,34 +766,6 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t width, ui
765766
}
766767
}
767768

768-
void DisplayList::transformRect(float left, float top, float right, float bottom, Rect& result) {
769-
result.left = left + mLeft;
770-
result.top = top + mTop;
771-
result.right = right + mLeft;
772-
result.bottom = bottom + mTop;
773-
if (mMatrixFlags != 0) {
774-
if (mMatrixFlags == TRANSLATION) {
775-
result.left += mTranslationX;
776-
result.top += mTranslationY;
777-
result.right += mTranslationX;
778-
result.bottom += mTranslationY;
779-
} else {
780-
updateMatrix();
781-
SkRect r;
782-
r.fLeft = result.left;
783-
r.fTop = result.top;
784-
r.fRight = result.right;
785-
r.fBottom = result.bottom;
786-
mTransformMatrix->mapRect(&r);
787-
result.left = r.fLeft;
788-
result.top = r.fTop;
789-
result.right = r.fRight;
790-
result.bottom = r.fBottom;
791-
}
792-
}
793-
}
794-
795-
796769
/**
797770
* Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
798771
* in the output() function, since that function processes the same list of opcodes for the
@@ -822,6 +795,12 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, uint32_t width,
822795
restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
823796
}
824797
setViewProperties(renderer, width, height, level);
798+
if (USE_DISPLAY_LIST_PROPERTIES && renderer.quickReject(0, 0, width, height)) {
799+
DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
800+
renderer.restoreToCount(restoreTo);
801+
renderer.endMark();
802+
return false;
803+
}
825804

826805
DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
827806
int saveCount = renderer.getSaveCount() - 1;
@@ -974,6 +953,9 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, uint32_t width,
974953
float x = getFloat();
975954
float y = getFloat();
976955
SkPaint* paint = getPaint(renderer);
956+
if (mCaching && mMultipliedAlpha < 255) {
957+
paint->setAlpha(mMultipliedAlpha);
958+
}
977959
DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
978960
bitmap, x, y, paint);
979961
renderer.drawBitmap(bitmap, x, y, paint);
@@ -1421,24 +1403,11 @@ status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
14211403
uint32_t width, uint32_t height, Rect& dirty, int32_t flags, uint32_t level) {
14221404
// dirty is an out parameter and should not be recorded,
14231405
// it matters only when replaying the display list
1424-
float top = 0;
1425-
float left = 0;
1426-
float right = width;
1427-
float bottom = height;
1428-
if (USE_DISPLAY_LIST_PROPERTIES) {
1429-
Rect transformedRect;
1430-
displayList->transformRect(left, top, right, bottom, transformedRect);
1431-
left = transformedRect.left;
1432-
top = transformedRect.top;
1433-
right = transformedRect.right;
1434-
bottom = transformedRect.bottom;
1435-
}
1436-
const bool reject = quickReject(left, top, right, bottom);
1437-
uint32_t* location = addOp(DisplayList::DrawDisplayList, reject);
1406+
1407+
addOp(DisplayList::DrawDisplayList);
14381408
addDisplayList(displayList);
14391409
addSize(width, height);
14401410
addInt(flags);
1441-
addSkip(location);
14421411
return DrawGlInfo::kStatusDone;
14431412
}
14441413

libs/hwui/DisplayListRenderer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace uirenderer {
5151

5252
// Set to 1 to enable native processing of View properties. 0 by default. Eventually this
5353
// will go away and we will always use this approach for accelerated apps.
54-
#define USE_DISPLAY_LIST_PROPERTIES 0
54+
#define USE_DISPLAY_LIST_PROPERTIES 1
5555

5656
#define TRANSLATION 0x0001
5757
#define ROTATION 0x0002
@@ -379,8 +379,6 @@ class DisplayList {
379379
mCaching = caching;
380380
}
381381

382-
void transformRect(float left, float top, float right, float bottom, Rect& result);
383-
384382
private:
385383
void init();
386384

libs/hwui/OpenGLRenderer.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,19 +1323,8 @@ void OpenGLRenderer::finishDrawTexture() {
13231323

13241324
status_t OpenGLRenderer::drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height,
13251325
Rect& dirty, int32_t flags, uint32_t level) {
1326-
float top = 0;
1327-
float left = 0;
1328-
float right = width;
1329-
float bottom = height;
1330-
if (USE_DISPLAY_LIST_PROPERTIES) {
1331-
Rect transformedRect;
1332-
displayList->transformRect(left, top, right, bottom, transformedRect);
1333-
left = transformedRect.left;
1334-
top = transformedRect.top;
1335-
right = transformedRect.right;
1336-
bottom = transformedRect.bottom;
1337-
}
1338-
if (quickReject(left, top, right, bottom)) {
1326+
1327+
if (!USE_DISPLAY_LIST_PROPERTIES && quickReject(0, 0, width, height)) {
13391328
return false;
13401329
}
13411330

0 commit comments

Comments
 (0)