Android中TextureView和SurfaceView的根本区别

结论

命令: adb shell dumpsys SurfaceFlinger | grep -C40 "Allocated buffers:"

GUI: 不同的图像进行composite(混合),效率一部分取决于 composite的工具

  1. 应用的Window对应于Layer,Surface,Layer(Surface)内有BufferQueue,BufferQueue内有不定数量的Buffer。
  2. TextureView增加了两个Buffer,Layer不变
    • 融合采用OpenGLES的composite(混合)
    • OpenGLES 也是有hard(GPU)、soft(CPU)两种实现方式,Android手机一般都是hard实现
    • 也就是说在Android中TextureView 基本采用GPU composite
  3. SurfaceView是增加Layer
    • 采用HardWareComposite,专用硬件来composite
  4. BufferQueue往往2个buffer

The Hardware Composer (HWC) HAL composites layers received from SurfaceFlinger, reducing the amount of composition OpenGL ES (GLES) and the GPU perform.
The HWC abstracts objects, such as overlays and 2D blitters, to composite surfaces and communicates with specialized window composition hardware to composite windows. Use the HWC to composite windows instead of having SurfaceFlinger composite with the GPU. Most GPUs aren’t optimized for composition, and when the GPU composes layers from SurfaceFlinger, apps can’t use the GPU for their own rendering.

引用文档

TextureView

从列表Activity,调出入带有TextureView的Activity, TextureView用于视频播放(起初不播)

  1. 普通Activity
AppledeMacBook-Pro-8:~ apple$ adb shell dumpsys SurfaceFlinger  | grep -C40 "Allocated buffers:"
    0x7faa81f460: count=-1
    0x7faa81f4b0: count=-1
    0x7faa81f500: count=-1
    0x7faa81f550: count=-1
    0x7faa81f5a0: count=-1
    0x7faa81f640: count=-1
    0x7faae3a670: count=-1
h/w composer state:
  h/w composer present and enabled
Hardware Composer state (version 01050000):
  mDebugForceFakeVSync=0
  Display[0] configurations (* current):
    * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16666666, colorMode=0
  numHwLayers=4, flags=00000000
    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
       HWC | 7faa81aae0 | 0002 | 0000 | 00 | 0100 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | com.google.grafika/com.android.grafika.MainActivity
       HWC | 7fa6a47460 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   72.0 |    0,    0, 1080,   72 | StatusBar
       HWC | 7faa81b920 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   42.0 |    0, 1878, 1080, 1920 | UpSlideTransparentView
 FB TARGET | 7faae30f40 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET

-------- Snapdragon Display Manager --------
-----------------------
device type: 0
state: 1, vsync on: 0, max. mixer stages: 4
num configs: 1, active config index: 0
res:1080 x 1920, dpi:403.41 x 403.04, fps:60,vsync period: 16666666

ROI(L T R B) : LEFT(0 0 1080 1920)

|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
| Idx |  Comp Type  |  Split | WB |  Pipe |    W x H    |          Format          |  Src Rect (L T R B) |  Dst Rect (L T R B) |  Z |    Flags   | Deci(HxV) | CS | Range|
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   0 |         SDE | Comp-1 |  - | 0x040 | 1088 x 1920 |           RGBA_8888_UBWC |    0    0 1080 1920 |    0    0 1080 1920 |  0 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   1 |         SDE | Comp-1 |  - | 0x010 | 1088 x   80 |           RGBA_8888_UBWC |    0    0 1080   72 |    0    0 1080   72 |  1 | 0x00000002 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   2 |         SDE | Comp-1 |  - | 0x008 | 1088 x   48 |           RGBA_8888_UBWC |    0    0 1080   42 |    0 1878 1080 1920 |  2 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|

Allocated buffers:
0x7fa6a46aa0: 8160.00 KiB | 1080 (1088) x 1920 |        2 | 0x20000900 | com.android.systemui.ImageWallpaper
0x7fa6a46e00:   42.00 KiB |   66 ( 128) x   84 |        1 | 0x00008933 | Sprite
0x7fa6a47460:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7fa6af6120:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faa81a2a0:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81a660:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81aae0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.MainActivity
0x7faa81b920:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faa81b9e0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x00000900 | 
0x7faa81bb00: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x00000900 | com.google.grafika/com.android.grafika.MainActivity
0x7faae30e80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30ee0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30f40: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
Total allocated (estimate): 58437.00 KB

进入含有TextureView,但TextureView不显示的Activity

