SurfaceFlinger: captureScreen buffer set GRALLOC_USAGE_HW_COMPOSER usage
CaptureScreen buffer should set GRALLOC_USAGE_HW_COMPOSER usage, as this buffer
will be composited as one layer by composer at the short time when do screenshot.
Some platforms will check GRALLOC_USAGE_HW_COMPOSER usage and guarantee buffer
be allocated as physical continuous memory, as some composer hardware such as DPU
2D can't handle no-continuous memory without MMU. Without GRALLOC_USAGE_HW_COMPOSER
usage, these platforms will meet problem.
Dumpsys SurfaceFinger information:
Display 21441949190532096 HWC layers:
-------------------------------------------------------------------------------------------
Layer name
Z | Window Type | Comp Type | Transform | Disp Frame (LTRB) | Source Crop (LTRB)
-------------------------------------------------------------------------------------------
SnapshotStartingWindow for taskId=1297#0
rel 0 | 3 | DEVICE | 0 | 0 0 1920 1080 | 0.0 0.0 1920.0 1080.0
- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - -
StatusBar#0
rel 0 | 2000 | DEVICE | 0 | 0 0 1920 31 | 0.0 0.0 1920.0 31.0
- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - -
NavigationBar0#0
rel 0 | 2019 | DEVICE | 0 | 0 1019 1920 1080 | 0.0 0.0 1920.0 61.0
- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - -
Sprite#0
331000 | 0 | DEVICE | 0 | 951 537 979 573 | 0.0 0.0 28.0 36.0
- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - -
0xf16e6c0623e0: 8100.00 KiB | 1920 (1920) x 1080 | 1 | 1 | 0x333 | screenshot
Bug: 153476418
Change-Id: I73addd5058924a370965f7d704c6bcf05848d821
Merged-In: I73addd5058924a370965f7d704c6bcf05848d821
Signed-off-by: Richard Liu <xuegang.liu@nxp.com>
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1788560..0ba8d7a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5935,7 +5935,7 @@
// TODO(b/116112787) Make buffer usage a parameter.
const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
- GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
+ GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER;
*outBuffer =
getFactory().createGraphicBuffer(renderArea.getReqWidth(), renderArea.getReqHeight(),
static_cast<android_pixel_format>(reqPixelFormat), 1,