Reputation: 3453
I am trying to understand how the the recently announced "GPU over draw" feature works. Why are certain parts of the screen drawn twice or thrice? How does this really work? Does this have anything to do with nesting of layouts? How to minimize this over draw. In windows phone we have an option like Bitmapcachemode
which will cache the redraw and prevent re drawing over and over again. Is there anything similar to this in Android? (The snippet below is from official Google docs)
With the latest version of glass, developers have an option of turning on GPU over draw.When you turn this setting on, the system will color in each pixel on the screen depending on how many times it was drawn in the last paint cycle. This setting helps you debug performance issues with deeply nested layouts or complex paint logic.
Pixels drawn in their original color were only drawn once. Pixels shaded in blue were drawn twice. Pixels shaded in green were drawn three times. Pixels shaded in light red were drawn four times. Pixels shaded in dark red were drawn five or more times.
Source - Google official docs.
Upvotes: 0
Views: 297
Reputation: 206
The GPU overdraw feature is simply a debugging tool for visualizing overdraw. Excessive overdraw can cause poor drawing/animation performance as it eats up time on the UI thread.
This feature has been present in Android for some time, Glass simply exposed a menu option to turn it on. See the "Visualizing overdraw" section of http://www.curious-creature.org/docs/android-performance-case-study-1.html for more information.
Overdraw is not necessarily caused by nested layouts. Overdraw occurs when you have views over other views that draw to the same region of the screen. For instance, it is common to set a background on your activity, but then have a full screen view that also has a background. In this instance, you are drawing every pixel on the screen at least 2 times. To fix this specific issue, you can remove the background on the activity since it is never visible due to the child view.
Currently Android does not have the ability to automatically detect and prevent overdraw, so it is on the developer to account for this in their implementation.
Upvotes: 1