通过查看GPU透支来改善应用程序的渲染时间。

What is Overdraw?

Overdraw happens every time the application asks the system to draw something on top of something else. The “Debug GPU Overdraw” tool overlays colours on top of your screen to indicate how many times a pixel has been redrawn.

译文:过度绘制发生的每一次应用要求系统上别的画的东西。“调试GPU透支”工具覆盖上你的屏幕的色彩显示多少次像素被重绘。

How do I enable the tool Debug GPU Overdraw?


  1. Go to Settings on your device.
  2. Go to Developer Options
  3. Select “Debug GPU Overdraw”.
  4. Select “Show overdraw areas”

你打开你的手机到开发人员工具选项—>调试GPU过度绘制—>显示GPU视图更新,当你运行你的程序时,你看着你的手机的颜色变化,来提高你的布局优化。

What do the different colours mean?

我们可以根据颜色来判断布局是否过度绘制以及根据颜色来判断绘制的程度。

Original colour – 没有过度绘制,只在屏幕上绘制过一次

Blue – 1x – 过度绘制,在屏幕上绘制过2次

Green – 2x – 过度绘制,在屏幕上绘制过3次

Pink – 3x –过度绘制,在屏幕上绘制过4次

Red – 4x – 过度绘制,在屏幕上绘制过5次

How do you fix overdraw?

在上面的例子中,我把背景颜色,设置在相对布局,让主题画的背景。

So going from this:

<RelativeLayout  android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF">

to this:

<RelativeLayout  android:layout_width="match_parent" android:layout_height="match_parent">


就像你可以看到,透支已经最小化。红色的透支了。你可以进一步改进的布局表现真实的色彩和一点蓝色的透支。有些透支是不可避免的。不是所有情况下的透支是背景颜色相关。其他问题也可能存在,如非常复杂的布局层次结构或太多的视图。你的目标应该是一个最大的透支2X(绿色)。

你也可以使用其他工具来看看为什么透支发生的工具如Hierarchy Viewer和GL示踪。

How do you debug overdraw issues? Do you have any other tips to share?
Also, you should totally Download the Book Dash App or contribute on Github!

Links:

http://developer.android.com/tools/performance/debug-gpu-overdraw/index.html

更多相关文章

  1. android 生成圆角和带倒影图片
  2. Android绘制圆形图片(五)
  3. Android(安卓)自定义View之能力分析图
  4. Android(安卓)surface 3 绘制 (的时机 java层)
  5. Android图形系统草稿
  6. Android(安卓)一个自定义View需要实现哪些方法
  7. Android之canvas详解
  8. Android(安卓)系统图形栈(一): OpenGL ES 和 EGL 介绍
  9. android 通过贝塞尔曲线 实现爱心点赞功能

随机推荐

  1. android 用到的技巧集
  2. android 学习笔记10——XML解析
  3. Android之SurfaceView、Camera
  4. android 监听电源键
  5. Android签到功能的实现
  6. android studio 错误总结
  7. Android发送短信
  8. Android(安卓)Studio简单的登录界面
  9. Android(安卓)Custom Views and XML attr
  10. drawlayout