AppledeMacBook-Pro-8:~ apple$ adb shell dumpsys SurfaceFlinger  | grep -C40 "Allocated buffers:"
    0x7faa81f460: count=-1
    0x7faa81f4b0: count=-1
    0x7faa81f500: count=-1
    0x7faa81f550: count=-1
    0x7faa81f5a0: count=-1
    0x7faa81f640: count=-1
    0x7faae3a670: count=-1
h/w composer state:
  h/w composer present and enabled
Hardware Composer state (version 01050000):
  mDebugForceFakeVSync=0
  Display[0] configurations (* current):
    * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16666666, colorMode=0
  numHwLayers=4, flags=00000000
    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
       HWC | 7faa81aa80 | 0002 | 0000 | 00 | 0100 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | com.google.grafika/com.android.grafika.PlayMovieActivity
       HWC | 7faa81a660 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   72.0 |    0,    0, 1080,   72 | StatusBar
       HWC | 7faa81b920 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   42.0 |    0, 1878, 1080, 1920 | UpSlideTransparentView
 FB TARGET | 7faae30f40 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET

-------- Snapdragon Display Manager --------
-----------------------
device type: 0
state: 1, vsync on: 0, max. mixer stages: 4
num configs: 1, active config index: 0
res:1080 x 1920, dpi:403.41 x 403.04, fps:60,vsync period: 16666666

ROI(L T R B) : LEFT(0 0 1080 1920)

|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
| Idx |  Comp Type  |  Split | WB |  Pipe |    W x H    |          Format          |  Src Rect (L T R B) |  Dst Rect (L T R B) |  Z |    Flags   | Deci(HxV) | CS | Range|
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   0 |         SDE | Comp-1 |  - | 0x040 | 1088 x 1920 |           RGBA_8888_UBWC |    0    0 1080 1920 |    0    0 1080 1920 |  0 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   1 |         SDE | Comp-1 |  - | 0x010 | 1088 x   80 |           RGBA_8888_UBWC |    0    0 1080   72 |    0    0 1080   72 |  1 | 0x00000002 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   2 |         SDE | Comp-1 |  - | 0x008 | 1088 x   48 |           RGBA_8888_UBWC |    0    0 1080   42 |    0 1878 1080 1920 |  2 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|

Allocated buffers:
0x7fa6a455a0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x00000900 | 
0x7fa6a459c0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieActivity
0x7fa6a46aa0: 8160.00 KiB | 1080 (1088) x 1920 |        2 | 0x20000900 | com.android.systemui.ImageWallpaper
0x7fa6a46e00:   42.00 KiB |   66 ( 128) x   84 |        1 | 0x00008933 | Sprite
0x7fa6a47460:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7fa6af6120:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faa81a2a0:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81a660:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81aa80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieActivity
0x7faa81b920:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faae30e80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30ee0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30f40: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
Total allocated (estimate): 58437.00 KB

显示TextureView

AppledeMacBook-Pro-8:~ apple$ adb shell dumpsys SurfaceFlinger  | grep -C40 "Allocated buffers:"
    0x7faa81f460: count=-1
    0x7faa81f4b0: count=-1
    0x7faa81f500: count=-1
    0x7faa81f550: count=-1
    0x7faa81f5a0: count=-1
    0x7faa81f640: count=-1
    0x7faae3a670: count=-1
h/w composer state:
  h/w composer present and enabled
Hardware Composer state (version 01050000):
  mDebugForceFakeVSync=0
  Display[0] configurations (* current):
    * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16666666, colorMode=0
  numHwLayers=4, flags=00000000
    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
       HWC | 7fa6af64e0 | 0002 | 0000 | 00 | 0100 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | com.google.grafika/com.android.grafika.PlayMovieActivity
       HWC | 7fa6a47460 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   72.0 |    0,    0, 1080,   72 | StatusBar
       HWC | 7faa81b920 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   42.0 |    0, 1878, 1080, 1920 | UpSlideTransparentView
 FB TARGET | 7faae30f40 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET

-------- Snapdragon Display Manager --------
-----------------------
device type: 0
state: 1, vsync on: 0, max. mixer stages: 4
num configs: 1, active config index: 0
res:1080 x 1920, dpi:403.41 x 403.04, fps:60,vsync period: 16666666

ROI(L T R B) : LEFT(0 0 1080 1920)

