Adding support for different Mapper versions in IComposer VTS tests
Bug: 135139498
Test: build, boot, VtsHalGraphicsComposerV2_<1,2,3>TargetTest,
Change-Id: I05e2832c64d4c06eb4afd64c3323d7edbd19a5f4
Merged-In: I05e2832c64d4c06eb4afd64c3323d7edbd19a5f4
diff --git a/graphics/composer/2.2/vts/functional/Android.bp b/graphics/composer/2.2/vts/functional/Android.bp
index 4cb0bdf..9f7e1cd 100644
--- a/graphics/composer/2.2/vts/functional/Android.bp
+++ b/graphics/composer/2.2/vts/functional/Android.bp
@@ -31,6 +31,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",
@@ -40,6 +41,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 da8858e..0648b34 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2ReadbackTest.cpp
@@ -39,9 +39,9 @@
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::AccessRegion;
using V2_1::vts::TestCommandReader;
static const IComposerClient::Color BLACK = {0, 0, 0, 0xff};
@@ -296,14 +296,13 @@
mComposerClient = client;
mGralloc = gralloc;
- mPixelFormat = pixelFormat;
+ mFormat = pixelFormat;
mDataspace = dataspace;
- mInfo.width = width;
- mInfo.height = height;
- mInfo.layerCount = 1;
- mInfo.format = mPixelFormat;
- mInfo.usage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::GPU_TEXTURE);
+ mWidth = width;
+ mHeight = height;
+ mLayerCount = 1;
+ mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::GPU_TEXTURE);
mAccessRegion.top = 0;
mAccessRegion.left = 0;
@@ -322,8 +321,10 @@
mGralloc->freeBuffer(mBufferHandle);
mBufferHandle = nullptr;
}
- mBufferHandle = mGralloc->allocate(mInfo, /*import*/ true, &mStride);
- ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mInfo, mStride));
+ mBufferHandle = mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
+ /*import*/ true, &mStride);
+ ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mWidth, mHeight, mLayerCount,
+ mFormat, mUsage, mStride));
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(mDisplay, mBufferHandle, -1));
}
@@ -332,13 +333,13 @@
int32_t fenceHandle;
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle));
- void* bufData = mGralloc->lock(mBufferHandle, mInfo.usage, mAccessRegion, fenceHandle);
- ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
- int32_t bytesPerPixel = GraphicsComposerReadbackTest::GetBytesPerPixel(mPixelFormat);
+ void* bufData = mGralloc->lock(mBufferHandle, mUsage, mAccessRegion, fenceHandle);
+ ASSERT_TRUE(mFormat == PixelFormat::RGB_888 || mFormat == PixelFormat::RGBA_8888);
+ int32_t bytesPerPixel = GraphicsComposerReadbackTest::GetBytesPerPixel(mFormat);
ASSERT_NE(-1, bytesPerPixel);
- for (int row = 0; row < mInfo.height; row++) {
- for (int col = 0; col < mInfo.width; col++) {
- int pixel = row * mInfo.width + col;
+ for (int row = 0; row < mHeight; row++) {
+ for (int col = 0; col < mWidth; col++) {
+ int pixel = row * mWidth + col;
int offset = (row * mStride + col) * bytesPerPixel;
uint8_t* pixelColor = (uint8_t*)bufData + offset;
@@ -354,12 +355,16 @@
}
}
- protected:
- IMapper::BufferDescriptorInfo mInfo;
- IMapper::Rect mAccessRegion;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mLayerCount;
+ PixelFormat mFormat;
+ uint64_t mUsage;
+ AccessRegion mAccessRegion;
+
+ protected:
uint32_t mStride;
const native_handle_t* mBufferHandle = nullptr;
- PixelFormat mPixelFormat;
Dataspace mDataspace;
Display mDisplay;
std::shared_ptr<Gralloc> mGralloc;
@@ -392,13 +397,12 @@
: TestLayer{client, display} {
mGralloc = gralloc;
mComposition = composition;
- mInfo.width = width;
- mInfo.height = height;
- mInfo.layerCount = 1;
- mInfo.format = format;
- mInfo.usage =
- static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
- BufferUsage::COMPOSER_OVERLAY);
+ mWidth = width;
+ mHeight = height;
+ mLayerCount = 1;
+ mFormat = format;
+ mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
+ BufferUsage::COMPOSER_OVERLAY);
mAccessRegion.top = 0;
mAccessRegion.left = 0;
@@ -423,9 +427,9 @@
}
void fillBuffer(std::vector<IComposerClient::Color> expectedColors) {
- void* bufData = mGralloc->lock(mBufferHandle, mInfo.usage, mAccessRegion, -1);
+ void* bufData = mGralloc->lock(mBufferHandle, mUsage, mAccessRegion, -1);
ASSERT_NO_FATAL_FAILURE(GraphicsComposerReadbackTest::fillBuffer(
- mInfo.width, mInfo.height, mStride, bufData, mInfo.format, expectedColors));
+ mWidth, mHeight, mStride, bufData, mFormat, expectedColors));
mFillFence = mGralloc->unlock(mBufferHandle);
if (mFillFence != -1) {
sync_wait(mFillFence, -1);
@@ -437,10 +441,12 @@
mGralloc->freeBuffer(mBufferHandle);
mBufferHandle = nullptr;
}
- mBufferHandle = mGralloc->allocate(mInfo, /*import*/ true, &mStride);
+ mBufferHandle = mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
+ /*import*/ true, &mStride);
ASSERT_NE(nullptr, mBufferHandle);
ASSERT_NO_FATAL_FAILURE(fillBuffer(colors));
- ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mInfo, mStride));
+ ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mWidth, mHeight, mLayerCount,
+ mFormat, mUsage, mStride));
}
void setToClientComposition(const std::shared_ptr<CommandWriterBase>& writer) {
@@ -448,11 +454,15 @@
writer->setLayerCompositionType(IComposerClient::Composition::CLIENT);
}
- IMapper::BufferDescriptorInfo mInfo;
- IMapper::Rect mAccessRegion;
+ AccessRegion mAccessRegion;
uint32_t mStride;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mLayerCount;
+ PixelFormat mFormat;
- protected:
+ protected:
+ uint64_t mUsage;
IComposerClient::Composition mComposition;
std::shared_ptr<Gralloc> mGralloc;
int32_t mFillFence;
@@ -568,14 +578,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
@@ -642,23 +649,20 @@
// 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(fillBuffer(clientInfo.width, clientInfo.height, clientStride,
- clientBufData, clientInfo.format, expectedColors));
+ ASSERT_NO_FATAL_FAILURE(fillBuffer(layer->mWidth, layer->mHeight, clientStride,
+ clientBufData, clientFormat, expectedColors));
int clientFence = mGralloc->unlock(clientBufferHandle);
if (clientFence != -1) {
sync_wait(clientFence, -1);
@@ -706,14 +710,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);
- 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);
+ 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);
@@ -728,30 +731,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);
- fillColorsArea(clientColors, clientInfo.width, clientFrame, RED);
- ASSERT_NO_FATAL_FAILURE(fillBuffer(clientInfo.width, clientInfo.height, clientStride,
- clientData, clientInfo.format, clientColors));
+ void* clientData = mGralloc->lock(clientBufferHandle, clientUsage, clientAccessRegion, -1);
+ std::vector<IComposerClient::Color> clientColors(mDisplayWidth * mDisplayHeight);
+ fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
+ ASSERT_NO_FATAL_FAILURE(fillBuffer(mDisplayWidth, mDisplayHeight, clientStride, clientData,
+ PixelFormat::RGBA_8888, clientColors));
int clientFence = mGralloc->unlock(clientBufferHandle);
if (clientFence != -1) {
sync_wait(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);