composer: vts: allocate buffer larger or equal to crop size

Ensure buffer size larger than crop size.

Bug: 175028291
Test: VtsHalGraphicsComposerV2_4TargetTest on Pixel 4, 5
Change-Id: I6528ac6989ca557d9f578b0119715a6688bb6d5d
diff --git a/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp b/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp
index d8312a2..d2d6d7d 100644
--- a/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp
+++ b/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp
@@ -152,9 +152,9 @@
 
     void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
 
-    const native_handle_t* allocate() {
+    const native_handle_t* allocate(int32_t width, int32_t height) {
         return mGralloc->allocate(
-                /*width*/ 64, /*height*/ 64, /*layerCount*/ 1,
+                width, height, /*layerCount*/ 1,
                 static_cast<common::V1_1::PixelFormat>(PixelFormat::RGBA_8888),
                 static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN));
     }
@@ -407,7 +407,10 @@
     mComposerClient->setPowerMode(display.get(), V2_1::IComposerClient::PowerMode::ON);
     mComposerClient->setColorMode_2_3(display.get(), ColorMode::NATIVE, RenderIntent::COLORIMETRIC);
 
-    auto handle = allocate();
+    IComposerClient::FRect displayCrop = display.getCrop();
+    int32_t displayWidth = static_cast<int32_t>(std::ceilf(displayCrop.right - displayCrop.left));
+    int32_t displayHeight = static_cast<int32_t>(std::ceilf(displayCrop.bottom - displayCrop.top));
+    auto handle = allocate(displayWidth, displayHeight);
     ASSERT_NE(nullptr, handle);
 
     Layer layer;
@@ -435,7 +438,7 @@
     ASSERT_EQ(0, mReader->mErrors.size());
 
     mWriter->selectLayer(layer);
-    auto handle2 = allocate();
+    auto handle2 = allocate(displayWidth, displayHeight);
     ASSERT_NE(nullptr, handle2);
 
     mWriter->setLayerBuffer(0, handle2, -1);
@@ -703,4 +706,4 @@
     }
 
     return RUN_ALL_TESTS();
-}
\ No newline at end of file
+}