结论
GUI: 不同的图像进行composite(混合),效率一部分取决于 composite的工具
- 应用的Window对应于Layer,Surface,Layer(Surface)内有BufferQueue,BufferQueue内有不定数量的Buffer。
- Layer (或Surface)<----包含---- 1个BufferQueue<----包含---- 多个Buffer (往往是三个 The BufferQueue for a display surface is typically configured for triple-buffering.)
- 而 BufferQueue 又分为生产端、消费端。
- TextureView增加了两个Buffer,Layer不变
- 融合采用OpenGLES的composite(混合)
- OpenGLES 也是有hard(GPU)、soft(CPU)两种实现方式,Android手机一般都是hard实现
- 也就是说在Android中TextureView 基本采用GPU composite
- SurfaceView增加Layer (Buffer自然随之增加)
- 融合采用HardWareComposite,专用硬件来composite
- Layer是有HWC进行混合的,是有硬件上的数量限制的
- 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.
Additionally, using SurfaceView objects adds two layers, which isn’t ideal because of the limitations on the number of overlays available on the hardware.
注意这个文档是说 用2个SurfaceView(对方视频播放、自己视频播放)去做视频会议,会增加2个layer。 这不是理想的解决方案,因为硬件对于layer是有数量限制的。
引用文档
实验
实验命令: adb shell dumpsys SurfaceFlinger | grep -C40 "Allocated buffers:"
TextureView
从列表Activity,调出入带有TextureView的Activity, 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 | 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 |
|-----|-------------|--------|----|-------|-------------|--------------------------|---------------------|---------------------|----|------------|-----------|--