Fix SurfaceControl#captureLayers when the layer is boundless

- Return an error if the client tries to screenshot a boundless layer without
specifying a crop. Otherwise the client will get a screenshot of 0x0.

- Use the crop in addition to the buffer size when determining the bounds of
the captured layer. This will enable us to capture container layers and color
layers that have a crop specified.

Fixes: 141326137
Test: atest SurfaceFlinger_test
Test: go/wm-smoke
Change-Id: Ibba4c01ad2d6739caee0d85b8d9c2d236fbf0ce0
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index b667a74..b1bb7fd 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -274,7 +274,7 @@
         sp<GraphicBuffer> outBuffer;
         return ScreenshotClient::captureLayers(mBGSurfaceControl->getHandle(),
                                                ui::Dataspace::V0_SRGB, ui::PixelFormat::RGBA_8888,
-                                               Rect(), FRAME_SCALE, &outBuffer);
+                                               Rect(0, 0, 1, 1), FRAME_SCALE, &outBuffer);
     };
     ASSERT_NO_FATAL_FAILURE(checkWithPrivileges<status_t>(condition, NO_ERROR, PERMISSION_DENIED));
 }