Revert "Add VTS readback tests for buffer slot clearing"
This reverts commit d103cd6828
.
NOTE: This is not a full revert, it leaves the production code in place and only reverts the VTS test changes.
Reason for revert: b/262370410
Test: atest VtsHalGraphicsComposerV2_1TargetTest on Oriole
Test: atest VtsHalGraphicsComposerV2_2TargetTest on Oriole
Test: atest VtsHalGraphicsComposerV2_3TargetTest on Oriole
Test: atest VtsHalGraphicsComposerV2_4TargetTest on Oriole
Bug: 262370410
Change-Id: I336beb9f0ed81b305b26c6d8e9da70cfabe04bbd
This commit is contained in:
parent
952057044b
commit
e887a25203
11 changed files with 444 additions and 777 deletions
|
@ -126,23 +126,15 @@ void ComposerClient::setReadbackBuffer(Display display, const native_handle_t* b
|
|||
ASSERT_EQ(Error::NONE, error) << "failed to setReadbackBuffer";
|
||||
}
|
||||
|
||||
void ComposerClient::getRequiredReadbackBufferAttributes(Display display,
|
||||
PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace) {
|
||||
ASSERT_EQ(Error::NONE, getReadbackBufferAttributes(display, outPixelFormat, outDataspace));
|
||||
}
|
||||
|
||||
Error ComposerClient::getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace) {
|
||||
Error error;
|
||||
void ComposerClient::getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace) {
|
||||
mClient->getReadbackBufferAttributes(
|
||||
display, [&](const Error& tmpError, const PixelFormat& tmpPixelFormat,
|
||||
const Dataspace& tmpDataspace) {
|
||||
error = tmpError;
|
||||
*outPixelFormat = tmpPixelFormat;
|
||||
*outDataspace = tmpDataspace;
|
||||
display,
|
||||
[&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) {
|
||||
ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes";
|
||||
*outPixelFormat = tmpOutPixelFormat;
|
||||
*outDataspace = tmpOutDataspace;
|
||||
});
|
||||
return error;
|
||||
}
|
||||
|
||||
void ComposerClient::getReadbackBufferFence(Display display, int32_t* outFence) {
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "renderengine/ExternalTexture.h"
|
||||
#include "renderengine/impl/ExternalTexture.h"
|
||||
|
||||
using ::android::status_t;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
|
@ -109,40 +107,6 @@ int32_t ReadbackHelper::GetBytesPerPixel(PixelFormat pixelFormat) {
|
|||
}
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
IComposerClient::Color desiredColor, int* fillFence) {
|
||||
ASSERT_NE(nullptr, fillFence);
|
||||
std::vector<IComposerClient::Color> desiredColors(
|
||||
static_cast<size_t>(graphicBuffer->getWidth() * graphicBuffer->getHeight()));
|
||||
::android::Rect bounds = graphicBuffer->getBounds();
|
||||
fillColorsArea(desiredColors, static_cast<int32_t>(graphicBuffer->getWidth()),
|
||||
{bounds.left, bounds.top, bounds.right, bounds.bottom}, desiredColor);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBufferAndGetFence(graphicBuffer, desiredColors, fillFence));
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
const std::vector<IComposerClient::Color>& desiredColors,
|
||||
int* fillFence) {
|
||||
ASSERT_TRUE(graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGB_888 ||
|
||||
graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGBA_8888);
|
||||
void* bufData;
|
||||
int32_t bytesPerPixel = -1;
|
||||
int32_t bytesPerStride = -1;
|
||||
status_t status =
|
||||
graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||
&bufData, &bytesPerPixel, &bytesPerStride);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: graphicBuffer->getStride();
|
||||
ReadbackHelper::fillBuffer(graphicBuffer->getWidth(), graphicBuffer->getHeight(), stride,
|
||||
bufData, static_cast<PixelFormat>(graphicBuffer->getPixelFormat()),
|
||||
desiredColors);
|
||||
status = graphicBuffer->unlockAsync(fillFence);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillBuffer(int32_t width, int32_t height, uint32_t stride, void* bufferData,
|
||||
PixelFormat pixelFormat,
|
||||
std::vector<IComposerClient::Color> desiredPixelColors) {
|
||||
|
@ -152,16 +116,16 @@ void ReadbackHelper::fillBuffer(int32_t width, int32_t height, uint32_t stride,
|
|||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int pixel = row * width + col;
|
||||
IComposerClient::Color desiredColor = desiredPixelColors[pixel];
|
||||
IComposerClient::Color srcColor = desiredPixelColors[pixel];
|
||||
|
||||
int offset = (row * stride + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
|
||||
pixelColor[0] = desiredColor.r;
|
||||
pixelColor[1] = desiredColor.g;
|
||||
pixelColor[2] = desiredColor.b;
|
||||
pixelColor[0] = srcColor.r;
|
||||
pixelColor[1] = srcColor.g;
|
||||
pixelColor[2] = srcColor.b;
|
||||
|
||||
if (bytesPerPixel == 4) {
|
||||
pixelColor[3] = desiredColor.a;
|
||||
pixelColor[3] = srcColor.a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,14 +152,12 @@ void ReadbackHelper::fillColorsArea(std::vector<IComposerClient::Color>& expecte
|
|||
}
|
||||
}
|
||||
|
||||
bool ReadbackHelper::readbackSupported(PixelFormat pixelFormat, Dataspace dataspace, Error error) {
|
||||
bool ReadbackHelper::readbackSupported(const PixelFormat& pixelFormat, const Dataspace& dataspace,
|
||||
const Error error) {
|
||||
if (error != Error::NONE) {
|
||||
return false;
|
||||
}
|
||||
return readbackSupported(pixelFormat, dataspace);
|
||||
}
|
||||
|
||||
bool ReadbackHelper::readbackSupported(PixelFormat pixelFormat, Dataspace dataspace) {
|
||||
// TODO: add support for RGBA_1010102
|
||||
if (pixelFormat != PixelFormat::RGB_888 && pixelFormat != PixelFormat::RGBA_8888) {
|
||||
return false;
|
||||
}
|
||||
|
@ -205,94 +167,71 @@ bool ReadbackHelper::readbackSupported(PixelFormat pixelFormat, Dataspace datasp
|
|||
return true;
|
||||
}
|
||||
|
||||
void ReadbackHelper::createReadbackBuffer(uint32_t width, uint32_t height, PixelFormat pixelFormat,
|
||||
Dataspace dataspace, sp<GraphicBuffer>* graphicBuffer) {
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
if (!readbackSupported(pixelFormat, dataspace)) {
|
||||
*graphicBuffer = nullptr;
|
||||
}
|
||||
android::PixelFormat bufferFormat = static_cast<android::PixelFormat>(pixelFormat);
|
||||
uint32_t layerCount = 1;
|
||||
uint64_t usage = static_cast<uint64_t>(static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint64_t>(BufferUsage::GPU_TEXTURE));
|
||||
*graphicBuffer = sp<GraphicBuffer>::make(width, height, bufferFormat, layerCount, usage,
|
||||
"ReadbackBuffer");
|
||||
ASSERT_NE(nullptr, *graphicBuffer);
|
||||
ASSERT_EQ(::android::OK, (*graphicBuffer)->initCheck());
|
||||
}
|
||||
|
||||
void ReadbackHelper::compareColorToBuffer(IComposerClient::Color expectedColor,
|
||||
const sp<GraphicBuffer>& graphicBuffer, int32_t fence) {
|
||||
std::vector<IComposerClient::Color> expectedColors(
|
||||
static_cast<size_t>(graphicBuffer->getWidth() * graphicBuffer->getHeight()));
|
||||
::android::Rect bounds = graphicBuffer->getBounds();
|
||||
fillColorsArea(expectedColors, static_cast<int32_t>(graphicBuffer->getWidth()),
|
||||
{bounds.left, bounds.top, bounds.right, bounds.bottom}, expectedColor);
|
||||
compareColorsToBuffer(expectedColors, graphicBuffer, fence);
|
||||
}
|
||||
|
||||
void ReadbackHelper::compareColorsToBuffer(std::vector<IComposerClient::Color>& expectedColors,
|
||||
const sp<GraphicBuffer>& graphicBuffer, int32_t fence) {
|
||||
ASSERT_TRUE(graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGB_888 ||
|
||||
graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGBA_8888);
|
||||
|
||||
int bytesPerPixel = -1;
|
||||
int bytesPerStride = -1;
|
||||
void* bufData = nullptr;
|
||||
status_t status = graphicBuffer->lockAsync(GRALLOC_USAGE_SW_READ_OFTEN, &bufData, fence,
|
||||
&bytesPerPixel, &bytesPerStride);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: graphicBuffer->getStride();
|
||||
|
||||
if (bytesPerPixel == -1) {
|
||||
PixelFormat pixelFormat = static_cast<PixelFormat>(graphicBuffer->getPixelFormat());
|
||||
bytesPerPixel = ReadbackHelper::GetBytesPerPixel(pixelFormat);
|
||||
}
|
||||
void ReadbackHelper::compareColorBuffers(std::vector<IComposerClient::Color>& expectedColors,
|
||||
void* bufferData, const uint32_t stride,
|
||||
const uint32_t width, const uint32_t height,
|
||||
const PixelFormat pixelFormat) {
|
||||
const int32_t bytesPerPixel = ReadbackHelper::GetBytesPerPixel(pixelFormat);
|
||||
ASSERT_NE(-1, bytesPerPixel);
|
||||
for (int row = 0; row < graphicBuffer->getHeight(); row++) {
|
||||
for (int col = 0; col < graphicBuffer->getWidth(); col++) {
|
||||
int pixel = row * static_cast<int32_t>(graphicBuffer->getWidth()) + col;
|
||||
int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufData + offset;
|
||||
const IComposerClient::Color expectedColor = expectedColors[static_cast<size_t>(pixel)];
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.r), pixelColor[0]);
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.g), pixelColor[1]);
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.b), pixelColor[2]);
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int pixel = row * width + col;
|
||||
int offset = (row * stride + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
|
||||
|
||||
ASSERT_EQ(expectedColors[pixel].r, pixelColor[0]);
|
||||
ASSERT_EQ(expectedColors[pixel].g, pixelColor[1]);
|
||||
ASSERT_EQ(expectedColors[pixel].b, pixelColor[2]);
|
||||
}
|
||||
}
|
||||
|
||||
status = graphicBuffer->unlock();
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
}
|
||||
|
||||
ReadbackBuffer::ReadbackBuffer(Display display, const std::shared_ptr<ComposerClient>& client,
|
||||
uint32_t width, uint32_t height, PixelFormat pixelFormat) {
|
||||
const std::shared_ptr<Gralloc>& gralloc, uint32_t width,
|
||||
uint32_t height, PixelFormat pixelFormat, Dataspace dataspace) {
|
||||
mDisplay = display;
|
||||
|
||||
mComposerClient = client;
|
||||
mGralloc = gralloc;
|
||||
|
||||
mPixelFormat = pixelFormat;
|
||||
mDataspace = dataspace;
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mPixelFormat = pixelFormat;
|
||||
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() {
|
||||
mGraphicBuffer = sp<GraphicBuffer>::make(mWidth, mHeight,
|
||||
static_cast<::android::PixelFormat>(mPixelFormat),
|
||||
mLayerCount, mUsage, "ReadbackBuffer");
|
||||
ASSERT_NE(nullptr, mGraphicBuffer);
|
||||
ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
|
||||
mComposerClient->setReadbackBuffer(mDisplay, mGraphicBuffer->handle, -1 /* fence */);
|
||||
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));
|
||||
}
|
||||
|
||||
void ReadbackBuffer::checkReadbackBuffer(std::vector<IComposerClient::Color> expectedColors) {
|
||||
// lock buffer for reading
|
||||
int32_t fenceHandle;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle));
|
||||
ReadbackHelper::compareColorsToBuffer(expectedColors, mGraphicBuffer, fenceHandle);
|
||||
|
||||
void* bufData = mGralloc->lock(mBufferHandle->get(), mUsage, mAccessRegion, fenceHandle);
|
||||
ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
|
||||
ReadbackHelper::compareColorBuffers(expectedColors, bufData, mStride, mWidth, mHeight,
|
||||
mPixelFormat);
|
||||
int32_t unlockFence = mGralloc->unlock(mBufferHandle->get());
|
||||
if (unlockFence != -1) {
|
||||
sync_wait(unlockFence, -1);
|
||||
close(unlockFence);
|
||||
}
|
||||
}
|
||||
|
||||
void TestColorLayer::write(const std::shared_ptr<CommandWriterBase>& writer) {
|
||||
|
|
|
@ -83,7 +83,9 @@ void TestRenderEngine::drawLayers() {
|
|||
void TestRenderEngine::checkColorBuffer(std::vector<V2_2::IComposerClient::Color>& expectedColors) {
|
||||
void* bufferData;
|
||||
ASSERT_EQ(0, mGraphicBuffer->lock(mGraphicBuffer->getUsage(), &bufferData));
|
||||
ReadbackHelper::compareColorsToBuffer(expectedColors, mGraphicBuffer, -1 /* fence */);
|
||||
ReadbackHelper::compareColorBuffers(expectedColors, bufferData, mGraphicBuffer->getStride(),
|
||||
mGraphicBuffer->getWidth(), mGraphicBuffer->getHeight(),
|
||||
mFormat);
|
||||
ASSERT_EQ(0, mGraphicBuffer->unlock());
|
||||
}
|
||||
|
||||
|
|
|
@ -78,10 +78,8 @@ class ComposerClient : public V2_1::vts::ComposerClient {
|
|||
PixelFormat format, Dataspace dataspace);
|
||||
void setPowerMode_2_2(Display display, IComposerClient::PowerMode mode);
|
||||
void setReadbackBuffer(Display display, const native_handle_t* buffer, int32_t releaseFence);
|
||||
void getRequiredReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace);
|
||||
Error getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace);
|
||||
void getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat,
|
||||
Dataspace* outDataspace);
|
||||
void getReadbackBufferFence(Display display, int32_t* outFence);
|
||||
|
||||
std::vector<ColorMode> getColorModes(Display display);
|
||||
|
|
|
@ -34,8 +34,6 @@ namespace composer {
|
|||
namespace V2_2 {
|
||||
namespace vts {
|
||||
|
||||
using android::GraphicBuffer;
|
||||
using android::sp;
|
||||
using android::hardware::hidl_handle;
|
||||
using common::V1_1::BufferUsage;
|
||||
using common::V1_1::Dataspace;
|
||||
|
@ -158,13 +156,6 @@ class ReadbackHelper {
|
|||
|
||||
static int32_t GetBytesPerPixel(PixelFormat pixelFormat);
|
||||
|
||||
static void fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
IComposerClient::Color desiredColor, int* fillFence);
|
||||
|
||||
static void fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
const std::vector<IComposerClient::Color>& desiredColors,
|
||||
int* fillFence);
|
||||
|
||||
static void fillBuffer(int32_t width, int32_t height, uint32_t stride, void* bufferData,
|
||||
PixelFormat pixelFormat,
|
||||
std::vector<IComposerClient::Color> desiredPixelColors);
|
||||
|
@ -175,39 +166,40 @@ class ReadbackHelper {
|
|||
static void fillColorsArea(std::vector<IComposerClient::Color>& expectedColors, int32_t stride,
|
||||
IComposerClient::Rect area, IComposerClient::Color color);
|
||||
|
||||
static bool readbackSupported(const PixelFormat& pixelFormat, const Dataspace& dataspace,
|
||||
const Error error);
|
||||
|
||||
static const std::vector<ColorMode> colorModes;
|
||||
static const std::vector<Dataspace> dataspaces;
|
||||
|
||||
static bool readbackSupported(PixelFormat pixelFormat, Dataspace dataspace, Error error);
|
||||
static bool readbackSupported(PixelFormat pixelFormat, Dataspace dataspace);
|
||||
|
||||
static void createReadbackBuffer(uint32_t width, uint32_t height, PixelFormat pixelFormat,
|
||||
Dataspace dataspace, sp<GraphicBuffer>* graphicBuffer);
|
||||
|
||||
static void compareColorToBuffer(IComposerClient::Color expectedColors,
|
||||
const sp<GraphicBuffer>& graphicBuffer, int32_t fence);
|
||||
|
||||
static void compareColorsToBuffer(std::vector<IComposerClient::Color>& expectedColors,
|
||||
const sp<GraphicBuffer>& graphicBuffer, int32_t fence);
|
||||
static void compareColorBuffers(std::vector<IComposerClient::Color>& expectedColors,
|
||||
void* bufferData, const uint32_t stride, const uint32_t width,
|
||||
const uint32_t height, const PixelFormat pixelFormat);
|
||||
};
|
||||
|
||||
class ReadbackBuffer {
|
||||
public:
|
||||
ReadbackBuffer(Display display, const std::shared_ptr<ComposerClient>& client, uint32_t width,
|
||||
uint32_t height, PixelFormat pixelFormat);
|
||||
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);
|
||||
|
||||
void setReadbackBuffer();
|
||||
|
||||
void checkReadbackBuffer(std::vector<IComposerClient::Color> expectedColors);
|
||||
|
||||
protected:
|
||||
sp<GraphicBuffer> mGraphicBuffer;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
PixelFormat mPixelFormat;
|
||||
uint32_t mLayerCount;
|
||||
PixelFormat mFormat;
|
||||
uint64_t mUsage;
|
||||
AccessRegion mAccessRegion;
|
||||
uint32_t mStride;
|
||||
std::unique_ptr<Gralloc::NativeHandleWrapper> mBufferHandle = nullptr;
|
||||
PixelFormat mPixelFormat;
|
||||
Dataspace mDataspace;
|
||||
Display mDisplay;
|
||||
std::shared_ptr<Gralloc> mGralloc;
|
||||
std::shared_ptr<ComposerClient> mComposerClient;
|
||||
};
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace vts {
|
|||
namespace {
|
||||
|
||||
using android::Rect;
|
||||
using common::V1_1::BufferUsage;
|
||||
using common::V1_1::Dataspace;
|
||||
using common::V1_1::PixelFormat;
|
||||
using V2_1::Config;
|
||||
|
@ -99,8 +100,8 @@ class GraphicsCompositionTestBase : public ::testing::Test {
|
|||
|
||||
mTestRenderEngine->initGraphicBuffer(
|
||||
static_cast<uint32_t>(mDisplayWidth), static_cast<uint32_t>(mDisplayHeight), 1,
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN |
|
||||
GRALLOC_USAGE_HW_RENDER);
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::GPU_RENDER_TARGET));
|
||||
mTestRenderEngine->setDisplaySettings(clientCompositionDisplay);
|
||||
}
|
||||
|
||||
|
@ -115,22 +116,6 @@ class GraphicsCompositionTestBase : public ::testing::Test {
|
|||
}
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> allocateBuffer(uint32_t width, uint32_t height, uint32_t usage) {
|
||||
const auto& graphicBuffer = sp<GraphicBuffer>::make(
|
||||
width, height, android::PIXEL_FORMAT_RGBA_8888,
|
||||
/*layerCount*/ 1u, usage, "VtsHalGraphicsComposer2_2_ReadbackTest");
|
||||
|
||||
if (graphicBuffer && android::OK == graphicBuffer->initCheck()) {
|
||||
return nullptr;
|
||||
}
|
||||
return graphicBuffer;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> allocateBuffer(uint32_t usage) {
|
||||
return allocateBuffer(static_cast<uint32_t>(mDisplayWidth),
|
||||
static_cast<uint32_t>(mDisplayHeight), usage);
|
||||
}
|
||||
|
||||
void clearCommandReaderState() {
|
||||
mReader->mCompositionChanges.clear();
|
||||
mReader->mErrors.clear();
|
||||
|
@ -208,9 +193,15 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -229,8 +220,8 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
|
|||
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
|
||||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -264,9 +255,15 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -275,8 +272,8 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
|
|||
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
|
||||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
|
||||
|
@ -322,155 +319,6 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_P(GraphicsCompositionTest, SetLayerBufferWithSlotsToClear) {
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
if (error == Error::UNSUPPORTED) {
|
||||
GTEST_SUCCEED() << "Readback is unsupported";
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(Error::NONE, error);
|
||||
|
||||
sp<GraphicBuffer> readbackBuffer;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::createReadbackBuffer(
|
||||
mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace, &readbackBuffer));
|
||||
if (readbackBuffer == nullptr) {
|
||||
GTEST_SUCCEED() << "Unsupported readback buffer attributes";
|
||||
return;
|
||||
}
|
||||
// no fence needed for the readback buffer
|
||||
int noFence = -1;
|
||||
|
||||
sp<GraphicBuffer> clearSlotBuffer = allocateBuffer(1u, 1u, GRALLOC_USAGE_HW_COMPOSER);
|
||||
ASSERT_NE(nullptr, clearSlotBuffer);
|
||||
|
||||
// red buffer
|
||||
uint32_t usage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
sp<GraphicBuffer> redBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, redBuffer);
|
||||
int redFence;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBufferAndGetFence(redBuffer, RED, &redFence));
|
||||
|
||||
// blue buffer
|
||||
sp<GraphicBuffer> blueBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, blueBuffer);
|
||||
int blueFence;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBufferAndGetFence(blueBuffer, BLUE, &blueFence));
|
||||
|
||||
// layer defaults
|
||||
IComposerClient::Rect rectFullDisplay = {0, 0, mDisplayWidth, mDisplayHeight};
|
||||
Layer layer = mComposerClient->createLayer(mPrimaryDisplay, 3);
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerDisplayFrame(rectFullDisplay);
|
||||
mWriter->setLayerCompositionType(IComposerClient::Composition::DEVICE);
|
||||
|
||||
// set the layer to the blue buffer
|
||||
// should be blue
|
||||
{
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(
|
||||
mPrimaryDisplay, readbackBuffer->handle, noFence));
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 0, blueBuffer->handle, blueFence);
|
||||
mWriter->validateDisplay();
|
||||
execute();
|
||||
ASSERT_TRUE(mReader->mCompositionChanges.empty());
|
||||
ASSERT_TRUE(mReader->mErrors.size());
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->presentDisplay();
|
||||
execute();
|
||||
int32_t fence;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence));
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::compareColorToBuffer(BLUE, readbackBuffer, fence));
|
||||
}
|
||||
|
||||
// change the layer to the red buffer
|
||||
// should be red
|
||||
{
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(
|
||||
mPrimaryDisplay, readbackBuffer->handle, noFence));
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 1, redBuffer->handle, redFence);
|
||||
mWriter->validateDisplay();
|
||||
execute();
|
||||
ASSERT_TRUE(mReader->mCompositionChanges.empty());
|
||||
ASSERT_TRUE(mReader->mErrors.size());
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->presentDisplay();
|
||||
execute();
|
||||
int32_t fence;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence));
|
||||
ReadbackHelper::compareColorToBuffer(RED, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the blue buffer
|
||||
// should still be red
|
||||
{
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(
|
||||
mPrimaryDisplay, readbackBuffer->handle, noFence));
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 0, clearSlotBuffer->handle, /*fence*/ -1);
|
||||
mWriter->validateDisplay();
|
||||
execute();
|
||||
ASSERT_TRUE(mReader->mCompositionChanges.empty());
|
||||
ASSERT_TRUE(mReader->mErrors.size());
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->presentDisplay();
|
||||
execute();
|
||||
int32_t fence;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence));
|
||||
ReadbackHelper::compareColorToBuffer(RED, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the red buffer, and set the buffer with the same slot to the blue buffer
|
||||
// should be blue
|
||||
{
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(
|
||||
mPrimaryDisplay, readbackBuffer->handle, noFence));
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 1, clearSlotBuffer->handle, /*fence*/ -1);
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 1, blueBuffer->handle, blueFence);
|
||||
mWriter->validateDisplay();
|
||||
execute();
|
||||
ASSERT_TRUE(mReader->mCompositionChanges.empty());
|
||||
ASSERT_TRUE(mReader->mErrors.size());
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->presentDisplay();
|
||||
execute();
|
||||
int32_t fence;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence));
|
||||
ReadbackHelper::compareColorToBuffer(BLUE, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the now-blue buffer
|
||||
// should be black (no buffer)
|
||||
// TODO(b/262037933) Ensure we never clear the active buffer's slot with the placeholder buffer
|
||||
// by setting the layer to the color black
|
||||
{
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(
|
||||
mPrimaryDisplay, readbackBuffer->handle, noFence));
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->selectLayer(layer);
|
||||
mWriter->setLayerBuffer(/*slot*/ 1, clearSlotBuffer->handle, /*fence*/ -1);
|
||||
mWriter->validateDisplay();
|
||||
execute();
|
||||
ASSERT_TRUE(mReader->mCompositionChanges.empty());
|
||||
ASSERT_TRUE(mReader->mErrors.size());
|
||||
mWriter->selectDisplay(mPrimaryDisplay);
|
||||
mWriter->presentDisplay();
|
||||
execute();
|
||||
int32_t fence;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence));
|
||||
ReadbackHelper::compareColorToBuffer(BLACK, readbackBuffer, fence);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
||||
for (ColorMode mode : mTestColorModes) {
|
||||
std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
|
||||
|
@ -479,9 +327,15 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -496,7 +350,8 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
|||
layer->write(mWriter);
|
||||
|
||||
// This following buffer call should have no effect
|
||||
uint32_t usage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
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);
|
||||
|
@ -505,8 +360,8 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
|||
std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
|
||||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mWriter->validateDisplay();
|
||||
|
@ -537,11 +392,15 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
PixelFormat pixelFormat;
|
||||
Dataspace dataspace;
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &pixelFormat,
|
||||
&dataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(pixelFormat, dataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -569,8 +428,8 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
|
|||
|
||||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(layers);
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
@ -582,8 +441,9 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
|
|||
ASSERT_EQ(1, mReader->mCompositionChanges[0].second);
|
||||
|
||||
PixelFormat clientFormat = PixelFormat::RGBA_8888;
|
||||
uint32_t clientUsage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN |
|
||||
GRALLOC_USAGE_HW_FB;
|
||||
uint64_t clientUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN |
|
||||
BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
|
||||
IComposerClient::Rect damage{0, 0, mDisplayWidth, mDisplayHeight};
|
||||
|
||||
|
@ -650,9 +510,15 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -665,8 +531,8 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
|
||||
{0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight}, RED);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
auto deviceLayer = std::make_shared<TestBufferLayer>(
|
||||
|
@ -686,8 +552,9 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
deviceLayer->write(mWriter);
|
||||
|
||||
PixelFormat clientFormat = PixelFormat::RGBA_8888;
|
||||
uint32_t clientUsage =
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_FB;
|
||||
uint64_t clientUsage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
|
||||
int32_t clientWidth = mDisplayWidth;
|
||||
int32_t clientHeight = mDisplayHeight / 2;
|
||||
|
@ -766,9 +633,15 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -792,8 +665,8 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) {
|
|||
|
||||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -845,9 +718,15 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -863,8 +742,8 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
|
|||
|
||||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
|
@ -900,9 +779,15 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -934,8 +819,8 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
|
|||
// update expected colors to match crop
|
||||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
|
||||
{0, 0, mDisplayWidth, mDisplayHeight}, BLUE);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(layers);
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
@ -965,9 +850,15 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -995,8 +886,8 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
|
||||
ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -1128,9 +1019,15 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_None) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -1146,8 +1043,8 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_None) {
|
|||
setUpLayers(IComposerClient::BlendMode::NONE);
|
||||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
@ -1180,9 +1077,15 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_Coverage) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -1199,8 +1102,8 @@ TEST_P(GraphicsBlendModeCompositionTest, DISABLED_Coverage) {
|
|||
setUpLayers(IComposerClient::BlendMode::COVERAGE);
|
||||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
@ -1227,9 +1130,15 @@ TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
|
@ -1244,8 +1153,8 @@ TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
|
|||
setUpLayers(IComposerClient::BlendMode::PREMULTIPLIED);
|
||||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
@ -1313,16 +1222,22 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
mLayer->setTransform(Transform::FLIP_H);
|
||||
mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
|
||||
|
@ -1362,16 +1277,22 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mLayer->setTransform(Transform::FLIP_V);
|
||||
|
@ -1411,16 +1332,22 @@ TEST_P(GraphicsTransformCompositionTest, ROT_180) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &mPixelFormat,
|
||||
&mDataspace);
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(mPixelFormat, mDataspace, error);
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
|
||||
tmpDataspace, tmpError);
|
||||
mPixelFormat = tmpPixelFormat;
|
||||
mDataspace = tmpDataspace;
|
||||
});
|
||||
|
||||
if (!mHasReadbackBuffer) {
|
||||
std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
|
||||
GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
|
||||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat);
|
||||
ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
|
||||
mDisplayHeight, mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mLayer->setTransform(Transform::ROT_180);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <composer-vts/2.2/ComposerVts.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
|
@ -36,6 +35,7 @@ namespace V2_2 {
|
|||
namespace vts {
|
||||
namespace {
|
||||
|
||||
using common::V1_0::BufferUsage;
|
||||
using common::V1_1::ColorMode;
|
||||
using common::V1_1::Dataspace;
|
||||
using common::V1_1::PixelFormat;
|
||||
|
@ -65,13 +65,17 @@ class GraphicsComposerHidlTest : public ::testing::TestWithParam<std::string> {
|
|||
mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
|
||||
mComposerCallback->setVsyncAllowed(false);
|
||||
|
||||
Error error = mComposerClient->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay, &mReadbackPixelFormat, &mReadbackDataspace);
|
||||
mHasReadbackBuffer = error == Error::NONE;
|
||||
if (mHasReadbackBuffer) {
|
||||
ASSERT_LT(static_cast<PixelFormat>(0), mReadbackPixelFormat);
|
||||
ASSERT_NE(Dataspace::UNKNOWN, mReadbackDataspace);
|
||||
}
|
||||
mComposerClient->getRaw()->getReadbackBufferAttributes(
|
||||
mPrimaryDisplay,
|
||||
[&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
|
||||
mHasReadbackBuffer = tmpError == Error::NONE;
|
||||
if (mHasReadbackBuffer) {
|
||||
mReadbackPixelFormat = tmpPixelFormat;
|
||||
mReadbackDataspace = tmpDataspace;
|
||||
ASSERT_LT(static_cast<PixelFormat>(0), mReadbackPixelFormat);
|
||||
ASSERT_NE(Dataspace::UNKNOWN, mReadbackDataspace);
|
||||
}
|
||||
});
|
||||
|
||||
mInvalidDisplayId = GetInvalidDisplayId();
|
||||
}
|
||||
|
@ -149,9 +153,10 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
|||
}
|
||||
|
||||
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,
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN);
|
||||
PixelFormat::RGBA_8888, usage);
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
|
@ -429,7 +434,9 @@ TEST_P(GraphicsComposerHidlTest, SetReadbackBuffer) {
|
|||
}
|
||||
|
||||
// BufferUsage::COMPOSER_OUTPUT is missing
|
||||
uint64_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
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>());
|
||||
|
@ -450,7 +457,9 @@ TEST_P(GraphicsComposerHidlTest, SetReadbackBufferBadDisplay) {
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
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>());
|
||||
|
@ -702,4 +711,4 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include "renderengine/ExternalTexture.h"
|
||||
#include "renderengine/impl/ExternalTexture.h"
|
||||
|
||||
using ::android::status_t;
|
||||
|
||||
namespace aidl::android::hardware::graphics::composer3::vts {
|
||||
|
||||
const std::vector<ColorMode> ReadbackHelper::colorModes = {ColorMode::SRGB, ColorMode::DISPLAY_P3};
|
||||
|
@ -29,9 +27,6 @@ const std::vector<Dataspace> ReadbackHelper::dataspaces = {common::Dataspace::SR
|
|||
common::Dataspace::DISPLAY_P3};
|
||||
|
||||
void TestLayer::write(ComposerClientWriter& writer) {
|
||||
::android::status_t status = ::android::OK;
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
|
||||
writer.setLayerDisplayFrame(mDisplay, mLayer, mDisplayFrame);
|
||||
writer.setLayerSourceCrop(mDisplay, mLayer, mSourceCrop);
|
||||
writer.setLayerZOrder(mDisplay, mLayer, mZOrder);
|
||||
|
@ -42,40 +37,6 @@ void TestLayer::write(ComposerClientWriter& writer) {
|
|||
writer.setLayerBrightness(mDisplay, mLayer, mBrightness);
|
||||
}
|
||||
|
||||
bool ReadbackHelper::readbackSupported(const common::PixelFormat& pixelFormat,
|
||||
const common::Dataspace& dataspace) {
|
||||
// TODO: add support for RGBA_1010102
|
||||
if (pixelFormat != common::PixelFormat::RGB_888 &&
|
||||
pixelFormat != common::PixelFormat::RGBA_8888) {
|
||||
return false;
|
||||
}
|
||||
if (std::find(dataspaces.begin(), dataspaces.end(), dataspace) == dataspaces.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReadbackHelper::createReadbackBuffer(ReadbackBufferAttributes readbackBufferAttributes,
|
||||
const VtsDisplay& display,
|
||||
sp<GraphicBuffer>* graphicBuffer) {
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
if (!readbackSupported(readbackBufferAttributes.format, readbackBufferAttributes.dataspace)) {
|
||||
*graphicBuffer = nullptr;
|
||||
}
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint64_t>(common::BufferUsage::GPU_TEXTURE));
|
||||
|
||||
uint32_t layerCount = 1;
|
||||
*graphicBuffer = sp<GraphicBuffer>::make(
|
||||
static_cast<uint32_t>(display.getDisplayWidth()),
|
||||
static_cast<uint32_t>(display.getDisplayHeight()),
|
||||
static_cast<::android::PixelFormat>(readbackBufferAttributes.format), layerCount, usage,
|
||||
"ReadbackBuffer");
|
||||
ASSERT_NE(nullptr, *graphicBuffer);
|
||||
ASSERT_EQ(::android::OK, (*graphicBuffer)->initCheck());
|
||||
}
|
||||
|
||||
std::string ReadbackHelper::getColorModeString(ColorMode mode) {
|
||||
switch (mode) {
|
||||
case ColorMode::SRGB:
|
||||
|
@ -142,11 +103,11 @@ LayerSettings TestLayer::toRenderEngineLayerSettings() {
|
|||
return layerSettings;
|
||||
}
|
||||
|
||||
int32_t ReadbackHelper::GetBytesPerPixel(PixelFormat pixelFormat) {
|
||||
int32_t ReadbackHelper::GetBytesPerPixel(common::PixelFormat pixelFormat) {
|
||||
switch (pixelFormat) {
|
||||
case PixelFormat::RGBA_8888:
|
||||
case common::PixelFormat::RGBA_8888:
|
||||
return 4;
|
||||
case PixelFormat::RGB_888:
|
||||
case common::PixelFormat::RGB_888:
|
||||
return 3;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -155,161 +116,136 @@ int32_t ReadbackHelper::GetBytesPerPixel(PixelFormat pixelFormat) {
|
|||
|
||||
void ReadbackHelper::fillBuffer(uint32_t width, uint32_t height, uint32_t stride, void* bufferData,
|
||||
common::PixelFormat pixelFormat,
|
||||
const std::vector<Color>& desiredColors) {
|
||||
std::vector<Color> desiredPixelColors) {
|
||||
ASSERT_TRUE(pixelFormat == common::PixelFormat::RGB_888 ||
|
||||
pixelFormat == common::PixelFormat::RGBA_8888);
|
||||
int32_t bytesPerPixel = GetBytesPerPixel(pixelFormat);
|
||||
ASSERT_NE(-1, bytesPerPixel);
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int pixel = row * static_cast<int32_t>(width) + col;
|
||||
Color desiredColor = desiredColors[static_cast<size_t>(pixel)];
|
||||
auto pixel = row * static_cast<int32_t>(width) + col;
|
||||
Color srcColor = desiredPixelColors[static_cast<size_t>(pixel)];
|
||||
|
||||
int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
|
||||
pixelColor[0] = static_cast<uint8_t>(std::round(255.0f * desiredColor.r));
|
||||
pixelColor[1] = static_cast<uint8_t>(std::round(255.0f * desiredColor.g));
|
||||
pixelColor[2] = static_cast<uint8_t>(std::round(255.0f * desiredColor.b));
|
||||
pixelColor[0] = static_cast<uint8_t>(std::round(255.0f * srcColor.r));
|
||||
pixelColor[1] = static_cast<uint8_t>(std::round(255.0f * srcColor.g));
|
||||
pixelColor[2] = static_cast<uint8_t>(std::round(255.0f * srcColor.b));
|
||||
|
||||
if (bytesPerPixel == 4) {
|
||||
pixelColor[3] = static_cast<uint8_t>(std::round(255.0f * desiredColor.a));
|
||||
pixelColor[3] = static_cast<uint8_t>(std::round(255.0f * srcColor.a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadbackHelper::clearColors(std::vector<Color>& colors, int32_t width, int32_t height,
|
||||
void ReadbackHelper::clearColors(std::vector<Color>& expectedColors, int32_t width, int32_t height,
|
||||
int32_t displayWidth) {
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
int pixel = row * displayWidth + col;
|
||||
colors[static_cast<size_t>(pixel)] = BLACK;
|
||||
expectedColors[static_cast<size_t>(pixel)] = BLACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillColorsArea(std::vector<Color>& colors, int32_t stride, Rect area,
|
||||
Color desiredColor) {
|
||||
void ReadbackHelper::fillColorsArea(std::vector<Color>& expectedColors, int32_t stride, Rect area,
|
||||
Color color) {
|
||||
for (int row = area.top; row < area.bottom; row++) {
|
||||
for (int col = area.left; col < area.right; col++) {
|
||||
int pixel = row * stride + col;
|
||||
colors[static_cast<size_t>(pixel)] = desiredColor;
|
||||
expectedColors[static_cast<size_t>(pixel)] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
Color desiredColor, int* fillFence) {
|
||||
ASSERT_NE(nullptr, fillFence);
|
||||
std::vector<Color> desiredColors(
|
||||
static_cast<size_t>(graphicBuffer->getWidth() * graphicBuffer->getHeight()));
|
||||
::android::Rect bounds = graphicBuffer->getBounds();
|
||||
fillColorsArea(desiredColors, static_cast<int32_t>(graphicBuffer->getWidth()),
|
||||
{bounds.left, bounds.top, bounds.right, bounds.bottom}, desiredColor);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBufferAndGetFence(graphicBuffer, desiredColors, fillFence));
|
||||
}
|
||||
|
||||
void ReadbackHelper::fillBufferAndGetFence(const sp<GraphicBuffer>& graphicBuffer,
|
||||
const std::vector<Color>& desiredColors,
|
||||
int* fillFence) {
|
||||
ASSERT_TRUE(graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGB_888 ||
|
||||
graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGBA_8888);
|
||||
void* bufData;
|
||||
int32_t bytesPerPixel = -1;
|
||||
int32_t bytesPerStride = -1;
|
||||
status_t status =
|
||||
graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||
&bufData, &bytesPerPixel, &bytesPerStride);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: graphicBuffer->getStride();
|
||||
ReadbackHelper::fillBuffer(
|
||||
graphicBuffer->getWidth(), graphicBuffer->getHeight(), stride, bufData,
|
||||
static_cast<common::PixelFormat>(graphicBuffer->getPixelFormat()), desiredColors);
|
||||
status = graphicBuffer->unlockAsync(fillFence);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
}
|
||||
|
||||
void ReadbackHelper::compareColorToBuffer(Color expectedColor,
|
||||
const sp<GraphicBuffer>& graphicBuffer,
|
||||
const ndk::ScopedFileDescriptor& fence) {
|
||||
std::vector<Color> expectedColors(
|
||||
static_cast<size_t>(graphicBuffer->getWidth() * graphicBuffer->getHeight()));
|
||||
::android::Rect bounds = graphicBuffer->getBounds();
|
||||
fillColorsArea(expectedColors, static_cast<int32_t>(graphicBuffer->getWidth()),
|
||||
{bounds.left, bounds.top, bounds.right, bounds.bottom}, expectedColor);
|
||||
compareColorsToBuffer(expectedColors, graphicBuffer, fence);
|
||||
}
|
||||
|
||||
void ReadbackHelper::compareColorsToBuffer(const std::vector<Color>& expectedColors,
|
||||
const sp<GraphicBuffer>& graphicBuffer,
|
||||
const ndk::ScopedFileDescriptor& fence) {
|
||||
ASSERT_TRUE(graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGB_888 ||
|
||||
graphicBuffer->getPixelFormat() == ::android::PIXEL_FORMAT_RGBA_8888);
|
||||
|
||||
int bytesPerPixel = -1;
|
||||
int bytesPerStride = -1;
|
||||
void* bufData = nullptr;
|
||||
status_t status = graphicBuffer->lockAsync(GRALLOC_USAGE_SW_READ_OFTEN, &bufData,
|
||||
dup(fence.get()), &bytesPerPixel, &bytesPerStride);
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: graphicBuffer->getStride();
|
||||
|
||||
if (bytesPerPixel == -1) {
|
||||
bytesPerPixel = ReadbackHelper::GetBytesPerPixel(
|
||||
static_cast<PixelFormat>(graphicBuffer->getPixelFormat()));
|
||||
bool ReadbackHelper::readbackSupported(const common::PixelFormat& pixelFormat,
|
||||
const common::Dataspace& dataspace) {
|
||||
if (pixelFormat != common::PixelFormat::RGB_888 &&
|
||||
pixelFormat != common::PixelFormat::RGBA_8888) {
|
||||
return false;
|
||||
}
|
||||
if (std::find(dataspaces.begin(), dataspaces.end(), dataspace) == dataspaces.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReadbackHelper::compareColorBuffers(const std::vector<Color>& expectedColors, void* bufferData,
|
||||
const uint32_t stride, const uint32_t width,
|
||||
const uint32_t height, common::PixelFormat pixelFormat) {
|
||||
const int32_t bytesPerPixel = ReadbackHelper::GetBytesPerPixel(pixelFormat);
|
||||
ASSERT_NE(-1, bytesPerPixel);
|
||||
for (int row = 0; row < graphicBuffer->getHeight(); row++) {
|
||||
for (int col = 0; col < graphicBuffer->getWidth(); col++) {
|
||||
int pixel = row * static_cast<int32_t>(graphicBuffer->getWidth()) + col;
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
auto pixel = row * static_cast<int32_t>(width) + col;
|
||||
int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufData + offset;
|
||||
uint8_t* pixelColor = (uint8_t*)bufferData + offset;
|
||||
const Color expectedColor = expectedColors[static_cast<size_t>(pixel)];
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.r), pixelColor[0]);
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.g), pixelColor[1]);
|
||||
ASSERT_EQ(std::round(255.0f * expectedColor.b), pixelColor[2]);
|
||||
}
|
||||
}
|
||||
|
||||
status = graphicBuffer->unlock();
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
}
|
||||
|
||||
ReadbackBuffer::ReadbackBuffer(int64_t display, const std::shared_ptr<VtsComposerClient>& client,
|
||||
int32_t width, int32_t height, common::PixelFormat pixelFormat)
|
||||
int32_t width, int32_t height, common::PixelFormat pixelFormat,
|
||||
common::Dataspace dataspace)
|
||||
: mComposerClient(client) {
|
||||
mDisplay = display;
|
||||
|
||||
mPixelFormat = pixelFormat;
|
||||
mDataspace = dataspace;
|
||||
|
||||
mWidth = static_cast<uint32_t>(width);
|
||||
mHeight = static_cast<uint32_t>(height);
|
||||
mPixelFormat = pixelFormat;
|
||||
mLayerCount = 1;
|
||||
mUsage = static_cast<uint64_t>(static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint64_t>(common::BufferUsage::GPU_TEXTURE));
|
||||
|
||||
mAccessRegion.top = 0;
|
||||
mAccessRegion.left = 0;
|
||||
mAccessRegion.right = static_cast<int32_t>(width);
|
||||
mAccessRegion.bottom = static_cast<int32_t>(height);
|
||||
}
|
||||
|
||||
::android::sp<::android::GraphicBuffer> ReadbackBuffer::allocateBuffer() {
|
||||
return ::android::sp<::android::GraphicBuffer>::make(
|
||||
mWidth, mHeight, static_cast<::android::PixelFormat>(mPixelFormat), mLayerCount, mUsage,
|
||||
"ReadbackBuffer");
|
||||
}
|
||||
|
||||
void ReadbackBuffer::setReadbackBuffer() {
|
||||
mGraphicBuffer = sp<GraphicBuffer>::make(mWidth, mHeight,
|
||||
static_cast<::android::PixelFormat>(mPixelFormat),
|
||||
mLayerCount, mUsage, "ReadbackBuffer");
|
||||
mGraphicBuffer = allocateBuffer();
|
||||
ASSERT_NE(nullptr, mGraphicBuffer);
|
||||
ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
|
||||
::ndk::ScopedFileDescriptor noFence = ::ndk::ScopedFileDescriptor(-1);
|
||||
const auto& status =
|
||||
mComposerClient->setReadbackBuffer(mDisplay, mGraphicBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
const auto& bufferHandle = mGraphicBuffer->handle;
|
||||
::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
|
||||
EXPECT_TRUE(mComposerClient->setReadbackBuffer(mDisplay, bufferHandle, fence).isOk());
|
||||
}
|
||||
|
||||
void ReadbackBuffer::checkReadbackBuffer(const std::vector<Color>& expectedColors) {
|
||||
ASSERT_NE(nullptr, mGraphicBuffer);
|
||||
// lock buffer for reading
|
||||
const auto& [fenceStatus, bufferFence] = mComposerClient->getReadbackBufferFence(mDisplay);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorsToBuffer(expectedColors, mGraphicBuffer, bufferFence);
|
||||
EXPECT_TRUE(fenceStatus.isOk());
|
||||
|
||||
int bytesPerPixel = -1;
|
||||
int bytesPerStride = -1;
|
||||
void* bufData = nullptr;
|
||||
|
||||
auto status = mGraphicBuffer->lockAsync(mUsage, mAccessRegion, &bufData, dup(bufferFence.get()),
|
||||
&bytesPerPixel, &bytesPerStride);
|
||||
EXPECT_EQ(::android::OK, status);
|
||||
ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: mGraphicBuffer->getStride();
|
||||
ReadbackHelper::compareColorBuffers(expectedColors, bufData, stride, mWidth, mHeight,
|
||||
mPixelFormat);
|
||||
status = mGraphicBuffer->unlock();
|
||||
EXPECT_EQ(::android::OK, status);
|
||||
}
|
||||
|
||||
void TestColorLayer::write(ComposerClientWriter& writer) {
|
||||
|
@ -387,8 +323,9 @@ void TestBufferLayer::fillBuffer(std::vector<Color>& expectedColors) {
|
|||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: mGraphicBuffer->getStride();
|
||||
ASSERT_EQ(::android::OK, status);
|
||||
ReadbackHelper::fillBuffer(mWidth, mHeight, stride, bufData, mPixelFormat, expectedColors);
|
||||
EXPECT_EQ(::android::OK, status);
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mWidth, mHeight, stride, bufData,
|
||||
mPixelFormat, expectedColors));
|
||||
|
||||
const auto unlockStatus = mGraphicBuffer->unlockAsync(&mFillFence);
|
||||
ASSERT_EQ(::android::OK, unlockStatus);
|
||||
|
@ -398,13 +335,13 @@ void TestBufferLayer::setBuffer(std::vector<Color> colors) {
|
|||
mGraphicBuffer = allocateBuffer();
|
||||
ASSERT_NE(nullptr, mGraphicBuffer);
|
||||
ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
|
||||
fillBuffer(colors);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(colors));
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> TestBufferLayer::allocateBuffer() {
|
||||
return sp<GraphicBuffer>::make(mWidth, mHeight,
|
||||
static_cast<::android::PixelFormat>(mPixelFormat), mLayerCount,
|
||||
mUsage, "TestBufferLayer");
|
||||
::android::sp<::android::GraphicBuffer> TestBufferLayer::allocateBuffer() {
|
||||
return ::android::sp<::android::GraphicBuffer>::make(
|
||||
mWidth, mHeight, static_cast<::android::PixelFormat>(mPixelFormat), mLayerCount, mUsage,
|
||||
"TestBufferLayer");
|
||||
}
|
||||
|
||||
void TestBufferLayer::setDataspace(common::Dataspace dataspace, ComposerClientWriter& writer) {
|
||||
|
|
|
@ -33,8 +33,6 @@ using ::android::renderengine::LayerSettings;
|
|||
using common::Dataspace;
|
||||
using common::PixelFormat;
|
||||
using IMapper2_1 = ::android::hardware::graphics::mapper::V2_1::IMapper;
|
||||
using ::android::GraphicBuffer;
|
||||
using ::android::sp;
|
||||
|
||||
static const Color BLACK = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
static const Color RED = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
@ -148,7 +146,7 @@ class TestBufferLayer : public TestLayer {
|
|||
|
||||
protected:
|
||||
Composition mComposition;
|
||||
sp<GraphicBuffer> mGraphicBuffer;
|
||||
::android::sp<::android::GraphicBuffer> mGraphicBuffer;
|
||||
TestRenderEngine& mRenderEngine;
|
||||
int32_t mFillFence;
|
||||
uint32_t mWidth;
|
||||
|
@ -164,11 +162,6 @@ class TestBufferLayer : public TestLayer {
|
|||
|
||||
class ReadbackHelper {
|
||||
public:
|
||||
static bool readbackSupported(const PixelFormat& pixelFormat, const Dataspace& dataspace);
|
||||
|
||||
static void createReadbackBuffer(ReadbackBufferAttributes readbackBufferAttributes,
|
||||
const VtsDisplay& display, sp<GraphicBuffer>* graphicBuffer);
|
||||
|
||||
static std::string getColorModeString(ColorMode mode);
|
||||
|
||||
static std::string getDataspaceString(Dataspace dataspace);
|
||||
|
@ -178,36 +171,28 @@ class ReadbackHelper {
|
|||
static int32_t GetBytesPerPixel(PixelFormat pixelFormat);
|
||||
|
||||
static void fillBuffer(uint32_t width, uint32_t height, uint32_t stride, void* bufferData,
|
||||
PixelFormat pixelFormat, const std::vector<Color>& desriedColors);
|
||||
PixelFormat pixelFormat, std::vector<Color> desiredPixelColors);
|
||||
|
||||
static void clearColors(std::vector<Color>& colors, int32_t width, int32_t height,
|
||||
static void clearColors(std::vector<Color>& expectedColors, int32_t width, int32_t height,
|
||||
int32_t displayWidth);
|
||||
|
||||
static void fillColorsArea(std::vector<Color>& colors, int32_t stride, Rect area,
|
||||
Color desiredColor);
|
||||
static void fillColorsArea(std::vector<Color>& expectedColors, int32_t stride, Rect area,
|
||||
Color color);
|
||||
|
||||
static void fillBufferAndGetFence(const sp<GraphicBuffer>& buffer, Color desiredColor,
|
||||
int* fillFence);
|
||||
|
||||
static void fillBufferAndGetFence(const sp<GraphicBuffer>& buffer,
|
||||
const std::vector<Color>& desiredColors, int* fillFence);
|
||||
|
||||
static void compareColorToBuffer(
|
||||
Color expectedColor, const sp<GraphicBuffer>& graphicBuffer,
|
||||
const ndk::ScopedFileDescriptor& fence = ::ndk::ScopedFileDescriptor(-1));
|
||||
|
||||
static void compareColorsToBuffer(
|
||||
const std::vector<Color>& expectedColors, const sp<GraphicBuffer>& graphicBuffer,
|
||||
const ndk::ScopedFileDescriptor& fence = ::ndk::ScopedFileDescriptor(-1));
|
||||
static bool readbackSupported(const PixelFormat& pixelFormat, const Dataspace& dataspace);
|
||||
|
||||
static const std::vector<ColorMode> colorModes;
|
||||
static const std::vector<Dataspace> dataspaces;
|
||||
|
||||
static void compareColorBuffers(const std::vector<Color>& expectedColors, void* bufferData,
|
||||
const uint32_t stride, const uint32_t width,
|
||||
const uint32_t height, PixelFormat pixelFormat);
|
||||
};
|
||||
|
||||
class ReadbackBuffer {
|
||||
public:
|
||||
ReadbackBuffer(int64_t display, const std::shared_ptr<VtsComposerClient>& client, int32_t width,
|
||||
int32_t height, common::PixelFormat pixelFormat);
|
||||
int32_t height, common::PixelFormat pixelFormat, common::Dataspace dataspace);
|
||||
|
||||
void setReadbackBuffer();
|
||||
|
||||
|
@ -216,12 +201,18 @@ class ReadbackBuffer {
|
|||
protected:
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
PixelFormat mPixelFormat;
|
||||
uint32_t mLayerCount;
|
||||
uint32_t mUsage;
|
||||
PixelFormat mPixelFormat;
|
||||
Dataspace mDataspace;
|
||||
int64_t mDisplay;
|
||||
sp<GraphicBuffer> mGraphicBuffer;
|
||||
::android::sp<::android::GraphicBuffer> mGraphicBuffer;
|
||||
std::shared_ptr<VtsComposerClient> mComposerClient;
|
||||
::android::Rect mAccessRegion;
|
||||
native_handle_t mBufferHandle;
|
||||
|
||||
private:
|
||||
::android::sp<::android::GraphicBuffer> allocateBuffer();
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::graphics::composer3::vts
|
||||
|
|
|
@ -76,7 +76,18 @@ void TestRenderEngine::drawLayers() {
|
|||
}
|
||||
|
||||
void TestRenderEngine::checkColorBuffer(const std::vector<Color>& expectedColors) {
|
||||
ReadbackHelper::compareColorsToBuffer(expectedColors, mGraphicBuffer);
|
||||
void* bufferData;
|
||||
int32_t bytesPerPixel = -1;
|
||||
int32_t bytesPerStride = -1;
|
||||
ASSERT_EQ(0, mGraphicBuffer->lock(static_cast<uint32_t>(mGraphicBuffer->getUsage()),
|
||||
&bufferData, &bytesPerPixel, &bytesPerStride));
|
||||
const uint32_t stride = (bytesPerPixel > 0 && bytesPerStride > 0)
|
||||
? static_cast<uint32_t>(bytesPerStride / bytesPerPixel)
|
||||
: mGraphicBuffer->getStride();
|
||||
ReadbackHelper::compareColorBuffers(expectedColors, bufferData, stride,
|
||||
mGraphicBuffer->getWidth(), mGraphicBuffer->getHeight(),
|
||||
mFormat);
|
||||
ASSERT_EQ(::android::OK, mGraphicBuffer->unlock());
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::graphics::composer3::vts
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <aidl/Gtest.h>
|
||||
#include <aidl/Vintf.h>
|
||||
#include <aidl/android/hardware/graphics/common/BufferUsage.h>
|
||||
#include <aidl/android/hardware/graphics/composer3/IComposer.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <ui/DisplayId.h>
|
||||
|
@ -80,11 +81,13 @@ class GraphicsCompositionTestBase : public ::testing::Test {
|
|||
clientCompositionDisplay.physicalDisplay = Rect(getDisplayWidth(), getDisplayHeight());
|
||||
clientCompositionDisplay.clip = clientCompositionDisplay.physicalDisplay;
|
||||
|
||||
mTestRenderEngine->initGraphicBuffer(static_cast<uint32_t>(getDisplayWidth()),
|
||||
static_cast<uint32_t>(getDisplayHeight()),
|
||||
/*layerCount*/ 1U,
|
||||
GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_SW_READ_OFTEN |
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN);
|
||||
mTestRenderEngine->initGraphicBuffer(
|
||||
static_cast<uint32_t>(getDisplayWidth()), static_cast<uint32_t>(getDisplayHeight()),
|
||||
/*layerCount*/ 1U,
|
||||
static_cast<uint64_t>(
|
||||
static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
|
||||
static_cast<uint64_t>(common::BufferUsage::GPU_RENDER_TARGET)));
|
||||
mTestRenderEngine->setDisplaySettings(clientCompositionDisplay);
|
||||
}
|
||||
|
||||
|
@ -112,21 +115,18 @@ class GraphicsCompositionTestBase : public ::testing::Test {
|
|||
ASSERT_EQ(status.getServiceSpecificError(), serviceSpecificError);
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> allocateBuffer(uint32_t width, uint32_t height, uint64_t usage) {
|
||||
sp<GraphicBuffer> graphicBuffer =
|
||||
sp<GraphicBuffer>::make(width, height, ::android::PIXEL_FORMAT_RGBA_8888,
|
||||
/*layerCount*/ 1u, static_cast<uint32_t>(usage),
|
||||
"VtsHalGraphicsComposer3_ReadbackTest");
|
||||
std::pair<bool, ::android::sp<::android::GraphicBuffer>> allocateBuffer(uint32_t usage) {
|
||||
const auto width = static_cast<uint32_t>(getDisplayWidth());
|
||||
const auto height = static_cast<uint32_t>(getDisplayHeight());
|
||||
|
||||
const auto& graphicBuffer = ::android::sp<::android::GraphicBuffer>::make(
|
||||
width, height, ::android::PIXEL_FORMAT_RGBA_8888,
|
||||
/*layerCount*/ 1u, usage, "VtsHalGraphicsComposer3_ReadbackTest");
|
||||
|
||||
if (graphicBuffer && ::android::OK == graphicBuffer->initCheck()) {
|
||||
return graphicBuffer;
|
||||
return {true, graphicBuffer};
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> allocateBuffer(uint64_t usage) {
|
||||
return allocateBuffer(static_cast<uint32_t>(getDisplayWidth()),
|
||||
static_cast<uint32_t>(getDisplayHeight()), usage);
|
||||
return {false, graphicBuffer};
|
||||
}
|
||||
|
||||
uint64_t getStableDisplayId(int64_t display) {
|
||||
|
@ -293,7 +293,7 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), coloredSquare, BLUE);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -332,7 +332,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
|
|||
}
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
std::vector<Color> expectedColors(
|
||||
static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
|
||||
|
@ -378,143 +378,6 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_P(GraphicsCompositionTest, SetLayerBufferWithSlotsToClear) {
|
||||
const auto& [status, readbackBufferAttributes] =
|
||||
mComposerClient->getReadbackBufferAttributes(getPrimaryDisplayId());
|
||||
if (!status.isOk()) {
|
||||
GTEST_SUCCEED() << "Readback not supported";
|
||||
return;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> readbackBuffer;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::createReadbackBuffer(
|
||||
readbackBufferAttributes, getPrimaryDisplay(), &readbackBuffer));
|
||||
if (readbackBuffer == nullptr) {
|
||||
GTEST_SUCCEED() << "Unsupported readback buffer attributes";
|
||||
return;
|
||||
}
|
||||
// no fence needed for the readback buffer
|
||||
ScopedFileDescriptor noFence(-1);
|
||||
|
||||
sp<GraphicBuffer> clearSlotBuffer = allocateBuffer(1u, 1u, GRALLOC_USAGE_HW_COMPOSER);
|
||||
ASSERT_NE(nullptr, clearSlotBuffer);
|
||||
|
||||
// red buffer
|
||||
uint64_t usage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
sp<GraphicBuffer> redBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, redBuffer);
|
||||
int redFence;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBufferAndGetFence(redBuffer, RED, &redFence));
|
||||
|
||||
// blue buffer
|
||||
sp<GraphicBuffer> blueBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, blueBuffer);
|
||||
int blueFence;
|
||||
ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBufferAndGetFence(blueBuffer, BLUE, &blueFence));
|
||||
|
||||
// layer defaults
|
||||
common::Rect rectFullDisplay = {0, 0, getDisplayWidth(), getDisplayHeight()};
|
||||
int64_t display = getPrimaryDisplayId();
|
||||
auto [layerStatus, layer] = mComposerClient->createLayer(getPrimaryDisplayId(), 3);
|
||||
ASSERT_TRUE(layerStatus.isOk());
|
||||
mWriter->setLayerDisplayFrame(display, layer, rectFullDisplay);
|
||||
mWriter->setLayerCompositionType(display, layer, Composition::DEVICE);
|
||||
|
||||
// set the layer to the blue buffer
|
||||
// should be blue
|
||||
{
|
||||
auto status = mComposerClient->setReadbackBuffer(display, readbackBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
mWriter->setLayerBuffer(display, layer, /*slot*/ 0, blueBuffer->handle, blueFence);
|
||||
mWriter->validateDisplay(display, ComposerClientWriter::kNoTimestamp);
|
||||
execute();
|
||||
ASSERT_TRUE(mReader.takeChangedCompositionTypes(display).empty());
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
mWriter->presentDisplay(display);
|
||||
execute();
|
||||
auto [fenceStatus, fence] = mComposerClient->getReadbackBufferFence(display);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorToBuffer(BLUE, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// change the layer to the red buffer
|
||||
// should be red
|
||||
{
|
||||
auto status = mComposerClient->setReadbackBuffer(display, readbackBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
mWriter->setLayerBuffer(display, layer, /*slot*/ 1, redBuffer->handle, redFence);
|
||||
mWriter->validateDisplay(display, ComposerClientWriter::kNoTimestamp);
|
||||
execute();
|
||||
ASSERT_TRUE(mReader.takeChangedCompositionTypes(display).empty());
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
mWriter->presentDisplay(display);
|
||||
execute();
|
||||
auto [fenceStatus, fence] = mComposerClient->getReadbackBufferFence(display);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorToBuffer(RED, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the blue buffer
|
||||
// should still be red
|
||||
{
|
||||
auto status = mComposerClient->setReadbackBuffer(display, readbackBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
mWriter->setLayerBufferWithNewCommand(display, layer, /*slot*/ 0, clearSlotBuffer->handle,
|
||||
/*fence*/ -1);
|
||||
mWriter->validateDisplay(display, ComposerClientWriter::kNoTimestamp);
|
||||
execute();
|
||||
ASSERT_TRUE(mReader.takeChangedCompositionTypes(display).empty());
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
mWriter->presentDisplay(display);
|
||||
execute();
|
||||
auto [fenceStatus, fence] = mComposerClient->getReadbackBufferFence(display);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorToBuffer(RED, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the red buffer, and set the buffer with the same slot to the blue buffer
|
||||
// should be blue
|
||||
{
|
||||
auto status = mComposerClient->setReadbackBuffer(display, readbackBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
mWriter->setLayerBufferWithNewCommand(display, layer, /*slot*/ 1, clearSlotBuffer->handle,
|
||||
/*fence*/ -1);
|
||||
mWriter->setLayerBuffer(display, layer, /*slot*/ 1, blueBuffer->handle, blueFence);
|
||||
mWriter->validateDisplay(display, ComposerClientWriter::kNoTimestamp);
|
||||
execute();
|
||||
ASSERT_TRUE(mReader.takeChangedCompositionTypes(display).empty());
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
mWriter->presentDisplay(display);
|
||||
execute();
|
||||
auto [fenceStatus, fence] = mComposerClient->getReadbackBufferFence(display);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorToBuffer(BLUE, readbackBuffer, fence);
|
||||
}
|
||||
|
||||
// clear the slot for the now-blue buffer
|
||||
// should be black (no buffer)
|
||||
// TODO(b/262037933) Ensure we never clear the active buffer's slot with the placeholder buffer
|
||||
// by setting the layer to the color black
|
||||
{
|
||||
auto status = mComposerClient->setReadbackBuffer(display, readbackBuffer->handle, noFence);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
mWriter->setLayerBufferWithNewCommand(display, layer, /*slot*/ 1, clearSlotBuffer->handle,
|
||||
/*fence*/ -1);
|
||||
mWriter->validateDisplay(display, ComposerClientWriter::kNoTimestamp);
|
||||
execute();
|
||||
if (!mReader.takeChangedCompositionTypes(display).empty()) {
|
||||
GTEST_SUCCEED();
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
mWriter->presentDisplay(display);
|
||||
execute();
|
||||
auto [fenceStatus, fence] = mComposerClient->getReadbackBufferFence(display);
|
||||
ASSERT_TRUE(fenceStatus.isOk());
|
||||
ReadbackHelper::compareColorToBuffer(BLACK, readbackBuffer, fence);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
||||
for (ColorMode mode : mTestColorModes) {
|
||||
EXPECT_TRUE(mComposerClient
|
||||
|
@ -536,9 +399,10 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
|||
layer->write(*mWriter);
|
||||
|
||||
// This following buffer call should have no effect
|
||||
uint64_t usage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
sp<GraphicBuffer> graphicBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
const auto usage = static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN);
|
||||
const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(usage);
|
||||
ASSERT_TRUE(graphicBufferStatus);
|
||||
const auto& buffer = graphicBuffer->handle;
|
||||
mWriter->setLayerBuffer(getPrimaryDisplayId(), layer->getLayer(), /*slot*/ 0, buffer,
|
||||
/*acquireFence*/ -1);
|
||||
|
@ -549,7 +413,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), coloredSquare, BLUE);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp);
|
||||
|
@ -577,7 +441,7 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer) {
|
|||
}
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
}
|
||||
|
@ -590,9 +454,10 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadDisplay) {
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t usage = GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
sp<GraphicBuffer> graphicBuffer = allocateBuffer(usage);
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
const auto usage = static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN);
|
||||
const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(usage);
|
||||
ASSERT_TRUE(graphicBufferStatus);
|
||||
const auto& bufferHandle = graphicBuffer->handle;
|
||||
::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
|
||||
|
||||
|
@ -674,7 +539,7 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
|
|||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(layers);
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
|
@ -687,14 +552,16 @@ TEST_P(GraphicsCompositionTest, ClientComposition) {
|
|||
ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0].composition);
|
||||
|
||||
PixelFormat clientFormat = PixelFormat::RGBA_8888;
|
||||
auto clientUsage = GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_SW_READ_OFTEN |
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN;
|
||||
auto clientUsage = static_cast<uint32_t>(
|
||||
static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
|
||||
Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
|
||||
common::Rect damage{0, 0, getDisplayWidth(), getDisplayHeight()};
|
||||
|
||||
// create client target buffer
|
||||
sp<GraphicBuffer> graphicBuffer = allocateBuffer(clientUsage);
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(clientUsage);
|
||||
ASSERT_TRUE(graphicBufferStatus);
|
||||
const auto& buffer = graphicBuffer->handle;
|
||||
void* clientBufData;
|
||||
const auto stride = static_cast<uint32_t>(graphicBuffer->stride);
|
||||
|
@ -751,7 +618,7 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
{0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()}, RED);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
auto deviceLayer = std::make_shared<TestBufferLayer>(
|
||||
|
@ -770,8 +637,10 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
deviceLayer->write(*mWriter);
|
||||
|
||||
PixelFormat clientFormat = PixelFormat::RGBA_8888;
|
||||
auto clientUsage =
|
||||
GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
|
||||
auto clientUsage = static_cast<uint32_t>(
|
||||
static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
|
||||
static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
|
||||
Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
|
||||
int32_t clientWidth = getDisplayWidth();
|
||||
int32_t clientHeight = getDisplayHeight() / 2;
|
||||
|
@ -793,8 +662,8 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
|
|||
}
|
||||
// create client target buffer
|
||||
ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0].composition);
|
||||
sp<GraphicBuffer> graphicBuffer = allocateBuffer(clientUsage);
|
||||
ASSERT_NE(nullptr, graphicBuffer);
|
||||
const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(clientUsage);
|
||||
ASSERT_TRUE(graphicBufferStatus);
|
||||
const auto& buffer = graphicBuffer->handle;
|
||||
|
||||
void* clientBufData;
|
||||
|
@ -856,7 +725,7 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) {
|
|||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -924,7 +793,7 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
|
|||
std::vector<std::shared_ptr<TestLayer>> layers = {layer};
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
|
@ -990,7 +859,7 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
|
||||
{0, 0, getDisplayWidth(), getDisplayHeight()}, BLUE);
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(layers);
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
|
@ -1047,7 +916,7 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -1157,7 +1026,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBrightnessDims) {
|
|||
ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), dimmerRedRect, DIM_RED);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
writeLayers(layers);
|
||||
|
@ -1293,7 +1162,7 @@ TEST_P(GraphicsBlendModeCompositionTest, None) {
|
|||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
|
@ -1338,7 +1207,7 @@ TEST_P(GraphicsBlendModeCompositionTest, Coverage) {
|
|||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
|
@ -1378,7 +1247,7 @@ TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
|
|||
setExpectedColors(expectedColors);
|
||||
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
writeLayers(mLayers);
|
||||
ASSERT_TRUE(mReader.takeErrors().empty());
|
||||
|
@ -1452,7 +1321,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
|
|||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
mLayer->setTransform(Transform::FLIP_H);
|
||||
mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter);
|
||||
|
@ -1497,7 +1366,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
|
|||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mLayer->setTransform(Transform::FLIP_V);
|
||||
|
@ -1542,7 +1411,7 @@ TEST_P(GraphicsTransformCompositionTest, ROT_180) {
|
|||
return;
|
||||
}
|
||||
ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
|
||||
getDisplayHeight(), mPixelFormat);
|
||||
getDisplayHeight(), mPixelFormat, mDataspace);
|
||||
ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
|
||||
|
||||
mLayer->setTransform(Transform::ROT_180);
|
||||
|
|
Loading…
Reference in a new issue