Remove mapper from composer2.2 VTS

Test: make VtsHalGraphicsComposerV2_2TargetTest
Bug: 292584923
Change-Id: Id281c732535ace4a36750d759b59db7aa6e5cb3a
This commit is contained in:
John Reck 2023-07-25 22:03:27 -04:00
parent 650fe3ed52
commit 82c666bd8c
10 changed files with 93 additions and 270 deletions

View file

@ -42,7 +42,6 @@ cc_library_static {
static_libs: [
"android.hardware.graphics.composer@2.1-vts",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.mapper@2.1-vts",
"libarect",
"libgtest",
"libmath",
@ -50,15 +49,10 @@ cc_library_static {
"librenderengine",
"libshaders",
"libtonemap",
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@3.0-vts",
"android.hardware.graphics.mapper@4.0",
"android.hardware.graphics.mapper@4.0-vts",
],
export_static_lib_headers: [
"android.hardware.graphics.composer@2.1-vts",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.mapper@2.1-vts",
],
header_libs: [
"android.hardware.graphics.composer@2.2-command-buffer",

View file

@ -179,66 +179,6 @@ std::array<float, 16> ComposerClient::getDataspaceSaturationMatrix(Dataspace dat
return matrix;
}
Gralloc::Gralloc() {
[this] {
ALOGD("Attempting to initialize gralloc4");
ASSERT_NO_FATAL_FAILURE(mGralloc4 = std::make_shared<Gralloc4>(
/*aidlAllocatorServiceName*/ IAllocator::descriptor +
std::string("/default"),
/*hidlAllocatorServiceName*/ "default",
/*mapperServiceName*/ "default",
/*errOnFailure=*/false));
if (mGralloc4->getMapper() == nullptr || !mGralloc4->hasAllocator()) {
mGralloc4 = nullptr;
ALOGD("Failed to initialize gralloc4, initializing gralloc3");
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
/*errOnFailure=*/false));
if (mGralloc3->getMapper() == nullptr || mGralloc3->getAllocator() == nullptr) {
mGralloc3 = nullptr;
ALOGD("Failed to initialize gralloc3, initializing gralloc2_1");
mGralloc2_1 = std::make_shared<Gralloc2_1>(/*errOnFailure*/ false);
if (!mGralloc2_1->getMapper()) {
mGralloc2_1 = nullptr;
ALOGD("Failed to initialize gralloc2_1, initializing gralloc2");
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
}
}
}
}();
}
bool Gralloc::validateBufferSize(const native_handle_t* bufferHandle, uint32_t width,
uint32_t height, uint32_t layerCount, PixelFormat format,
uint64_t usage, uint32_t stride) {
if (mGralloc4) {
IMapper4::BufferDescriptorInfo info{};
info.width = width;
info.height = height;
info.layerCount = layerCount;
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
info.usage = usage;
return mGralloc4->validateBufferSize(bufferHandle, info, stride);
} else if (mGralloc3) {
IMapper3::BufferDescriptorInfo info{};
info.width = width;
info.height = height;
info.layerCount = layerCount;
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
info.usage = usage;
return mGralloc3->validateBufferSize(bufferHandle, info, stride);
} else if (mGralloc2_1) {
IMapper2_1::BufferDescriptorInfo info{};
info.width = width;
info.height = height;
info.layerCount = layerCount;
info.format = static_cast<android::hardware::graphics::common::V1_1::PixelFormat>(format);
info.usage = usage;
return mGralloc2_1->validateBufferSize(bufferHandle, info, stride);
} else {
return true;
}
}
} // namespace vts
} // namespace V2_2
} // namespace composer

View file

