系列文章目录:
- Android性能优化典范综述
- Android性能优化典范之Render Performance
- Android性能优化典范之Understanding Overdraw
- Android性能优化典范之Understanding VSYNC
- Android性能优化典范之Profile GPU Rendering
技术复核(2026-10-13):本文保留 2015 年的视频摘录和示意图。过度绘制的概念仍然适用;下文补充默认颜色表的版本依据、透明混合的例外和删除背景的前提,不把颜色变浅直接当成性能收益。
当时的视频简介:
One of the most problematic performance problems on Android is the easiest to create; thankfully, it’s also easy to fix.
OVERDRAW is a term used to describe how many times a pixel has been re-drawn in a single frame of rendering. It’s a troublesome issue, because in most cases, pixels that are overdrawn do not end up contributing to the final rendered image. As such, it amounts to wasted work for your GPU and CPU.
Fixing overdraw has everything to do with using the available on-device tools, like Show GPU Overdraw, and then adjusting your view hierarchy in order to reduce areas where it may be occurring.
OverDraw概念
视频开头作者举了一个例子,说如果你是一个粉刷匠,你应该会知道,给墙壁粉刷是一件工作量非常大的工作,而且如果你需要重新粉刷一遍的话(比如对颜色不满意),那么第一次的粉刷就白干了. 同样的道理,如果一个不透明区域完全覆盖了前面画出的内容,前面的部分绘制就可能没有贡献。如果你想兼顾高性能和完美的设计,那么你的程序可能会出现一个性能问题:OverDraw!
Overdraw(过度绘制) 指同一帧里,同一个像素被重复绘制。例如下面重叠的卡片,不透明卡片下面被完全遮住的部分可能做了无用功;但不能把“发生重叠”一律视为浪费。半透明内容、阴影和抗锯齿边缘仍需要底下的颜色参与混合,直接删掉底层会改变画面。实际工作量也受裁剪和渲染器优化影响。官方概念说明