|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
| Idx |  Comp Type  |  Split | WB |  Pipe |    W x H    |          Format          |  Src Rect (L T R B) |  Dst Rect (L T R B) |  Z |    Flags   | Deci(HxV) | CS | Range|
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   0 |         SDE | Comp-1 |  - | 0x040 | 1088 x 1920 |           RGBA_8888_UBWC |    0    0 1080 1920 |    0    0 1080 1920 |  0 | 0x00000002 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   1 |         SDE | Comp-1 |  - | 0x010 | 1088 x   80 |           RGBA_8888_UBWC |    0    0 1080   72 |    0    0 1080   72 |  1 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   2 |         SDE | Comp-1 |  - | 0x008 | 1088 x   48 |           RGBA_8888_UBWC |    0    0 1080   42 |    0 1878 1080 1920 |  2 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|

Allocated buffers:
0x7fa6a459c0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieActivity
0x7fa6a46aa0: 8160.00 KiB | 1080 (1088) x 1920 |        2 | 0x20000900 | com.android.systemui.ImageWallpaper
0x7fa6a46e00:   42.00 KiB |   66 ( 128) x   84 |        1 | 0x00008933 | Sprite
0x7fa6a47460:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7fa6af6120:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7fa6af64e0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieActivity
0x7faa81a2a0:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81a660:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81aa80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieActivity
0x7faa81b920:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faae30e80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30ee0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30f40: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
Total allocated (estimate): 58437.00 KB

可以看到

  • 普通的Activity,初始化时有两个buffer,大小相同,即BufferQueue默然含有 2 个buffer
  • 显示TextureView时,Buffer加了一个Activity的
  • Layer始终保持4个
    • 应用 Activity
    • StatusBar
    • UpSlideTransparentView (不知道干什么,但是有)
    • HWC_FRAMEBUFFER_TARGET (屏幕Target)
  • 从最终日志,可推断出BufferQueue中分配的Buffer (buffer在BufferQueue的dequeue操作中创建)
    • 应用3个(两个+TextureView)、StatusBar(3个)、FramebufferSurface (3个)、等等

SurfaceView

从普通列表,跳转到带有Surface的Activity,SurfaceView用于播视频(起初没有波)

  1. 跳转到SurfaceActivity
AppledeMacBook-Pro-8:~ apple$ adb shell dumpsys SurfaceFlinger  | grep -C40 "Allocated buffers:"
    0x7faa81f550: count=-1
    0x7faa81f5a0: count=-1
    0x7faa81f640: count=-1
    0x7faae3a670: count=-1
h/w composer state:
  h/w composer present and enabled
Hardware Composer state (version 01050000):
  mDebugForceFakeVSync=0
  Display[0] configurations (* current):
    * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16666666, colorMode=0
  numHwLayers=5, flags=00000000
    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
       HWC | 00000000 | 0002 | 80000000 | 00 | 0105 | ? ffffffff  |    0.0,    0.0,   -1.0,   -1.0 |   48,  408, 1032, 1872 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
       HWC | 7faa81ad80 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
       HWC | 7fa6a47460 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   72.0 |    0,    0, 1080,   72 | StatusBar
       HWC | 7faa81b920 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   42.0 |    0, 1878, 1080, 1920 | UpSlideTransparentView
 FB TARGET | 7faae30e80 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET

-------- Snapdragon Display Manager --------
-----------------------
device type: 0
state: 1, vsync on: 0, max. mixer stages: 4
num configs: 1, active config index: 0
res:1080 x 1920, dpi:403.41 x 403.04, fps:60,vsync period: 16666666

ROI(L T R B) : LEFT(0 0 1080 1920)

|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
| Idx |  Comp Type  |  Split | WB |  Pipe |    W x H    |          Format          |  Src Rect (L T R B) |  Dst Rect (L T R B) |  Z |    Flags   | Deci(HxV) | CS | Range|
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   0 |         SDE | Comp-1 |  - | 0x040 |  984 x 1464 |                ARGB_8888 |    0    0  984 1464 |   48  408 1032 1872 |  0 | 0x00000004 |   0 x   0 |  0 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   1 |         SDE | Comp-1 |  - | 0x010 | 1088 x 1920 |           RGBA_8888_UBWC |    0    0 1080 1920 |    0    0 1080 1920 |  1 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   2 |         SDE | Comp-1 |  - | 0x008 | 1088 x   80 |           RGBA_8888_UBWC |    0    0 1080   72 |    0    0 1080   72 |  2 | 0x00000002 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   3 |         SDE | Comp-1 |  - | 0x001 | 1088 x   48 |           RGBA_8888_UBWC |    0    0 1080   42 |    0 1878 1080 1920 |  3 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|