@ -187,12 +187,11 @@ void ReadbackHelper::compareColorBuffers(std::vector<IComposerClient::Color>& ex
}
ReadbackBuffer::ReadbackBuffer(Display display, const std::shared_ptr<ComposerClient>& client,
const std::shared_ptr<Gralloc>& gralloc, uint32_t width,
uint32_t height, PixelFormat pixelFormat, Dataspace dataspace) {
uint32_t width, uint32_t height, PixelFormat pixelFormat,
Dataspace dataspace) {
mDisplay = display;
mComposerClient = client;
mGralloc = gralloc;
mPixelFormat = pixelFormat;
mDataspace = dataspace;
@ -202,20 +201,12 @@ ReadbackBuffer::ReadbackBuffer(Display display, const std::shared_ptr<ComposerCl
mLayerCount = 1;
mFormat = mPixelFormat;
mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::GPU_TEXTURE);
mAccessRegion.top = 0;
mAccessRegion.left = 0;
mAccessRegion.width = width;
mAccessRegion.height = height;
}
void ReadbackBuffer::setReadbackBuffer() {
mBufferHandle.reset(new Gralloc::NativeHandleWrapper(
mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
/*import*/ true, &mStride)));
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle->get(), mWidth, mHeight,
mLayerCount, mFormat, mUsage, mStride));
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(mDisplay, mBufferHandle->get(), -1));
mBuffer = sp<GraphicBuffer>::make(mWidth, mHeight, (int32_t)mFormat, mLayerCount, mUsage);
ASSERT_EQ(STATUS_OK, mBuffer->initCheck());
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(mDisplay, mBuffer->handle, -1));
}
void ReadbackBuffer::checkReadbackBuffer(std::vector<IComposerClient::Color> expectedColors) {
@ -223,15 +214,14 @@ void ReadbackBuffer::checkReadbackBuffer(std::vector<IComposerClient::Color> exp
int32_t fenceHandle;
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle));
void* bufData = mGralloc->lock(mBufferHandle->get(), mUsage, mAccessRegion, fenceHandle);
void* bufData = nullptr;
int32_t stride = mBuffer->stride;
status_t status = mBuffer->lockAsync(mUsage, &bufData, fenceHandle);
ASSERT_EQ(STATUS_OK, status);
ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
ReadbackHelper::compareColorBuffers(expectedColors, bufData, mStride, mWidth, mHeight,
ReadbackHelper::compareColorBuffers(expectedColors, bufData, stride, mWidth, mHeight,
mPixelFormat);
int32_t unlockFence = mGralloc->unlock(mBufferHandle->get());
if (unlockFence != -1) {
sync_wait(unlockFence, -1);
close(unlockFence);
}
EXPECT_EQ(STATUS_OK, mBuffer->unlock());
}
void TestColorLayer::write(const std::shared_ptr<CommandWriterBase>& writer) {
@ -251,12 +241,10 @@ LayerSettings TestColorLayer::toRenderEngineLayerSettings() {
}
TestBufferLayer::TestBufferLayer(const std::shared_ptr<ComposerClient>& client,
const std::shared_ptr<Gralloc>& gralloc,
TestRenderEngine& renderEngine, Display display, int32_t width,
int32_t height, PixelFormat format,
IComposerClient::Composition composition)
: TestLayer{client, display}, mRenderEngine(renderEngine) {
mGralloc = gralloc;
mComposition = composition;
mWidth = width;
mHeight = height;
@ -265,11 +253,6 @@ TestBufferLayer::TestBufferLayer(const std::shared_ptr<ComposerClient>& client,
mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
BufferUsage::COMPOSER_OVERLAY | BufferUsage::GPU_TEXTURE);
mAccessRegion.top = 0;
mAccessRegion.left = 0;
mAccessRegion.width = width;
mAccessRegion.height = height;
setSourceCrop({0, 0, (float)width, (float)height});
}
@ -277,15 +260,13 @@ void TestBufferLayer::write(const std::shared_ptr<CommandWriterBase>& writer) {
TestLayer::write(writer);
writer->setLayerCompositionType(mComposition);
writer->setLayerVisibleRegion(std::vector<IComposerClient::Rect>(1, mDisplayFrame));
if (mBufferHandle != nullptr) writer->setLayerBuffer(0, mBufferHandle->get(), mFillFence);
if (mBuffer) writer->setLayerBuffer(0, mBuffer->handle, -1);
}
LayerSettings TestBufferLayer::toRenderEngineLayerSettings() {
LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings();
layerSettings.source.buffer.buffer = std::make_shared<renderengine::impl::ExternalTexture>(
new GraphicBuffer(mBufferHandle->get(), GraphicBuffer::CLONE_HANDLE, mWidth, mHeight,
static_cast<int32_t>(mFormat), 1, mUsage, mStride),
mRenderEngine.getInternalRenderEngine(),
mBuffer, mRenderEngine.getInternalRenderEngine(),
renderengine::impl::ExternalTexture::Usage::READABLE);
layerSettings.source.buffer.usePremultipliedAlpha =
@ -304,24 +285,18 @@ LayerSettings TestBufferLayer::toRenderEngineLayerSettings() {
}
void TestBufferLayer::fillBuffer(std::vector<IComposerClient::Color> expectedColors) {
void* bufData = mGralloc->lock(mBufferHandle->get(), mUsage, mAccessRegion, -1);
ASSERT_NO_FATAL_FAILURE(
ReadbackHelper::fillBuffer(mWidth, mHeight, mStride, bufData, mFormat, expectedColors));
mFillFence = mGralloc->unlock(mBufferHandle->get());
if (mFillFence != -1) {
sync_wait(mFillFence, -1);
close(mFillFence);
}
void* bufData = nullptr;
status_t status = mBuffer->lock(mUsage, &bufData);
ASSERT_EQ(STATUS_OK, status);
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mWidth, mHeight, mBuffer->stride, bufData,
mFormat, expectedColors));
EXPECT_EQ(STATUS_OK, mBuffer->unlock());
}
void TestBufferLayer::setBuffer(std::vector<IComposerClient::Color> colors) {
mBufferHandle.reset(new Gralloc::NativeHandleWrapper(
mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
/*import*/ true, &mStride)));
ASSERT_NE(nullptr, mBufferHandle->get());
mBuffer = sp<GraphicBuffer>::make(mWidth, mHeight, (int32_t)mFormat, mLayerCount, mUsage);
ASSERT_EQ(STATUS_OK, mBuffer->initCheck());
ASSERT_NO_FATAL_FAILURE(fillBuffer(colors));
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle->get(), mWidth, mHeight,
mLayerCount, mFormat, mUsage, mStride));
}
void TestBufferLayer::setDataspace(Dataspace dataspace,

View file

@ -24,7 +24,6 @@ namespace composer {
namespace V2_2 {
namespace vts {
using mapper::V2_1::IMapper;
using renderengine::DisplaySettings;
using renderengine::LayerSettings;
using renderengine::RenderEngineCreationArgs;

View file

@ -26,7 +26,6 @@
#include <android/hardware/graphics/composer/2.2/IComposerClient.h>
#include <composer-command-buffer/2.2/ComposerCommandBuffer.h>
#include <composer-vts/2.1/ComposerVts.h>
#include <mapper-vts/2.1/MapperVts.h>
#include <utils/StrongPointer.h>
namespace android {
@ -41,14 +40,6 @@ using common::V1_1::ColorMode;
using common::V1_1::Dataspace;
using common::V1_1::PixelFormat;
using common::V1_1::RenderIntent;
using IMapper2_1 = android::hardware::graphics::mapper::V2_1::IMapper;
using IMapper3 = android::hardware::graphics::mapper::V3_0::IMapper;
using IMapper4 = android::hardware::graphics::mapper::V4_0::IMapper;
using Gralloc2 = android::hardware::graphics::mapper::V2_0::vts::Gralloc;
using Gralloc2_1 = android::hardware::graphics::mapper::V2_1::vts::Gralloc;
using Gralloc3 = android::hardware::graphics::mapper::V3_0::vts::Gralloc;
using Gralloc4 = android::hardware::graphics::mapper::V4_0::vts::Gralloc;
using IAllocator = aidl::android::hardware::graphics::allocator::IAllocator;
class ComposerClient;
@ -92,28 +83,6 @@ class ComposerClient : public V2_1::vts::ComposerClient {
const sp<IComposerClient> mClient;
};
class Gralloc : public V2_1::vts::Gralloc {
public:
using NativeHandleWrapper = V2_1::vts::NativeHandleWrapper;
Gralloc();
const NativeHandleWrapper allocate(uint32_t width, uint32_t height, uint32_t layerCount,
PixelFormat format, uint64_t usage, bool import = true,
uint32_t* outStride = nullptr) {
return V2_1::vts::Gralloc::allocate(
width, height, layerCount,
static_cast<android::hardware::graphics::common::V1_0::PixelFormat>(format), usage,
import, outStride);
}
bool validateBufferSize(const native_handle_t* bufferHandle, uint32_t width, uint32_t height,
uint32_t layerCount, PixelFormat format, uint64_t usage,
uint32_t stride);
protected:
std::shared_ptr<Gralloc2_1> mGralloc2_1 = nullptr;
};
} // namespace vts
} // namespace V2_2
} // namespace composer

View file

@ -22,7 +22,6 @@
#include <composer-vts/2.1/GraphicsComposerCallback.h>
#include <composer-vts/2.1/TestCommandReader.h>
#include <composer-vts/2.2/ComposerVts.h>
#include <mapper-vts/2.1/MapperVts.h>
#include <renderengine/RenderEngine.h>
#include <memory>
@ -38,8 +37,6 @@ using android::hardware::hidl_handle;
using common::V1_1::BufferUsage;
using common::V1_1::Dataspace;
using common::V1_1::PixelFormat;
using IMapper2_1 = mapper::V2_1::IMapper;
using Gralloc2_1 = mapper::V2_1::vts::Gralloc;
using renderengine::LayerSettings;
using V2_1::Display;
using V2_1::Layer;
@ -113,9 +110,8 @@ class TestColorLayer : public TestLayer {
class TestBufferLayer : public TestLayer {
public:
TestBufferLayer(
const std::shared_ptr<ComposerClient>& client, const std::shared_ptr<Gralloc>& gralloc,
TestRenderEngine& renderEngine, Display display, int32_t width, int32_t height,
PixelFormat format,
const std::shared_ptr<ComposerClient>& client, TestRenderEngine& renderEngine,
Display display, int32_t width, int32_t height, PixelFormat format,
IComposerClient::Composition composition = IComposerClient::Composition::DEVICE);
void write(const std::shared_ptr<CommandWriterBase>& writer) override;
@ -135,15 +131,11 @@ class TestBufferLayer : public TestLayer {
uint32_t mLayerCount;
PixelFormat mFormat;
uint64_t mUsage;
AccessRegion mAccessRegion;
uint32_t mStride;
protected:
IComposerClient::Composition mComposition;
std::shared_ptr<Gralloc> mGralloc;
TestRenderEngine& mRenderEngine;
int32_t mFillFence;
std::unique_ptr<Gralloc::NativeHandleWrapper> mBufferHandle;
sp<GraphicBuffer> mBuffer;
};
class ReadbackHelper {
@ -179,9 +171,8 @@ class ReadbackHelper {
class ReadbackBuffer {
public:
ReadbackBuffer(Display display, const std::shared_ptr<ComposerClient>& client,
const std::shared_ptr<Gralloc>& gralloc, uint32_t width, uint32_t height,
PixelFormat pixelFormat, Dataspace dataspace);
ReadbackBuffer(Display display, const std::shared_ptr<ComposerClient>& client, uint32_t width,
uint32_t height, PixelFormat pixelFormat, Dataspace dataspace);
void setReadbackBuffer();
@ -193,13 +184,10 @@ class ReadbackBuffer {
uint32_t mLayerCount;
PixelFormat mFormat;
uint64_t mUsage;
AccessRegion mAccessRegion;
uint32_t mStride;
std::unique_ptr<Gralloc::NativeHandleWrapper> mBufferHandle = nullptr;
sp<GraphicBuffer> mBuffer;
PixelFormat mPixelFormat;
Dataspace mDataspace;
Display mDisplay;
std::shared_ptr<Gralloc> mGralloc;
std::shared_ptr<ComposerClient> mComposerClient;
};

View file

@ -34,10 +34,8 @@ namespace composer {
namespace V2_2 {
namespace vts {
using mapper::V2_1::IMapper;
using renderengine::DisplaySettings;
using renderengine::RenderEngineCreationArgs;
using vts::Gralloc;
class TestRenderEngine {
public:

View file

@ -54,24 +54,13 @@ cc_test {
"libsync",
"libui",
"android.hardware.common-V2-ndk",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
],
static_libs: [
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.allocator@3.0",
"android.hardware.graphics.allocator@4.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.1-vts",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.composer@2.2-vts",
"android.hardware.graphics.mapper@2.0-vts",
"android.hardware.graphics.mapper@2.1-vts",
"android.hardware.graphics.mapper@3.0-vts",
"android.hardware.graphics.mapper@4.0-vts",
"libaidlcommonsupport",
"libgtest",
"librenderengine",

View file

@ -47,7 +47,6 @@ using V2_1::Config;
using V2_1::Display;
using V2_1::vts::NativeHandleWrapper;
using V2_1::vts::TestCommandReader;
using vts::Gralloc;
class GraphicsCompositionTestBase : public ::testing::Test {
protected:
@ -79,7 +78,6 @@ class GraphicsCompositionTestBase : public ::testing::Test {
// set up command writer/reader and gralloc
mWriter = std::make_shared<CommandWriterBase>(1024);
mReader = std::make_unique<TestCommandReader>();
mGralloc = std::make_shared<Gralloc>();
ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON));
@ -143,7 +141,6 @@ class GraphicsCompositionTestBase : public ::testing::Test {
std::vector<ColorMode> mTestColorModes;
std::shared_ptr<CommandWriterBase> mWriter;
std::unique_ptr<TestCommandReader> mReader;
std::shared_ptr<Gralloc> mGralloc;
std::unique_ptr<TestRenderEngine> mTestRenderEngine;
bool mHasReadbackBuffer;
@ -220,7 +217,7 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -272,7 +269,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
mWriter->selectDisplay(mPrimaryDisplay);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
@ -285,9 +282,9 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
{0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
BLUE);
auto layer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
auto layer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
layer->setZOrder(10);
layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
@ -352,15 +349,16 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
// This following buffer call should have no effect
uint64_t usage =
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
NativeHandleWrapper bufferHandle =
mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, PixelFormat::RGBA_8888, usage);
mWriter->setLayerBuffer(0, bufferHandle.get(), -1);
sp<GraphicBuffer> buffer = sp<GraphicBuffer>::make(
mDisplayWidth, mDisplayHeight, (int32_t)PixelFormat::RGBA_8888, 1, usage);
ASSERT_EQ(STATUS_OK, buffer->initCheck());
mWriter->setLayerBuffer(0, buffer->handle, -1);
// expected color for each pixel
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -419,16 +417,16 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
{0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
BLUE);
auto layer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_FP16);
auto layer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_FP16);
layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
layer->setZOrder(10);
layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
writeLayers(layers);
@ -462,25 +460,20 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
}
// create client target buffer
uint32_t clientStride;
NativeHandleWrapper clientBufferHandle =
mGralloc->allocate(layer->mWidth, layer->mHeight, layer->mLayerCount,
clientFormat, clientUsage, /*import*/ true, &clientStride);
ASSERT_NE(nullptr, clientBufferHandle.get());
sp<GraphicBuffer> clientBuffer =
sp<GraphicBuffer>::make(layer->mWidth, layer->mHeight, (int32_t)clientFormat,
layer->mLayerCount, clientUsage);
ASSERT_EQ(STATUS_OK, clientBuffer->initCheck());
void* clientBufData =
mGralloc->lock(clientBufferHandle.get(), clientUsage, layer->mAccessRegion, -1);
void* clientBufData = nullptr;
ASSERT_EQ(STATUS_OK, clientBuffer->lock(clientUsage, &clientBufData));
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(layer->mWidth, layer->mHeight,
clientStride, clientBufData,
clientBuffer->stride, clientBufData,
clientFormat, expectedColors));
int clientFence = mGralloc->unlock(clientBufferHandle.get());
if (clientFence != -1) {
sync_wait(clientFence, -1);
close(clientFence);
}
clientBuffer->unlock();
mWriter->setClientTarget(0, clientBufferHandle.get(), clientFence, clientDataspace,
mWriter->setClientTarget(0, clientBuffer->handle, -1, clientDataspace,
std::vector<IComposerClient::Rect>(1, damage));
layer->setToClientComposition(mWriter);
@ -531,12 +524,12 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
{0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight}, RED);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
auto deviceLayer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mComposerClient, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight / 2, PixelFormat::RGBA_8888);
std::vector<IComposerClient::Color> deviceColors(deviceLayer->mWidth *
deviceLayer->mHeight);
@ -573,8 +566,8 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
}
auto clientLayer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, clientWidth,
clientHeight, PixelFormat::RGBA_FP16, IComposerClient::Composition::DEVICE);
mComposerClient, *mTestRenderEngine, mPrimaryDisplay, clientWidth, clientHeight,
PixelFormat::RGBA_FP16, IComposerClient::Composition::DEVICE);
IComposerClient::Rect clientFrame = {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight};
clientLayer->setDisplayFrame(clientFrame);
clientLayer->setZOrder(0);
@ -590,27 +583,22 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
}
// create client target buffer
ASSERT_EQ(1, mReader->mCompositionChanges[0].second);
uint32_t clientStride;
NativeHandleWrapper clientBufferHandle =
mGralloc->allocate(mDisplayWidth, mDisplayHeight, clientLayer->mLayerCount,
clientFormat, clientUsage, /*import*/ true, &clientStride);
ASSERT_NE(nullptr, clientBufferHandle.get());
sp<GraphicBuffer> clientBuffer =
sp<GraphicBuffer>::make(mDisplayWidth, mDisplayHeight, (int32_t)clientFormat,
clientLayer->mLayerCount, clientUsage);
ASSERT_EQ(STATUS_OK, clientBuffer->initCheck());
void* clientBufData = mGralloc->lock(clientBufferHandle.get(), clientUsage,
{0, 0, mDisplayWidth, mDisplayHeight}, -1);
void* clientBufData = nullptr;
ASSERT_EQ(STATUS_OK, clientBuffer->lock(clientUsage, &clientBufData));
std::vector<IComposerClient::Color> clientColors(mDisplayWidth * mDisplayHeight);
ReadbackHelper::fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mDisplayWidth, mDisplayHeight,
clientStride, clientBufData,
clientBuffer->stride, clientBufData,
clientFormat, clientColors));
int clientFence = mGralloc->unlock(clientBufferHandle.get());
if (clientFence != -1) {
sync_wait(clientFence, -1);
close(clientFence);
}
EXPECT_EQ(STATUS_OK, clientBuffer->unlock());
mWriter->setClientTarget(0, clientBufferHandle.get(), clientFence, clientDataspace,
mWriter->setClientTarget(0, clientBuffer->handle, -1, clientDataspace,
std::vector<IComposerClient::Rect>(1, clientFrame));
clientLayer->setToClientComposition(mWriter);
mWriter->validateDisplay();
@ -655,9 +643,9 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) {
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
auto layer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
auto layer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
layer->setZOrder(10);
layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
@ -665,7 +653,7 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) {
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -742,7 +730,7 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -803,9 +791,9 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
{0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
BLUE);
auto layer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
auto layer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
layer->setZOrder(10);
layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
@ -819,7 +807,7 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
// update expected colors to match crop
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
{0, 0, mDisplayWidth, mDisplayHeight}, BLUE);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
writeLayers(layers);
@ -886,7 +874,7 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -955,9 +943,9 @@ class GraphicsBlendModeCompositionTest
backgroundLayer->setZOrder(0);
backgroundLayer->setColor(mBackgroundColor);
auto layer = std::make_shared<TestBufferLayer>(
mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
auto layer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mDisplayWidth,
mDisplayHeight, PixelFormat::RGBA_8888);
layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
layer->setZOrder(10);
layer->setDataspace(Dataspace::UNKNOWN, mWriter);
@ -1043,7 +1031,7 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_None) {
setUpLayers(IComposerClient::BlendMode::NONE);
setExpectedColors(expectedColors);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
writeLayers(mLayers);
@ -1102,7 +1090,7 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_Coverage) {
setUpLayers(IComposerClient::BlendMode::COVERAGE);
setExpectedColors(expectedColors);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
writeLayers(mLayers);
@ -1153,7 +1141,7 @@ TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
setUpLayers(IComposerClient::BlendMode::PREMULTIPLIED);
setExpectedColors(expectedColors);
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
writeLayers(mLayers);
@ -1193,7 +1181,7 @@ class GraphicsTransformCompositionTest : public GraphicsCompositionTest {
IComposerClient::Rect blueRect = {mSideLength / 2, mSideLength / 2, mSideLength,
mSideLength};
mLayer = std::make_shared<TestBufferLayer>(mComposerClient, mGralloc, *mTestRenderEngine,
mLayer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
mPrimaryDisplay, mSideLength, mSideLength,
PixelFormat::RGBA_8888);
mLayer->setDisplayFrame({0, 0, mSideLength, mSideLength});
@ -1236,7 +1224,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
return;
}
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
mLayer->setTransform(Transform::FLIP_H);
@ -1291,7 +1279,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
return;
}
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
@ -1346,7 +1334,7 @@ TEST_P(GraphicsTransformCompositionTest, ROT_180) {
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
return;
}
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
mDisplayHeight, mPixelFormat, mDataspace);
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());

