Skip to content

Commit f16fc51

Browse files
committed
Remove unnecessary code
Found cleaner way to improve recents scrolling performance on crespo-- instead of rendering the background in the items, instead we just set a window flag. Removed need for a lot of code.
1 parent b442eca commit f16fc51

File tree

7 files changed

+16
-189
lines changed

7 files changed

+16
-189
lines changed

packages/SystemUI/res/values/colors.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<drawable name="notification_item_background_color_pressed">#ff257390</drawable>
2323
<drawable name="ticker_background_color">#ff1d1d1d</drawable>
2424
<drawable name="status_bar_background">#ff000000</drawable>
25-
<drawable name="status_bar_recents_background_solid">#b3000000</drawable>
2625
<drawable name="status_bar_recents_app_thumbnail_background">#88000000</drawable>
2726
<color name="status_bar_recents_app_label_color">#ffffffff</color>
2827
<drawable name="status_bar_notification_row_background_color">#ff090909</drawable>

packages/SystemUI/src/com/android/systemui/recent/RecentsCallback.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,5 @@ public interface RecentsCallback {
2727
void handleOnClick(View selectedView);
2828
void handleSwipe(View selectedView);
2929
void handleLongPress(View selectedView, View anchorView, View thumbnailView);
30-
void handleShowBackground(boolean show);
3130
void dismiss();
32-
33-
// TODO: find another way to get this info from RecentsPanelView
34-
boolean isRecentsVisible();
3531
}

packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,6 @@ public View getChildContentView(View v) {
211211
return v.findViewById(R.id.recent_item);
212212
}
213213

214-
@Override
215-
protected void onLayout (boolean changed, int left, int top, int right, int bottom) {
216-
super.onLayout(changed, left, top, right, bottom);
217-
if (mPerformanceHelper != null) {
218-
mPerformanceHelper.onLayoutCallback();
219-
}
220-
}
221-
222214
@Override
223215
public void draw(Canvas canvas) {
224216
super.draw(canvas);
@@ -322,12 +314,6 @@ public void run() {
322314
});
323315
}
324316

