0

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.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Prasanna Aarthi
  • 3,439
  • 4
  • 26
  • 48

1 Answers1

1

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.

Brandon Wuest
  • 206
  • 1
  • 2
  • Thank you for the response.. You mean to say there is no way to cache the textures so that they needn't be redrawn again? – Prasanna Aarthi Sep 22 '14 at 04:20
  • Overdraw isn't necessarily something that can be prevented by caching. Views aren't drawn continuously in Android, they are only drawn when a view is invalidated/dirty. So when views remain static (and can be cached), you are generally only going to take the overdraw performance hit he first time the view is rendered. The problem really comes if you are updating lots of views frequently that overlap - in this instance caching can't help out much since updated views must be redrawn with other views to ensure any blending is accounted for. – Brandon Wuest Sep 22 '14 at 06:36
  • thank you, one thing I dont get is this one "Views aren't drawn continuously" they have to be rendered on screen at an FPS of 30-60 , so will be drawn on the screen continuously.This is how I understand, the first time any graphic will be rendered by the UI thread, after which the textures will be handed over to GPU and it will draw it on the screen at 60 FPS.Please correct me if this is wrong in android. – Prasanna Aarthi Sep 22 '14 at 08:11
  • Views are only drawn when they are changed (or manually invalidated). They are not continuously rendered at a fixed frame rate, only on demand. – Brandon Wuest Sep 22 '14 at 16:41