View file

@ -18,14 +18,13 @@
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <composer-vts/2.1/GraphicsComposerCallback.h>
#include <composer-vts/2.1/TestCommandReader.h>
#include <composer-vts/2.2/ComposerVts.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include <mapper-vts/2.0/MapperVts.h>
#include <ui/GraphicBuffer.h>
namespace android {
namespace hardware {
@ -141,8 +140,6 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp());
ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>());
mWriter = std::make_unique<CommandWriterBase>(1024);
mReader = std::make_unique<V2_1::vts::TestCommandReader>();
}
@ -152,20 +149,10 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::TearDown());
}
NativeHandleWrapper allocate() {
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()); }
std::unique_ptr<CommandWriterBase> mWriter;
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
private:
std::unique_ptr<Gralloc> mGralloc;
};
/**
@ -437,13 +424,11 @@ TEST_P(GraphicsComposerHidlTest, SetReadbackBuffer) {
uint64_t usage =
static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
std::unique_ptr<Gralloc> gralloc;
std::unique_ptr<NativeHandleWrapper> buffer;
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
ASSERT_NO_FATAL_FAILURE(buffer.reset(new NativeHandleWrapper(
gralloc->allocate(mDisplayWidth, mDisplayHeight, 1, mReadbackPixelFormat, usage))));
sp<GraphicBuffer> buffer = sp<GraphicBuffer>::make(mDisplayWidth, mDisplayHeight,
(int32_t)mReadbackPixelFormat, 1, usage);
ASSERT_EQ(STATUS_OK, buffer->initCheck());
mComposerClient->setReadbackBuffer(mPrimaryDisplay, buffer->get(), -1);
mComposerClient->setReadbackBuffer(mPrimaryDisplay, buffer->handle, -1);
}
/**
@ -460,14 +445,12 @@ TEST_P(GraphicsComposerHidlTest, SetReadbackBufferBadDisplay) {
uint64_t usage =
static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
std::unique_ptr<Gralloc> gralloc;
std::unique_ptr<NativeHandleWrapper> buffer;
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
ASSERT_NO_FATAL_FAILURE(buffer.reset(new NativeHandleWrapper(
gralloc->allocate(mDisplayWidth, mDisplayHeight, 1, mReadbackPixelFormat, usage))));
sp<GraphicBuffer> buffer = sp<GraphicBuffer>::make(mDisplayWidth, mDisplayHeight,
(int32_t)mReadbackPixelFormat, 1, usage);
ASSERT_EQ(STATUS_OK, buffer->initCheck());
Error error =
mComposerClient->getRaw()->setReadbackBuffer(mInvalidDisplayId, buffer->get(), nullptr);
Error error = mComposerClient->getRaw()->setReadbackBuffer(mInvalidDisplayId, buffer->handle,
nullptr);
ASSERT_EQ(Error::BAD_DISPLAY, error);
}