Skip to content

Commit 54ab347

Browse files
author
Romain Guy
committed
Don't create a giant layer for all notifications
Bug #6642475 When expanding the status bar, create one layer per notification instead of a single giant layer for the pile of notifications. This prevents layer creation failure when the total height of the notifications is larger than the maximum allowed texture size in OpenGL ES 2.0. This change only enables layers on notifications that will be visible once the notification area is fully expanded. Change-Id: I3c791a66cf5ac0973f3a65cfcd84b95209d580f3
1 parent 15c9c61 commit 54ab347

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,10 +3926,9 @@ public void debug() {
39263926
}
39273927

39283928
public void dumpGfxInfo(int[] info) {
3929+
info[0] = info[1] = 0;
39293930
if (mView != null) {
39303931
getGfxInfo(mView, info);
3931-
} else {
3932-
info[0] = info[1] = 0;
39333932
}
39343933
}
39353934

core/java/android/view/WindowManagerImpl.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,16 @@ public void dumpGfxInfo(FileDescriptor fd) {
530530

531531
for (int i = 0; i < count; i++) {
532532
ViewRootImpl root = mRoots[i];
533+
String name = getWindowName(root);
534+
pw.printf("\n\t%s", name);
535+
533536
HardwareRenderer renderer = root.getView().mAttachInfo.mHardwareRenderer;
534537
if (renderer != null) {
535538
renderer.dumpGfxInfo(pw);
536539
}
537540
}
538541

539-
pw.println("\nView hierarchy:");
542+
pw.println("\nView hierarchy:\n");
540543

541544
int viewsCount = 0;
542545
int displayListsSize = 0;
@@ -546,15 +549,14 @@ public void dumpGfxInfo(FileDescriptor fd) {
546549
ViewRootImpl root = mRoots[i];
547550
root.dumpGfxInfo(info);
548551

549-
String name = root.getClass().getName() + '@' +
550-
Integer.toHexString(hashCode());
551-
pw.printf(" %s: %d views, %.2f kB (display lists)",
552+
String name = getWindowName(root);
553+
pw.printf(" %s\n %d views, %.2f kB of display lists",
552554
name, info[0], info[1] / 1024.0f);
553555
HardwareRenderer renderer = root.getView().mAttachInfo.mHardwareRenderer;
554556
if (renderer != null) {
555557
pw.printf(", %d frames rendered", renderer.getFrameCount());
556558
}
557-
pw.printf("\n");
559+
pw.printf("\n\n");
558560

559561
viewsCount += info[0];
560562
displayListsSize += info[1];
@@ -570,6 +572,11 @@ public void dumpGfxInfo(FileDescriptor fd) {
570572
}
571573
}
572574

575+
private static String getWindowName(ViewRootImpl root) {
576+
return root.mWindowAttributes.getTitle() + "/" +
577+
root.getClass().getName() + '@' + Integer.toHexString(root.hashCode());
578+
}
579+
573580
public void setStoppedState(IBinder token, boolean stopped) {
574581
synchronized (this) {
575582
if (mViews == null)

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,12 +1376,59 @@ void stopTracking() {
13761376
if (!mTracking)
13771377
return;
13781378
mTracking = false;
1379-
mPile.setLayerType(View.LAYER_TYPE_NONE, null);
1379+
setPileLayers(View.LAYER_TYPE_NONE);
13801380
mVelocityTracker.recycle();
13811381
mVelocityTracker = null;
13821382
mCloseView.setPressed(false);
13831383
}
13841384

1385+
/**
1386+
* Enables or disables layers on the children of the notifications pile.
1387+
*
1388+
* When layers are enabled, this method attempts to enable layers for the minimal
1389+
* number of children. Only children visible when the notification area is fully
1390+
* expanded will receive a layer. The technique used in this method might cause
1391+
* more children than necessary to get a layer (at most one extra child with the
1392+
* current UI.)
1393+
*
1394+
* @param layerType {@link View#LAYER_TYPE_NONE} or {@link View#LAYER_TYPE_HARDWARE}
1395+
*/
1396+
private void setPileLayers(int layerType) {
1397+
final int count = mPile.getChildCount();
1398+
1399+
switch (layerType) {
1400+
case View.LAYER_TYPE_NONE:
1401+
for (int i = 0; i < count; i++) {
1402+
mPile.getChildAt(i).setLayerType(layerType, null);
1403+
}
1404+
break;
1405+
case View.LAYER_TYPE_HARDWARE:
1406+
final int[] location = new int[2];
1407+
mNotificationPanel.getLocationInWindow(location);
1408+
1409+
final int left = location[0];
1410+
final int top = location[1];
1411+
final int right = left + mNotificationPanel.getWidth();
1412+
final int bottom = top + getExpandedViewMaxHeight();
1413+
1414+
final Rect childBounds = new Rect();
1415+
1416+
for (int i = 0; i < count; i++) {
1417+
final View view = mPile.getChildAt(i);
1418+
view.getLocationInWindow(location);
1419+
1420+
childBounds.set(location[0], location[1],
1421+
location[0] + view.getWidth(), location[1] + view.getHeight());
1422+
1423+
if (childBounds.intersects(left, top, right, bottom)) {
1424+
view.setLayerType(layerType, null);
1425+
}
1426+
}
1427+
1428+
break;
1429+
}
1430+
}
1431+
13851432
void incrementAnim(long frameTimeNanos) {
13861433
final long deltaNanos = Math.max(frameTimeNanos - mAnimLastTimeNanos, 0);
13871434
final float t = deltaNanos * 0.000000001f; // ns -> s
@@ -1421,7 +1468,7 @@ void prepareTracking(int y, boolean opening) {
14211468
mCloseView.setPressed(true);
14221469

14231470
mTracking = true;
1424-
mPile.setLayerType(View.LAYER_TYPE_HARDWARE, null);
1471+
setPileLayers(View.LAYER_TYPE_HARDWARE);
14251472
mVelocityTracker = VelocityTracker.obtain();
14261473
if (opening) {
14271474
makeExpandedVisible(true);

0 commit comments

Comments
 (0)