Android review-overdraw

Brief description

The application may draw the same pixel multiple times in a single frame. This situation is called "overdrawing" . Overdrawing is usually unnecessary and is best avoided. It wastes GPU time to render pixels that have nothing to do with what the user sees on the screen, causing performance issues.

Overdraw detection

  • You can use the system's built-in GPU overdrawing debugging tool, which can be turned on in the developer options-debug GPU overdrawing option
  • You can also use other tools, such as AS layout analyzer, etc.

Solve the overdrawing problem

  • Flatten the
    view hierarchy. Too many levels of views are one of the main reasons for overdrawing. Therefore, we need to reduce layout nesting to improve performance.
  • Remove unwanted background from the layout
    By default, the layout has no background, which means that the layout itself will not directly render any content. However, when the layout has a background, it may cause overdrawing.
    Removing unnecessary background can quickly improve rendering performance. The unnecessary background may never be visible because it will be completely covered by any other content drawn on the view by the application. For example, when the system draws a child view on the parent view, it may completely cover the background of the parent view.
  • Reducing Transparency
    The rendering of transparency in the Android system is essentially achieved by drawing opaque pixels on top of the original content pixels, which means that the same screen area will be drawn twice, once for the original content, and once for the original content. With the newly added transparency effect (opaque pixels, that is, the color value channel is different), the pixels drawn the second time will be superimposed on the real view, so the effect of transparency is created. Obviously, the setting of transparency will seriously cause over-drawing.

Guess you like

Origin blog.csdn.net/why1092576787/article/details/114851882