325-
public void onRecentsVisibilityChanged() {
326-
if (mPerformanceHelper != null) {
327-
mPerformanceHelper.updateShowBackground();
328-
}
329-
}
330-
331317
@Override
332318
protected void onVisibilityChanged(View changedView, int visibility) {
333319
super.onVisibilityChanged(changedView, visibility);
@@ -374,9 +360,6 @@ public int numItemsInOneScreenful() {
374360

375361
@Override
376362
public void setLayoutTransition(LayoutTransition transition) {
377-
if (mPerformanceHelper != null) {
378-
mPerformanceHelper.setLayoutTransitionCallback(transition);
379-
}
380363
// The layout transition applies to our embedded LinearLayout
381364
mLinearLayout.setLayoutTransition(transition);
382365
}

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232
import android.provider.Settings;
3333
import android.util.AttributeSet;
3434
import android.util.Log;
35+
import android.view.Display;
3536
import android.view.KeyEvent;
3637
import android.view.LayoutInflater;
3738
import android.view.MenuItem;
3839
import android.view.MotionEvent;
3940
import android.view.View;
4041
import android.view.ViewGroup;
41-
import android.view.ViewRootImpl;
42+
import android.view.WindowManager;
4243
import android.view.accessibility.AccessibilityEvent;
4344
import android.view.animation.AnimationUtils;
4445
import android.widget.AdapterView;
@@ -325,18 +326,6 @@ public void hide(boolean animate) {
325326
}
326327
}
327328

328-
public void handleShowBackground(boolean show) {
329-
if (show) {
330-
mRecentsScrim.setBackgroundResource(R.drawable.status_bar_recents_background_solid);
331-
} else {
332-
mRecentsScrim.setBackgroundDrawable(null);
333-
}
334-
}
335-
336-
public boolean isRecentsVisible() {
337-
return getVisibility() == VISIBLE;
338-
}
339-
340329
public void onAnimationCancel(Animator animation) {
341330
}
342331

@@ -457,9 +446,15 @@ protected void onFinishInflate() {
457446
mRecentsNoApps = findViewById(R.id.recents_no_apps);
458447
mChoreo = new Choreographer(this, mRecentsScrim, mRecentsContainer, mRecentsNoApps, this);
459448

460-
// In order to save space, we make the background texture repeat in the Y direction
461-
if (mRecentsScrim != null && mRecentsScrim.getBackground() instanceof BitmapDrawable) {
462-
((BitmapDrawable) mRecentsScrim.getBackground()).setTileModeY(TileMode.REPEAT);
449+
if (mRecentsScrim != null) {
450+
Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
451+
.getDefaultDisplay();
452+
if (!ActivityManager.isHighEndGfx(d)) {
453+
mRecentsScrim.setBackgroundDrawable(null);
454+
} else if (mRecentsScrim.getBackground() instanceof BitmapDrawable) {
455+
// In order to save space, we make the background texture repeat in the Y direction
456+
((BitmapDrawable) mRecentsScrim.getBackground()).setTileModeY(TileMode.REPEAT);
457+
}
463458
}
464459

465460
mPreloadTasksRunnable = new Runnable() {
@@ -478,21 +473,6 @@ private void createCustomAnimations(LayoutTransition transitioner) {
478473
transitioner.setAnimator(LayoutTransition.DISAPPEARING, null);
479474
}
480475

481-
@Override
482-
protected void onVisibilityChanged(View changedView, int visibility) {
483-
super.onVisibilityChanged(changedView, visibility);
484-
if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + changedView + ", " + visibility + ")");
485-
486-
if (mRecentsContainer instanceof RecentsHorizontalScrollView) {
487-
((RecentsHorizontalScrollView) mRecentsContainer).onRecentsVisibilityChanged();
488-
} else if (mRecentsContainer instanceof RecentsVerticalScrollView) {
489-
((RecentsVerticalScrollView) mRecentsContainer).onRecentsVisibilityChanged();
490-
} else {
491-
throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
492-
}
493-
}
494-
495-
496476
private void updateIcon(ViewHolder h, Drawable icon, boolean show, boolean anim) {
497477
if (icon != null) {
498478
h.iconView.setImageDrawable(icon);

packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java

Lines changed: 2 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -78,77 +78,20 @@ public void onAttachedToWindowCallback(
7878
mScrollView.setVerticalFadingEdgeEnabled(false);
7979
mScrollView.setHorizontalFadingEdgeEnabled(false);
8080
}
81-
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
82-
mCallback = callback;
83-
mLinearLayout = layout;
84-
mAttachedToWindow = true;
85-
mBackgroundDrawable = mContext.getResources()
86-
.getDrawable(R.drawable.status_bar_recents_background_solid).getConstantState();
87-
updateShowBackground();
88-
}
89-
9081
}
9182

9283
public void addViewCallback(View newLinearLayoutChild) {
9384
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
9485
final View view = newLinearLayoutChild;
95-
if (mShowBackground) {
96-
view.setBackgroundDrawable(mBackgroundDrawable.newDrawable());
97-
view.setDrawingCacheEnabled(true);
98-
view.buildDrawingCache();
99-
} else {
100-
view.setBackgroundDrawable(null);
101-
view.setDrawingCacheEnabled(false);
102-
view.destroyDrawingCache();
103-
}
104-
}
105-
}
106-
107-
public void onLayoutCallback() {
108-
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
109-
mScrollView.post(new Runnable() {
110-
public void run() {
111-
updateShowBackground();
112-
}
113-
});
86+
view.setDrawingCacheEnabled(true);
87+
view.buildDrawingCache();
11488
}
11589
}
11690

11791
public void drawCallback(Canvas canvas,
11892
int left, int right, int top, int bottom, int scrollX, int scrollY,
11993
float topFadingEdgeStrength, float bottomFadingEdgeStrength,
12094
float leftFadingEdgeStrength, float rightFadingEdgeStrength) {
121-
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
122-
if (mIsVertical) {
123-
if (scrollY < 0) {
124-
Drawable d = mBackgroundDrawable.newDrawable().getCurrent();
125-
d.setBounds(0, scrollY, mScrollView.getWidth(), 0);
126-
d.draw(canvas);
127-
} else {
128-
final int childHeight = mLinearLayout.getHeight();
129-
if (scrollY + mScrollView.getHeight() > childHeight) {
130-
Drawable d = mBackgroundDrawable.newDrawable().getCurrent();
131-
d.setBounds(0, childHeight, mScrollView.getWidth(),
132-
scrollY + mScrollView.getHeight());
133-
d.draw(canvas);
134-
}
135-
}
136-
} else {
137-
if (scrollX < 0) {
138-
Drawable d = mBackgroundDrawable.newDrawable().getCurrent();
139-
d.setBounds(scrollX, 0, 0, mScrollView.getHeight());
140-
d.draw(canvas);
141-
} else {
142-
final int childWidth = mLinearLayout.getWidth();
143-
if (scrollX + mScrollView.getWidth() > childWidth) {
144-
Drawable d = mBackgroundDrawable.newDrawable().getCurrent();
145-
d.setBounds(childWidth, 0,
146-
scrollX + mScrollView.getWidth(), mScrollView.getHeight());
147-
d.draw(canvas);
148-
}
149-
}
150-
}
151-
}
15295

15396
if ((mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS)
15497
|| USE_DARK_FADE_IN_HW_ACCELERATED_MODE) {
@@ -241,64 +184,4 @@ public int getHorizontalFadingEdgeLengthCallback() {
241184
return mFadingEdgeLength;
242185
}
243186

244-
public void setLayoutTransitionCallback(LayoutTransition transition) {
245-
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
246-
if (transition != null) {
247-
transition.addTransitionListener(new LayoutTransition.TransitionListener() {
248-
@Override
249-
public void startTransition(LayoutTransition transition,
250-
ViewGroup container, View view, int transitionType) {
251-
updateShowBackground();
252-
}
253-
254-
@Override
255-
public void endTransition(LayoutTransition transition,
256-
ViewGroup container, View view, int transitionType) {
257-
updateShowBackground();
258-
}
259-
});
260-
}
261-
}
262-
}
263-
264-
// Turn on/off drawing the background in our ancestor, and turn on/off drawing
265-
// in the items in LinearLayout contained by this scrollview.
266-
// Moving the background drawing to our children, and turning on a drawing cache
267-
// for each of them, gives us a ~20fps gain when Recents is rendered in software
268-
public void updateShowBackground() {
269-
if (!mAttachedToWindow) {
270-
// We haven't been initialized yet-- we'll get called again when we are
271-
return;
272-
}
273-
if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) {
274-
LayoutTransition transition = mLinearLayout.getLayoutTransition();
275-
int linearLayoutSize =
276-
mIsVertical ? mLinearLayout.getHeight() : mLinearLayout.getWidth();
277-
int scrollViewSize =
278-
mIsVertical ? mScrollView.getHeight() : mScrollView.getWidth();
279-
boolean show = !mScrollView.isHardwareAccelerated() &&
280-
(linearLayoutSize > scrollViewSize) &&
281-
!(transition != null && transition.isRunning()) &&
282-
mCallback.isRecentsVisible();
283-
284-
if (!mFirstTime && show == mShowBackground) return;
285-
mShowBackground = show;
286-
mFirstTime = false;
287-
288-
mCallback.handleShowBackground(!show);
289-
for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
290-
View v = mLinearLayout.getChildAt(i);
291-
if (show) {
292-
v.setBackgroundDrawable(mBackgroundDrawable.newDrawable());
293-
v.setDrawingCacheEnabled(true);
294-
v.buildDrawingCache();
295-
} else {
296-
v.setDrawingCacheEnabled(false);
297-
v.destroyDrawingCache();
298-
v.setBackgroundDrawable(null);
299-
}
300-
}
301-
}
302-
}
303-
304187
}

packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ public View getChildContentView(View v) {
218218
return v.findViewById(R.id.recent_item);
219219
}
220220

221-
@Override
222-
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
223-
super.onLayout(changed, left, top, right, bottom);
224-
if (mPerformanceHelper != null) {
225-
mPerformanceHelper.onLayoutCallback();
226-
}
227-
}
228-
229221
@Override
230222
public void draw(Canvas canvas) {
231223
super.draw(canvas);
@@ -329,12 +321,6 @@ public void run() {
329321
});
330322
}
331323

332-
public void onRecentsVisibilityChanged() {
333-
if (mPerformanceHelper != null) {
334-
mPerformanceHelper.updateShowBackground();
335-
}
336-
}
337-
338324
@Override
339325
protected void onVisibilityChanged(View changedView, int visibility) {
340326
super.onVisibilityChanged(changedView, visibility);
@@ -382,9 +368,6 @@ public int numItemsInOneScreenful() {
382368

383369
@Override
384370
public void setLayoutTransition(LayoutTransition transition) {
385-
if (mPerformanceHelper != null) {
386-
mPerformanceHelper.setLayoutTransitionCallback(transition);
387-
}
388371
// The layout transition applies to our embedded LinearLayout
389372
mLinearLayout.setLayoutTransition(transition);
390373
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutP
390390
(opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT));
391391
if (ActivityManager.isHighEndGfx(mDisplay)) {
392392
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
393+
} else {
394+
lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
395+
lp.dimAmount = 0.7f;
393396
}
394397
lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
395398
lp.setTitle("RecentsPanel");

0 commit comments

Comments
 (0)