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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章