How to make sense of dumpsys SurfaceFlinger

Andi Jay picture Andi Jay · Feb 8, 2014 · Viewed 20.2k times · Source

Is there any documentation on the output of the adb command "dumpsys SurfaceFlinger"?

In particular, I'd like to understand what is the difference between an HWC or GLES layer type, and what does numHwLayers mean?

Here is the section of dumpsys SurfaceFlinger I'm talking about:

  mDebugForceFakeVSync=0
  Display[0] : 768x1280, xdpi=319.790009, ydpi=318.744995, refresh=16666667
  numHwLayers=5, flags=00000000
    type    |  handle  |   hints  |   flags  | tr | blend |  format  |       source crop         |           frame           name
------------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------
       GLES | b7e1c440 | 00000002 | 00000000 | 00 | 00100 | 00000002 | [  334,   56, 1102, 1190] | [    0,   50,  768, 1184] com.android.systemui.ImageWallpaper
       GLES | b7e1d7c8 | 00000002 | 00000000 | 00 | 00105 | 00000001 | [    0,   50,  768, 1184] | [    0,   50,  768, 1184] com.android.launcher/com.android.launcher2.Launcher
       GLES | b7e701e0 | 00000002 | 00000000 | 00 | 00105 | 00000001 | [    0,    0,  768,   50] | [    0,    0,  768,   50] StatusBar
       GLES | b7e1df68 | 00000002 | 00000000 | 00 | 00100 | 00000001 | [    0,    0,  768,   96] | [    0, 1184,  768, 1280] NavigationBar
  FB TARGET | b7dd3ab0 | 00000000 | 00000000 | 00 | 00105 | 00000001 | [    0,    0,  768, 1280] | [    0,    0,  768, 1280] HWC_FRAMEBUFFER_TARGET

Answer

Andi Jay picture Andi Jay · Feb 8, 2014

Ok, I have enough figured out to answer my own question, but if anyone has any additional input, please leave them in the comments. There's some additional stuff encountered which I'll note below that still isn't clear.

First, the link below helps explain a few things about how image rendering and compositing happens through SurfaceFlinger: http://source.android.com/devices/graphics.html

If you noticed in the link, there are two ways images are sent to the display. One is to process images with the GPU before sending them to the display, and the other is to use hardware overlays of the display to bypass the GPU and send images directly to the display. The latter method performs better, but you are limited to a certain number of layers/overlays (usually 4). If you have more layers, things have to get processed by the GPU.

The part of dumpsys SurfaceFlinger which was at the center of my question shows you how many layers there are at the moment dumpsys was called, and if those layers are being handled by the Hardware Composer (HWC) or the GPU (GLES). This explains what HWC and GLES mean. Also, numHwLayers is how many overlays the display supports (usually 4).

Also, there are "source crop" and "frame" coordinates. The source crop is the section of an image that will be displayed. For example, if it's a wallpaper that spans multiple display screens (think about what you see on the home screen when you swipe across screens), then at a given moment you will only need a subsection of that larger wallpaper image to display. This means that source crop is just telling you what section of that overall image you are using at the moment. The frame part of it is where that section of the source image is going to actually be display on the screen.

The code for this section of the dumpsys SurfaceFlinger command is located here: \frameworks\native\services\surfaceflinger\DisplayHardware\HWComposer.cpp

It's in a function called "HWComposer::dump"

The above answers my original question, but below are some additional things I noticed:

It looks like there are more composition types than HWC and GLES. In the code noted above, I see a "BACKGROUND" and a "FB TARGET" composite type. FB TARGET seems to always be present when you type "dumpsys SurfaceFlinger" in adb. I think FB Target is simply the frame buffer the complete image will be written to (someone please confirm this). Even if the device is asleep you see this FB TARGET. What I don't understand is, what is this BACKGROUND type? I can't even take a guess on that one. Please leave a comment if you know what this is.

Thanks!