summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-12-04 16:25:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-12-04 16:25:50 +0000
commit373ed37cd3f83cc9f55b698d64eccf708f2b4e7f (patch)
treed5725edc4b523bbc7a6f2fbec5f747252ceb9986 /services/surfaceflinger/SurfaceFlinger.cpp
parentfcdc7ad83658d63b17557aab68484468724644b4 (diff)
parentefc42e2badd2be4e3404cc16619dd3d85d37a7e7 (diff)
Merge "Fix SurfaceControl#captureLayers when the layer is boundless"
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8cd7223267..f3d32247b1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5089,14 +5089,21 @@ status_t SurfaceFlinger::captureLayers(
return PERMISSION_DENIED;
}
+ Rect parentSourceBounds = parent->getCroppedBufferSize(parent->getCurrentState());
if (sourceCrop.width() <= 0) {
crop.left = 0;
- crop.right = parent->getBufferSize(parent->getCurrentState()).getWidth();
+ crop.right = parentSourceBounds.getWidth();
}
if (sourceCrop.height() <= 0) {
crop.top = 0;
- crop.bottom = parent->getBufferSize(parent->getCurrentState()).getHeight();
+ crop.bottom = parentSourceBounds.getHeight();
+ }
+
+ if (crop.isEmpty() || frameScale <= 0.0f) {
+ // Error out if the layer has no source bounds (i.e. they are boundless) and a source
+ // crop was not specified, or an invalid frame scale was provided.
+ return BAD_VALUE;
}
reqWidth = crop.width() * frameScale;
reqHeight = crop.height() * frameScale;