summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@google.com>2018-08-20 16:42:23 -0700
committerYiwei Zhang <zzyiwei@google.com>2018-08-20 20:30:08 -0700
commitf4e02874b260f85acb7eba2d61fe9af37e290c0f (patch)
tree6c78ee90e1558d2f56460e9dfd2025f07f70a7cf
parent99b4619cfeb1e8ed899ca0a4c72154be6263a98c (diff)
downloadnative-f4e02874b260f85acb7eba2d61fe9af37e290c0f.tar.gz
Get screenshot to exclude black cutout
Bug: b/112869712 Test: long press power button to take screenshots && adb shell screencap && apps to take screenshots and check Change-Id: Ieb83373c9103f9847775eca5788358b567a05b24 Merged-In: Ieb83373c9103f9847775eca5788358b567a05b24
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index d1cc3dcd78..f0c35d163c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4828,6 +4828,16 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
const sp<const DisplayDevice> device(getDisplayDeviceLocked(display));
if (CC_UNLIKELY(device == 0)) return BAD_VALUE;
+ const Rect& dispScissor = device->getScissor();
+ if (!dispScissor.isEmpty()) {
+ sourceCrop.set(dispScissor);
+ // adb shell screencap will default reqWidth and reqHeight to zeros.
+ if (reqWidth == 0 || reqHeight == 0) {
+ reqWidth = uint32_t(dispScissor.width());
+ reqHeight = uint32_t(dispScissor.height());
+ }
+ }
+
DisplayRenderArea renderArea(device, sourceCrop, reqHeight, reqWidth, rotation);
auto traverseLayers = std::bind(std::mem_fn(&SurfaceFlinger::traverseLayersInDisplay), this,