Allocated buffers:
0x7fa6a46aa0: 8160.00 KiB | 1080 (1088) x 1920 |        2 | 0x20000900 | com.android.systemui.ImageWallpaper
0x7fa6a46e00:   42.00 KiB |   66 ( 128) x   84 |        1 | 0x00008933 | Sprite
0x7fa6a47460:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7fa6af6120:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faa81a2a0:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81a600: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7faa81a660:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81ad80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7faa81b920:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faae30e80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30ee0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30f40: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
Total allocated (estimate): 50277.00 KB

可以看到多了一个Layer,SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity

  1. 运行SurfaceView播视频
AppledeMacBook-Pro-8:~ apple$ adb shell dumpsys SurfaceFlinger  | grep -C40 "Allocated buffers:"
    0x7faa81f550: count=-1
    0x7faa81f5a0: count=-1
    0x7faa81f640: count=-1
    0x7faae3a670: count=-1
h/w composer state:
  h/w composer present and enabled
Hardware Composer state (version 01050000):
  mDebugForceFakeVSync=0
  Display[0] configurations (* current):
    * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16666666, colorMode=0
  numHwLayers=5, flags=00000000
    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
       HWC | 7fa6a47400 | 0002 | 0000 | 00 | 0100 | ? 7fa30c06  |    0.0,    0.0,  320.0,  240.0 |   48,  408, 1032, 1146 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
       HWC | 7faa81a600 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
       HWC | 7fa6a47460 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   72.0 |    0,    0, 1080,   72 | StatusBar
       HWC | 7faa81b920 | 0002 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0,   42.0 |    0, 1878, 1080, 1920 | UpSlideTransparentView
 FB TARGET | 7faae30f40 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET

-------- Snapdragon Display Manager --------
-----------------------
device type: 0
state: 1, vsync on: 0, max. mixer stages: 4
num configs: 1, active config index: 0
res:1080 x 1920, dpi:403.41 x 403.04, fps:60,vsync period: 16666666

ROI(L T R B) : LEFT(0 0 1080 1920)

|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
| Idx |  Comp Type  |  Split | WB |  Pipe |    W x H    |          Format          |  Src Rect (L T R B) |  Dst Rect (L T R B) |  Z |    Flags   | Deci(HxV) | CS | Range|
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   0 |         SDE | Comp-1 |  - | 0x001 |  384 x  256 |    Y_CBCR_420_VENUS_UBWC |    0    0  320  240 |   48  408 1032 1146 |  0 | 0x00000000 |   0 x   0 |  0 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   1 |         SDE | Comp-1 |  - | 0x040 | 1088 x 1920 |           RGBA_8888_UBWC |    0    0 1080 1920 |    0    0 1080 1920 |  1 | 0x00000002 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   2 |         SDE | Comp-1 |  - | 0x010 | 1088 x   80 |           RGBA_8888_UBWC |    0    0 1080   72 |    0    0 1080   72 |  2 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|
|   3 |         SDE | Comp-1 |  - | 0x008 | 1088 x   48 |           RGBA_8888_UBWC |    0    0 1080   42 |    0 1878 1080 1920 |  3 | 0x00000000 |   0 x   0 |  6 |  0 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|----|------|

Allocated buffers:
0x7fa6a46aa0: 8160.00 KiB | 1080 (1088) x 1920 |        2 | 0x20000900 | com.android.systemui.ImageWallpaper
0x7fa6a46c80: unknown     |  320 ( 384) x  240 | 7FA30C06 | 0x02002900 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7fa6a46e00:   42.00 KiB |   66 ( 128) x   84 |        1 | 0x00008933 | Sprite
0x7fa6a47400: unknown     |  320 ( 384) x  240 | 7FA30C06 | 0x02002900 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7fa6a47460:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7fa6af6120:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faa81a2a0:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81a600: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7faa81a660:  306.00 KiB | 1080 (1088) x   72 |        1 | 0x20000900 | StatusBar
0x7faa81ad80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20000900 | com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
0x7faa81b920:  178.50 KiB | 1080 (1088) x   42 |        1 | 0x20000900 | UpSlideTransparentView
0x7faae30e80: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30ee0: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
0x7faae30f40: 8160.00 KiB | 1080 (1088) x 1920 |        1 | 0x20001a00 | FramebufferSurface
Total allocated (estimate): 50277.00 KB

多了两个SurfaceView的Buffer

0x7fa6a46c80: unknown     |  320 ( 384) x  240 | 7FA30C06 | 0x02002900 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity

0x7fa6a47400: unknown     |  320 ( 384) x  240 | 7FA30C06 | 0x02002900 | SurfaceView - com.google.grafika/com.android.grafika.PlayMovieSurfaceActivity
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章