dumpsys SurfaceFlinger
显示开启了那些特殊宏
Build configuration: [sf PRESENT_TIME_OFFSET=0 FORCE_HWC_FOR_RBG_TO_YUV=0 MAX_VIRT_DISPLAY_DIM=0 RUNNING_WITHOUT_SYNC_FRAMEWORK=0 NUM_FRAMEBUFFER_SURFACE_BUFFERS=3] [libui] [libgui]
显示外接显示硬件的相关信息
Display identification data:
Display 0 (HWC display 0): no identification data
sync 机制
Sync configuration: [using: EGL_ANDROID_native_fence_sync EGL_KHR_wait_sync]
有 EGL_ANDROID_native_fence_sync、EGL_KHR_fence_sync和EGL_KHR_wait_sync,其中一二是互斥的,三可以与一二共存
VSync 相关
Scheduler:
+ Idle timer: off
+ Touch timer: off
+ Use content detection: off
ScreenOff: 0d00:00:01.822
60fps: 0d00:49:22.933
app phase: 1000000 ns SF phase: 1000000 ns
early app phase: 1000000 ns early SF phase: 1000000 ns
GL early app phase: 1000000 ns GL early SF phase: 1000000 ns
next VSYNC threshold: 9223372036854775807 ns
present offset: 0 ns VSYNC period: 16666666 ns
DesiredDisplayConfigSpecs (DisplayManager): default config ID: 0, primary range: [0.00 60.00], app request range: [0.00 inf]
(config override by backdoor: no)
app: state=Idle VSyncState={displayId=0, count=528}
pending events (count=0):
connections (count=14):
Connection{0xb4000079672bb4f0, VSyncRequest::None}
Connection{0xb4000079672b9600, VSyncRequest::None}
Connection{0xb4000079672dfe00, VSyncRequest::None}
Connection{0xb4000079672e8f10, VSyncRequest::None}
Connection{0xb4000079672e0a60, VSyncRequest::None}
Connection{0xb4000079672e8990, VSyncRequest::None}
Connection{0xb4000079672eb2d0, VSyncRequest::None}
Connection{0xb4000079672e7440, VSyncRequest::None}
Connection{0xb4000079672ebbc0, VSyncRequest::None}
Connection{0xb4000079672ecae0, VSyncRequest::None}
Connection{0xb4000079672ee0e0, VSyncRequest::None}
Connection{0xb4000079672eef50, VSyncRequest::None}
Connection{0xb4000079672e95f0, VSyncRequest::None}
Connection{0xb4000079672daad0, VSyncRequest::None}
present fences are used
mPeriod: 16671000 ns (59.984 fps)
mPhase: 28247 ns
mError: 0 ns (sqrt=0.0)
mNumResyncSamplesSincePresent: 6 (limit 4)
mNumResyncSamples: 6 (max 32)
mResyncSamples:
4391093643000
4391110312000 (+16669000)
4391127051000 (+16739000)
4391143619000 (+16568000)
4391160300000 (+16681000)
4391176961000 (+16661000)
mPresentFences [8]:
[invalid fence]
[invalid fence]
[invalid fence]
[invalid fence]
[invalid fence]
[invalid fence]
[invalid fence]
[invalid fence]
current monotonic time: 4398044752848
StaticScreenStats
Static screen stats:
< 1 frames: 2.747 s (0.1%)
< 2 frames: 3.628 s (0.1%)
< 3 frames: 0.477 s (0.0%)
< 4 frames: 0.534 s (0.0%)
< 5 frames: 3.227 s (0.1%)
< 6 frames: 2.945 s (0.1%)
< 7 frames: 0.205 s (0.0%)
7+ frames: 2536.853 s (99.5%)
统计显示丢帧
Total missed frame count: 244
HWC missed frame count: 6
GPU missed frame count: 237
显示需要进行合成 Layer 详情(mDrawingState)
Visible layers (count = 43)
GraphicBufferProducers: 5, max 4096
Composition layers
* Layer 0xb400007a8729d420 (com.android.systemui.ImageWallpaper#0)
isSecure=false geomUsesSourceCrop=true geomBufferUsesDisplayInverseTransform=false geomLayerTransform 0x00000000 (ROT_0 ) 0x05 (SCALE TRANSLATE )
1.6500 0.0000 -96.0000
0.0000 1.6500 -516.0000
0.0000 0.0000 1.0000
geomBufferSize=[0 0 1280 1280] geomContentCrop=[0 0 1280 1280] geomCrop=[0 0 -1 -1] geomBufferTransform=0
Region transparentRegionHint (this=0xb4000079d728b300, count=1)
[ 0, 0, 0, 0]
geomLayerBounds=[58.181816 312.727264 1221.817993 967.272705] shadowRadius=0.000000
blend=NONE (1) alpha=1.000000 backgroundBlurRadius=0
type=2013 appId=10115 composition type=DEVICE (2)
buffer: slot=0 buffer=0xb40000799728b630
sideband stream=0x0
color=[0.000000 0.000000 0.000000]
isOpaque=true hasProtectedContent=false isColorspaceAgnostic=false dataspace=UNKNOWN (0) hdr metadata types=0 colorTransform=[[1.000,0.000,0.000,0.000][0.000,1.000,0.000,0.000][0.000,0.000,1.000,0.000][0.000,0.000,0.000,1.000]]
* Layer 0xb400007a772b8430 (Task=1#0)
isSecure=false geomUsesSourceCrop=false geomBufferUsesDisplayInverseTransform=false geomLayerTransform 0x00000000 (ROT_0 ) 0x00 (IDENTITY )
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000
geomBufferSize=[0 0 -1 -1] geomContentCrop=[0 0 -1 -1] geomCrop=[0 0 -1 -1] geomBufferTransform=0
Region transparentRegionHint (this=0xb4000079d72896e0, count=1)
[ 0, 0, 0, 0]
geomLayerBounds=[0.000000 0.000000 1920.000000 1080.000000] shadowRadius=0.000000
blend=NONE (1) alpha=1.000000 backgroundBlurRadius=0
type=0 appId=0 composition type=INVALID (0)
buffer: slot=-1 buffer=0x0
sideband stream=0x0
color=[0.000000 0.000000 0.000000]
isOpaque=true hasProtectedContent=false isColorspaceAgnostic=false dataspace=UNKNOWN (0) hdr metadata types=0 colorTransform=[[1.000,0.000,0.000,0.000][0.000,1.000,0.000,0.000][0.000,0.000,1.000,0.000][0.000,0.000,0.000,1.000]]
显示 mDrawingState 中 Layer 详情,调用 LayerFECompositionState::dump() 函数。注意 mDrawingState 保存的是经过 handleTransactionLocked() 处理过的 Layer。
显示设备(DisplayDevice)详情
Displays (1 entries)
+ DisplayDevice{0, internal, primary, "Internal display"}
powerMode=On (2), activeConfig=0, Composition Display State: ["Internal display"]
isVirtual=false hwcId=0
isEnabled=true isSecure=true usesClientComposition=true usesDeviceComposition=false flipClientTarget=false reusedClientComposition=false layerStack=0 layerStackInternal=true
transform 0x00000000 (ROT_0 ) 0x00 (IDENTITY )
1.0000 0.0000 -0.0000
0.0000 1.0000 -0.0000
0.0000 0.0000 1.0000
bounds=[0 0 3840 1080] frame=[0 0 1920 1080] viewport=[0 0 1920 1080] sourceClip=[0 0 1920 1080] destinationClip=[0 0 1920 1080] needsFiltering=false
colorMode=NATIVE (0) renderIntent=COLORIMETRIC (0) dataspace=UNKNOWN (0) colorTransformMatrix=[[1.000,0.000,0.000,0.000][0.000,1.000,0.000,0.000][0.000,0.000,1.000,0.000][0.000,0.000,0.000,1.000]]target dataspace=UNKNOWN (0)
Composition Display Color State:
HWC Support: wideColorGamut=false hdr10plus=false hdr10=false hlg=false dv=false metadata=0
Composition RenderSurface State:
size=[3840 1080] ANativeWindow=0xb400007a6734b830 (format 1) flips=487
FramebufferSurface: dataspace: Default(0)
mAbandoned=0
- BufferQueue mMaxAcquiredBufferCount=2 mMaxDequeuedBufferCount=1
mDequeueBufferCannotBlock=0 mAsyncMode=0
mQueueBufferCanDrop=0 mLegacyBufferDrop=1
default-size=[3840x1080] default-format=1 transform-hint=00 frame-counter=301
mTransformHintInUse=00 mAutoPrerotation=0
FIFO(0):
(mConsumerName=FramebufferSurface, mConnectedApi=1, mConsumerUsageBits=6656, mId=1f5000000000, producer=[3185:/vendor/bin/hw/android.hardware.graphics.composer@2.1-service], consumer=[8016:/system/bin/surfaceflinger])
Slots:
>[02:0xb400007997287190] state=ACQUIRED 0xb400007997285450 frame=301 [3840x1080: 0, 1]
[01:0xb4000079972869b0] state=FREE 0xb400007997285e70 frame=299 [3840x1080: 0, 1]
[00:0xb400007997287730] state=FREE 0xb4000079972847f0 frame=300 [3840x1080: 0, 1]
2 Layers
- Output Layer 0xb400007a072a1380(com.android.systemui.ImageWallpaper#0)
Region visibleRegion (this=0xb400007a072a1398, count=1)
[ 0, 0, 1920, 1080]
Region visibleNonTransparentRegion (this=0xb400007a072a1400, count=1)
[ 0, 0, 1920, 1080]
Region coveredRegion (this=0xb400007a072a1468, count=1)
[ 0, 0, 1920, 1080]
Region output visibleRegion (this=0xb400007a072a14d0, count=1)
[ 0, 0, 1920, 1080]
Region shadowRegion (this=0xb400007a072a1538, count=1)
[ 0, 0, 0, 0]
forceClientComposition=false clearClientTarget=false displayFrame=[0 0 1920 1080] sourceCrop=[58.000000 313.000000 1222.000000 967.000000] bufferTransform=0 (0) dataspace=UNKNOWN (0) z-index=0
hwc: layer=0x0810 composition=CLIENT (1)
- Output Layer 0xb400007a072a5500(com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0)
Region visibleRegion (this=0xb400007a072a5518, count=1)
[ 0, 0, 1920, 1080]
Region visibleNonTransparentRegion (this=0xb400007a072a5580, count=1)
[ 0, 0, 1920, 1080]
Region coveredRegion (this=0xb400007a072a55e8, count=1)
[ 0, 0, 0, 0]
Region output visibleRegion (this=0xb400007a072a5650, count=1)
[ 0, 0, 1920, 1080]
Region shadowRegion (this=0xb400007a072a56b8, count=1)
[ 0, 0, 0, 0]
forceClientComposition=false clearClientTarget=false displayFrame=[0 0 1920 1080] sourceCrop=[0.000000 0.000000 1920.000000 1080.000000] bufferTransform=0 (0) dataspace=UNKNOWN (0) z-index=1
hwc: layer=0x0812 composition=CLIENT (1)
-
最开始是系统默认的显示设备(DisplayDevice)相关配置
-
然后是 DisplayDevice 中的 FramebufferSurface 和 Output 相关信息,FramebufferSurface 的 producer 为 /vendor/bin/hw/android.hardware.graphics.composer@2.1-service,是由于 SurfaceFlinger::processDisplayAdded() 函数在 composer 进程回调函数中调用
-
最后部分的2个 Layer 属于 OutputLayer,是需要提交到 hwc 合成的 Layer
显示 mCurrentState 中属于当前显示设备部分的详情
Display 0 HWC layers:
-----------------------------------------------------------------------------------------------------------------------------------------------
Layer name
Z | Window Type | Comp Type | Transform | Disp Frame (LTRB) | Source Crop (LTRB) | Frame Rate (Explicit) [Focused]
-----------------------------------------------------------------------------------------------------------------------------------------------
com.android.systemui.ImageWallpaper#0
rel 0 | 2013 | CLIENT | 0 | 0 0 1920 1080 | 58.0 313.0 1222.0 967.0 | [ ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0
rel 0 | 1 | CLIENT | 0 | 0 0 1920 1080 | 0.0 0.0 1920.0 1080.0 | [*]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
此处与上面的 mDrawingState 中保存 Layer 对应,
HWC 中 Layer 详情
h/w composer state:
h/w composer enabled
-- HWC2 Version HWC2-1.3.1 by bin.li@rock-chips.com --
DisplayId=0, Connector 346, Type = DSI-1, Connector state = DRM_MODE_CONNECTED
NumHwLayers=2, activeModeId=3, 3840x1080p60.00, colorMode = 0, bStandardSwitchResolution=0
------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+------------
id | z | sf-type | hwc-type | handle | transform | blnd | source crop (l,t,r,b) | frame | dataspace | name
------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+------------
0016 | 000 | Client | Client | 00b400007965af5210 | None | None | 58.0, 313.0, 1222.0, 967.0 | 0, 0, 1920, 1080 | 0 | com.android.systemui.ImageWallpaper#0
0018 | 001 | Client | Client | 00b400007965af8a50 | None | Premultipl | 0.0, 0.0, 1920.0, 1080.0 | 0, 0, 1920, 1080 | 0 | com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0
------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+------------
DrmHwcLayer Dump:
DrmHwcLayer[ 16] Buffer[w/h/s/format]=[1280,1280,1280, 2] Fourcc=XB24 Transform=None (0x1) Blend[a=255]=NONE source_crop[l,t,r,b]=[ 58, 313, 1222, 967] display_frame[l,t,r,b]=[ 0, 0,1920,1080],skip=0,afbcd=1
DrmHwcLayer[ 18] Buffer[w/h/s/format]=[1920,1080,1920, 1] Fourcc=AB24 Transform=None (0x1) Blend[a=255]=PREMULT source_crop[l,t,r,b]=[ 0, 0, 1920, 1080] display_frame[l,t,r,b]=[ 0, 0,1920,1080],skip=0,afbcd=1
DrmHwcFBtar[ 0] Buffer[w/h/s/format]=[3840,1080,3840, 1] Fourcc=AB24 Transform=None (0x1) Blend[a=255]=PREMULT source_crop[l,t,r,b]=[ 0, 0, 3840, 1080] display_frame[l,t,r,b]=[ 0, 0,3840,1080],afbcd=1
显示 SurfaceFlinger 分配的 GraphicBuffer
DrmHwcLayer Dump:
DrmHwcLayer[ 16] Buffer[w/h/s/format]=[1280,1280,1280, 2] Fourcc=XB24 Transform=None (0x1) Blend[a=255]=NONE source_crop[l,t,r,b]=[ 58, 313, 1222, 967] display_frame[l,t,r,b]=[ 0, 0,1920,1080],skip=0,afbcd=1
DrmHwcLayer[ 18] Buffer[w/h/s/format]=[1920,1080,1920, 1] Fourcc=AB24 Transform=None (0x1) Blend[a=255]=PREMULT source_crop[l,t,r,b]=[ 0, 0, 1920, 1080] display_frame[l,t,r,b]=[ 0, 0,1920,1080],skip=0,afbcd=1
DrmHwcLayer[ 123] Buffer[w/h/s/format]=[ 44, 56, 48, 1] Fourcc=AB24 Transform=None (0x1) Blend[a=255]=PREMULT source_crop[l,t,r,b]=[ 0, 0, 44, 56] display_frame[l,t,r,b]=[ 947, 839, 991, 895],skip=0,afbcd=0
DrmHwcFBtar[ 0] Buffer[w/h/s/format]=[3840,1080,3840, 1] Fourcc=AB24 Transform=None (0x1) Blend[a=255]=PREMULT source_crop[l,t,r,b]=[ 0, 0, 3840, 1080] display_frame[l,t,r,b]=[ 0, 0,3840,1080],afbcd=1
GraphicBufferAllocator buffers:
0xb4000079972847f0: unknown | 3840 ( 0) x 1080 | 1 | 1 | 0x1a00 | FramebufferSurface
0xb400007997284b50: unknown | 1 ( 0) x 1 | 1 | 1 | 0x300 | placeholder
0xb400007997285450: unknown | 3840 ( 0) x 1080 | 1 | 1 | 0x1a00 | FramebufferSurface
0xb400007997285e70: unknown | 3840 ( 0) x 1080 | 1 | 1 | 0x1a00 | FramebufferSurface
0xb4000079972884b0: unknown | 1920 ( 0) x 1080 | 1 | 1 | 0x40000000000b00 | com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0
0xb40000799728a670: unknown | 1920 ( 0) x 1080 | 1 | 1 | 0x40000000000b00 | com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0
0xb40000799728b870: unknown | 1280 ( 0) x 1280 | 1 | 2 | 0x40000000000b00 | com.android.systemui.ImageWallpaper#0
0xb40000799728bbd0: 10.50 KiB | 44 ( 48) x 56 | 1 | 1 | 0x8933 | Sprite#0
0xb40000799728e9f0: unknown | 1920 ( 0) x 1080 | 1 | 1 | 0x40000000000b00 | com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0
Total allocated by GraphicBufferAllocator (estimate): 10.50 KB
Imported gralloc buffers:
+ name:BLAST Consumer0, id:940597837995, size:3.6e+03KiB, w/h:1280x720, usage: 0x830, req fmt:1, fourcc/mod:875708993/0, compressed: false
planes: R/G/B/A: w/h:1280x720, stride:5120 bytes, size:3686400
+ name:Sprite#0, id:940597837992, size:10KiB, w/h:44x56, usage: 0x8933, req fmt:1, fourcc/mod:875708993/0, compressed: false
planes: R/G/B/A: w/h:44x56, stride:192 bytes, size:10752
+ name:com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0, id:940597837978, size:8.3e+03KiB, w/h:1920x1080, usage: 0x40000000000b00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:1920x1088, stride:7680 bytes, size:8486912
+ name:com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0, id:940597837977, size:8.3e+03KiB, w/h:1920x1080, usage: 0x40000000000b00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:1920x1088, stride:7680 bytes, size:8486912
+ name:com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher#0, id:940597837975, size:8.3e+03KiB, w/h:1920x1080, usage: 0x40000000000b00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:1920x1088, stride:7680 bytes, size:8486912
+ name:FramebufferSurface, id:940597837949, size:1.7e+04KiB, w/h:3840x1080, usage: 0x1a00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:3840x1088, stride:15360 bytes, size:16972800
+ name:com.android.systemui.ImageWallpaper#0, id:940597837964, size:6.5e+03KiB, w/h:1280x1280, usage: 0x40000000000b00, req fmt:2, fourcc/mod:875709016/576460752303423489, compressed: true
planes: R/G/B: w/h:1280x1280, stride:5120 bytes, size:6656000
+ name:FramebufferSurface, id:940597837948, size:1.7e+04KiB, w/h:3840x1080, usage: 0x1a00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:3840x1088, stride:15360 bytes, size:16972800
+ name:FramebufferSurface, id:940597837947, size:1.7e+04KiB, w/h:3840x1080, usage: 0x1a00, req fmt:1, fourcc/mod:875708993/576460752303423489, compressed: true
planes: R/G/B/A: w/h:3840x1088, stride:15360 bytes, size:16972800
+ name:placeholder, id:940597837946, size:0.062KiB, w/h:1x1, usage: 0x300, req fmt:1, fourcc/mod:875708993/0, compressed: false
planes: R/G/B/A: w/h:1x1, stride:64 bytes, size:64
Total imported by gralloc: 8.5e+04KiB
-
第一部分显示由 SurfaceFlinger 分配的 GraphicBuffer,注意使用 BLASTBufferQueue 不会显示在此处,它由应用端分配
-
第二部分显示 SurfaceFlinger 使用过得 GraphicBuffer,注意如果使用 BLASTBufferQueue 会显示在此处,如上面的"BLAST Consumer0"
按照相互的关联,显示 mDrawingState 中所有的 Layer
+ ContainerLayer (Root#0)
Region TransparentRegion (this=0 count=0)
Region VisibleRegion (this=0 count=0)
Region SurfaceDamageRegion (this=0 count=0)
layerStack= 0, z= 0, pos=(0,0), size=( 0, 0), crop=[ 0, 0, -1, -1], cornerRadius=0.000000, isProtected=0, isOpaque=0, invalidate=1, dataspace=Default, defaultPixelFormat=Unknown/None, backgroundBlurRadius=0, color=(0.000,0.000,0.000,1.000), flags=0x00000002, tr=[0.00, 0.00][0.00, 0.00]
parent=none
zOrderRelativeOf=none
activeBuffer=[ 0x 0: 0,Unknown/None], tr=[0.00, 0.00][0.00, 0.00] queued-frames=0, mRefreshPending=0, metadata={}, cornerRadiusCrop=[0.00, 0.00, 0.00, 0.00], shadowRadius=0.000,
+ ContainerLayer (mWindowContainers#0)
Region TransparentRegion (this=0 count=0)
Region VisibleRegion (this=0 count=0)
Region SurfaceDamageRegion (this=0 count=0)
layerStack= 0, z= 0, pos=(0,0), size=( 0, 0), crop=[ 0, 0, -1, -1], cornerRadius=0.000000, isProtected=0, isOpaque=0, invalidate=1, dataspace=Default, defaultPixelFormat=Unknown/None, backgroundBlurRadius=0, color=(0.000,0.000,0.000,1.000), flags=0x00000000, tr=[0.00, 0.00][0.00, 0.00]
parent=Root#0
zOrderRelativeOf=none
activeBuffer=[ 0x 0: 0,Unknown/None], tr=[0.00, 0.00][0.00, 0.00] queued-frames=0, mRefreshPending=0, metadata={}, cornerRadiusCrop=[0.00, 0.00, 0.00, 0.00], shadowRadius=0.000,
Android系统SurfaceFlinger服务的显示配置与同步机制分析
9717





