Adding support for different Mapper versions in IComposer VTS tests
Bug: 135139498
Test: build, boot, VtsHalGraphicsComposerV2_<1,2,3>TargetTest,
Change-Id: I05e2832c64d4c06eb4afd64c3323d7edbd19a5f4
diff --git a/graphics/composer/2.2/vts/functional/Android.bp b/graphics/composer/2.2/vts/functional/Android.bp
index b62f302..13e03c6 100644
--- a/graphics/composer/2.2/vts/functional/Android.bp
+++ b/graphics/composer/2.2/vts/functional/Android.bp
@@ -30,6 +30,7 @@
],
static_libs: [
"android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.allocator@3.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.1-vts",
@@ -39,6 +40,8 @@
"android.hardware.graphics.mapper@2.0-vts",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@2.1-vts",
+ "android.hardware.graphics.mapper@3.0",
+ "android.hardware.graphics.mapper@3.0-vts",
],
header_libs: [
"android.hardware.graphics.composer@2.1-command-buffer",
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
index 2534196..eef0433 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
@@ -36,7 +36,6 @@
using common::V1_1::Dataspace;
using common::V1_1::PixelFormat;
using mapper::V2_1::IMapper;
-using mapper::V2_1::vts::Gralloc;
using V2_1::Display;
using V2_1::Layer;
using V2_1::vts::TestCommandReader;
@@ -269,14 +268,11 @@
layer->write(mWriter);
// This following buffer call should have no effect
- IMapper::BufferDescriptorInfo bufferInfo{};
- bufferInfo.width = mDisplayWidth;
- bufferInfo.height = mDisplayHeight;
- bufferInfo.layerCount = 1;
- bufferInfo.format = PixelFormat::RGBA_8888;
- bufferInfo.usage =
- static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
- const native_handle_t* bufferHandle = mGralloc->allocate(bufferInfo);
+ PixelFormat format = PixelFormat::RGBA_8888;
+ uint64_t usage =
+ static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
+ const native_handle_t* bufferHandle =
+ mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, format, usage);
mWriter->setLayerBuffer(0, bufferHandle, -1);
// expected color for each pixel
@@ -345,24 +341,21 @@
// create client target buffer
uint32_t clientStride;
- IMapper::BufferDescriptorInfo clientInfo;
- clientInfo.width = layer->mInfo.width;
- clientInfo.height = layer->mInfo.height;
- clientInfo.layerCount = layer->mInfo.layerCount;
- clientInfo.format = PixelFormat::RGBA_8888;
- clientInfo.usage =
- static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
- BufferUsage::COMPOSER_CLIENT_TARGET);
+ PixelFormat clientFormat = PixelFormat::RGBA_8888;
+ uint64_t clientUsage =
+ static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
+ BufferUsage::COMPOSER_CLIENT_TARGET);
const native_handle_t* clientBufferHandle =
- mGralloc->allocate(clientInfo, /*import*/ true, &clientStride);
+ mGralloc->allocate(layer->mWidth, layer->mHeight, layer->mLayerCount, clientFormat,
+ clientUsage, /*import*/ true, &clientStride);
ASSERT_NE(nullptr, clientBufferHandle);
void* clientBufData =
- mGralloc->lock(clientBufferHandle, clientInfo.usage, layer->mAccessRegion, -1);
+ mGralloc->lock(clientBufferHandle, clientUsage, layer->mAccessRegion, -1);
- ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(clientInfo.width, clientInfo.height,
+ ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(layer->mWidth, layer->mHeight,
clientStride, clientBufData,
- clientInfo.format, expectedColors));
+ clientFormat, expectedColors));
int clientFence = mGralloc->unlock(clientBufferHandle);
if (clientFence != -1) {
sync_wait(clientFence, -1);
@@ -411,14 +404,13 @@
auto deviceLayer =
std::make_shared<TestBufferLayer>(mComposerClient, mGralloc, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight / 2, PixelFormat::RGBA_8888);
- std::vector<IComposerClient::Color> deviceColors(deviceLayer->mInfo.width *
- deviceLayer->mInfo.height);
- ReadbackHelper::fillColorsArea(deviceColors, deviceLayer->mInfo.width,
- {0, 0, static_cast<int32_t>(deviceLayer->mInfo.width),
- static_cast<int32_t>(deviceLayer->mInfo.height)},
+ std::vector<IComposerClient::Color> deviceColors(deviceLayer->mWidth * deviceLayer->mHeight);
+ ReadbackHelper::fillColorsArea(deviceColors, deviceLayer->mWidth,
+ {0, 0, static_cast<int32_t>(deviceLayer->mWidth),
+ static_cast<int32_t>(deviceLayer->mHeight)},
GREEN);
- deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->mInfo.width),
- static_cast<int32_t>(deviceLayer->mInfo.height)});
+ deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->mWidth),
+ static_cast<int32_t>(deviceLayer->mHeight)});
deviceLayer->setZOrder(10);
ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors));
deviceLayer->write(mWriter);
@@ -433,30 +425,25 @@
execute();
ASSERT_EQ(0, mReader->mErrors.size());
- IMapper::BufferDescriptorInfo clientInfo;
- clientInfo.width = mDisplayWidth;
- clientInfo.height = mDisplayHeight;
- clientInfo.layerCount = 1;
- clientInfo.format = PixelFormat::RGBA_8888;
- clientInfo.usage =
- static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
- BufferUsage::COMPOSER_CLIENT_TARGET);
-
+ uint64_t clientUsage =
+ static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
+ BufferUsage::COMPOSER_CLIENT_TARGET);
uint32_t clientStride;
const native_handle_t* clientBufferHandle =
- mGralloc->allocate(clientInfo, /*import*/ true, &clientStride);
+ mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, PixelFormat::RGBA_8888,
+ clientUsage, /*import*/ true, &clientStride);
ASSERT_NE(nullptr, clientBufferHandle);
- IMapper::Rect clientAccessRegion;
+ AccessRegion clientAccessRegion;
clientAccessRegion.left = 0;
clientAccessRegion.top = 0;
clientAccessRegion.width = mDisplayWidth;
clientAccessRegion.height = mDisplayHeight;
- void* clientData = mGralloc->lock(clientBufferHandle, clientInfo.usage, clientAccessRegion, -1);
- std::vector<IComposerClient::Color> clientColors(clientInfo.width * clientInfo.height);
- ReadbackHelper::fillColorsArea(clientColors, clientInfo.width, clientFrame, RED);
- ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(clientInfo.width, clientInfo.height,
- clientStride, clientData, clientInfo.format,
+ void* clientData = mGralloc->lock(clientBufferHandle, clientUsage, clientAccessRegion, -1);
+ std::vector<IComposerClient::Color> clientColors(mDisplayWidth * mDisplayHeight);
+ ReadbackHelper::fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
+ ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mDisplayWidth, mDisplayHeight, clientStride,
+ clientData, PixelFormat::RGBA_8888,
clientColors));
int clientFence = mGralloc->unlock(clientBufferHandle);
if (clientFence != -1) {
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
index 9c80f4d..51832f9 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
@@ -40,7 +40,6 @@
using common::V1_1::PixelFormat;
using common::V1_1::RenderIntent;
using mapper::V2_0::IMapper;
-using mapper::V2_0::vts::Gralloc;
// Test environment for graphics.composer
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
@@ -171,15 +170,10 @@
}
const native_handle_t* allocate() {
- IMapper::BufferDescriptorInfo info{};
- info.width = 64;
- info.height = 64;
- info.layerCount = 1;
- info.format = static_cast<common::V1_0::PixelFormat>(PixelFormat::RGBA_8888);
- info.usage =
- static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
-
- return mGralloc->allocate(info);
+ uint64_t usage =
+ static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
+ return mGralloc->allocate(/*width*/ 64, /*height*/ 64, /*layerCount*/ 1,
+ PixelFormat::RGBA_8888, usage);
}
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
@@ -456,18 +450,15 @@
return;
}
- IMapper::BufferDescriptorInfo info{};
- info.width = mDisplayWidth;
- info.height = mDisplayHeight;
- info.layerCount = 1;
- info.format = static_cast<common::V1_0::PixelFormat>(mReadbackPixelFormat);
// BufferUsage::COMPOSER_OUTPUT is missing
- info.usage = static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
+ uint64_t usage =
+ static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
std::unique_ptr<Gralloc> gralloc;
const native_handle_t* buffer;
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
- ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(info));
+ ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(mDisplayWidth, mDisplayHeight, 1,
+ mReadbackPixelFormat, usage));
mComposerClient->setReadbackBuffer(mPrimaryDisplay, buffer, -1);
}
@@ -483,17 +474,14 @@
return;
}
- IMapper::BufferDescriptorInfo info{};
- info.width = mDisplayWidth;
- info.height = mDisplayHeight;
- info.layerCount = 1;
- info.format = static_cast<common::V1_0::PixelFormat>(mReadbackPixelFormat);
- info.usage = static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
+ uint64_t usage =
+ static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
std::unique_ptr<Gralloc> gralloc;
const native_handle_t* buffer;
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
- ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(info));
+ ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(mDisplayWidth, mDisplayHeight, 1,
+ mReadbackPixelFormat, usage));
Error error = mComposerClient->getRaw()->setReadbackBuffer(mInvalidDisplayId, buffer, nullptr);
ASSERT_EQ(Error::BAD_DISPLAY, error);