mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Adding support for different Mapper versions in IComposer VTS tests" into qt-dev
This commit is contained in:
@@ -80,7 +80,8 @@ class ComposerImpl : public Interface {
|
||||
|
||||
Return<void> createClient(IComposer::createClient_cb hidl_cb) override {
|
||||
std::unique_lock<std::mutex> lock(mClientMutex);
|
||||
if (!waitForClientDestroyedLocked(lock)) {
|
||||
bool destroyed = waitForClientDestroyedLocked(lock);
|
||||
if (!destroyed) {
|
||||
hidl_cb(Error::NO_RESOURCES, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ cc_library_static {
|
||||
static_libs: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -315,6 +315,77 @@ void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* write
|
||||
writer->reset();
|
||||
}
|
||||
|
||||
Gralloc::Gralloc() {
|
||||
[this] {
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
|
||||
/*errOnFailure=*/false));
|
||||
if (mGralloc3->getAllocator() == nullptr || mGralloc3->getMapper() == nullptr) {
|
||||
mGralloc3 = nullptr;
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
const native_handle_t* Gralloc::allocate(uint32_t width, uint32_t height, uint32_t layerCount,
|
||||
PixelFormat format, uint64_t usage, bool import,
|
||||
uint32_t* outStride) {
|
||||
if (mGralloc3) {
|
||||
IMapper3::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
|
||||
info.usage = usage;
|
||||
return mGralloc3->allocate(info, import, outStride);
|
||||
} else {
|
||||
IMapper2::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = format;
|
||||
info.usage = usage;
|
||||
return mGralloc2->allocate(info, import, outStride);
|
||||
}
|
||||
}
|
||||
|
||||
void* Gralloc::lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const AccessRegion& accessRegionRect, int acquireFence) {
|
||||
if (mGralloc3) {
|
||||
IMapper3::Rect accessRegion;
|
||||
accessRegion.left = accessRegionRect.left;
|
||||
accessRegion.top = accessRegionRect.top;
|
||||
accessRegion.width = accessRegionRect.width;
|
||||
accessRegion.height = accessRegionRect.height;
|
||||
int32_t bytesPerPixel;
|
||||
int32_t bytesPerStride;
|
||||
return mGralloc3->lock(bufferHandle, cpuUsage, accessRegion, acquireFence, &bytesPerPixel,
|
||||
&bytesPerStride);
|
||||
} else {
|
||||
IMapper2::Rect accessRegion;
|
||||
accessRegion.left = accessRegionRect.left;
|
||||
accessRegion.top = accessRegionRect.top;
|
||||
accessRegion.width = accessRegionRect.width;
|
||||
accessRegion.height = accessRegionRect.height;
|
||||
return mGralloc2->lock(bufferHandle, cpuUsage, accessRegion, acquireFence);
|
||||
}
|
||||
}
|
||||
|
||||
int Gralloc::unlock(const native_handle_t* bufferHandle) {
|
||||
if (mGralloc3) {
|
||||
return mGralloc3->unlock(bufferHandle);
|
||||
} else {
|
||||
return mGralloc2->unlock(bufferHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void Gralloc::freeBuffer(const native_handle_t* bufferHandle) {
|
||||
if (mGralloc3) {
|
||||
mGralloc3->freeBuffer(bufferHandle);
|
||||
} else {
|
||||
mGralloc2->freeBuffer(bufferHandle);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_1
|
||||
} // namespace composer
|
||||
|
||||
@@ -25,8 +25,12 @@
|
||||
#include <android/hardware/graphics/composer/2.1/IComposer.h>
|
||||
#include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
#include <mapper-vts/3.0/MapperVts.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
@@ -38,6 +42,10 @@ using android::hardware::graphics::common::V1_0::ColorMode;
|
||||
using android::hardware::graphics::common::V1_0::Dataspace;
|
||||
using android::hardware::graphics::common::V1_0::Hdr;
|
||||
using android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
using IMapper2 = android::hardware::graphics::mapper::V2_0::IMapper;
|
||||
using IMapper3 = android::hardware::graphics::mapper::V3_0::IMapper;
|
||||
using Gralloc2 = android::hardware::graphics::mapper::V2_0::vts::Gralloc;
|
||||
using Gralloc3 = android::hardware::graphics::mapper::V3_0::vts::Gralloc;
|
||||
|
||||
class ComposerClient;
|
||||
|
||||
@@ -119,6 +127,34 @@ class ComposerClient {
|
||||
const sp<IComposerClient> mClient;
|
||||
};
|
||||
|
||||
class AccessRegion {
|
||||
public:
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
};
|
||||
|
||||
class Gralloc {
|
||||
public:
|
||||
explicit Gralloc();
|
||||
|
||||
const native_handle_t* allocate(uint32_t width, uint32_t height, uint32_t layerCount,
|
||||
PixelFormat format, uint64_t usage, bool import = true,
|
||||
uint32_t* outStride = nullptr);
|
||||
|
||||
void* lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const AccessRegion& accessRegionRect, int acquireFence);
|
||||
|
||||
int unlock(const native_handle_t* bufferHandle);
|
||||
|
||||
void freeBuffer(const native_handle_t* bufferHandle);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Gralloc2> mGralloc2 = nullptr;
|
||||
std::shared_ptr<Gralloc3> mGralloc3 = nullptr;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_1
|
||||
} // namespace composer
|
||||
|
||||
@@ -26,10 +26,13 @@ cc_test {
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <composer-vts/2.1/GraphicsComposerCallback.h>
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
#include <mapper-vts/3.0/MapperVts.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
@@ -47,8 +48,6 @@ using android::hardware::graphics::common::V1_0::ColorTransform;
|
||||
using android::hardware::graphics::common::V1_0::Dataspace;
|
||||
using android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
using android::hardware::graphics::common::V1_0::Transform;
|
||||
using android::hardware::graphics::mapper::V2_0::IMapper;
|
||||
using android::hardware::graphics::mapper::V2_0::vts::Gralloc;
|
||||
using GrallocError = android::hardware::graphics::mapper::V2_0::Error;
|
||||
|
||||
// Test environment for graphics.composer
|
||||
@@ -669,7 +668,6 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp());
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>());
|
||||
|
||||
Config activeConfig = mComposerClient->getActiveConfig(mPrimaryDisplay);
|
||||
mDisplayWidth = mComposerClient->getDisplayAttribute(mPrimaryDisplay, activeConfig,
|
||||
IComposerClient::Attribute::WIDTH);
|
||||
@@ -685,16 +683,10 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
}
|
||||
|
||||
const native_handle_t* allocate() {
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = mDisplayWidth;
|
||||
info.height = mDisplayHeight;
|
||||
info.layerCount = 1;
|
||||
info.format = PixelFormat::RGBA_8888;
|
||||
info.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN |
|
||||
BufferUsage::COMPOSER_OVERLAY);
|
||||
|
||||
return mGralloc->allocate(info);
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN |
|
||||
BufferUsage::COMPOSER_OVERLAY);
|
||||
return mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, PixelFormat::RGBA_8888, usage);
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
@@ -705,7 +697,7 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
int32_t mDisplayHeight;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Gralloc> mGralloc;
|
||||
std::unique_ptr<Gralloc> mGralloc;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,10 @@ cc_library_static {
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
export_static_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
|
||||
@@ -180,6 +180,48 @@ std::array<float, 16> ComposerClient::getDataspaceSaturationMatrix(Dataspace dat
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Gralloc::Gralloc() {
|
||||
[this] {
|
||||
ALOGD("Attempting to initialize gralloc3");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
|
||||
/*errOnFailure=*/false));
|
||||
if (mGralloc3->getMapper() == nullptr || mGralloc3->getAllocator() == nullptr) {
|
||||
mGralloc3 = nullptr;
|
||||
ALOGD("Failed to create gralloc3, initializing gralloc2_1");
|
||||
mGralloc2_1 = std::make_shared<Gralloc2_1>(/*errOnFailure*/ false);
|
||||
if (!mGralloc2_1->getMapper()) {
|
||||
mGralloc2_1 = nullptr;
|
||||
ALOGD("Failed to create gralloc2_1, initializing gralloc2");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
|
||||
}
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
bool Gralloc::validateBufferSize(const native_handle_t* bufferHandle, uint32_t width,
|
||||
uint32_t height, uint32_t layerCount, PixelFormat format,
|
||||
uint64_t usage, uint32_t stride) {
|
||||
if (mGralloc3) {
|
||||
IMapper3::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
|
||||
info.usage = usage;
|
||||
return mGralloc3->validateBufferSize(bufferHandle, info, stride);
|
||||
} else if (mGralloc2_1) {
|
||||
IMapper2_1::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = static_cast<android::hardware::graphics::common::V1_1::PixelFormat>(format);
|
||||
info.usage = usage;
|
||||
return mGralloc2_1->validateBufferSize(bufferHandle, info, stride);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_2
|
||||
} // namespace composer
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <android/hardware/graphics/composer/2.2/IComposerClient.h>
|
||||
#include <composer-command-buffer/2.2/ComposerCommandBuffer.h>
|
||||
#include <composer-vts/2.1/ComposerVts.h>
|
||||
#include <mapper-vts/2.1/MapperVts.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
namespace android {
|
||||
@@ -41,6 +42,11 @@ using common::V1_1::ColorMode;
|
||||
using common::V1_1::Dataspace;
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using IMapper2_1 = android::hardware::graphics::mapper::V2_1::IMapper;
|
||||
using IMapper3 = android::hardware::graphics::mapper::V3_0::IMapper;
|
||||
using Gralloc2 = android::hardware::graphics::mapper::V2_0::vts::Gralloc;
|
||||
using Gralloc2_1 = android::hardware::graphics::mapper::V2_1::vts::Gralloc;
|
||||
using Gralloc3 = android::hardware::graphics::mapper::V3_0::vts::Gralloc;
|
||||
|
||||
class ComposerClient;
|
||||
|
||||
@@ -84,6 +90,26 @@ class ComposerClient : public V2_1::vts::ComposerClient {
|
||||
const sp<IComposerClient> mClient;
|
||||
};
|
||||
|
||||
class Gralloc : public V2_1::vts::Gralloc {
|
||||
public:
|
||||
Gralloc();
|
||||
const native_handle_t* allocate(uint32_t width, uint32_t height, uint32_t layerCount,
|
||||
PixelFormat format, uint64_t usage, bool import = true,
|
||||
uint32_t* outStride = nullptr) {
|
||||
return V2_1::vts::Gralloc::allocate(
|
||||
width, height, layerCount,
|
||||
static_cast<android::hardware::graphics::common::V1_0::PixelFormat>(format), usage,
|
||||
import, outStride);
|
||||
}
|
||||
|
||||
bool validateBufferSize(const native_handle_t* bufferHandle, uint32_t width, uint32_t height,
|
||||
uint32_t layerCount, PixelFormat format, uint64_t usage,
|
||||
uint32_t stride);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Gralloc2_1> mGralloc2_1 = nullptr;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_2
|
||||
} // namespace composer
|
||||
|
||||
@@ -31,6 +31,7 @@ cc_test {
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
@@ -40,6 +41,8 @@ cc_test {
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -39,9 +39,9 @@ using common::V1_1::BufferUsage;
|
||||
using common::V1_1::Dataspace;
|
||||
using common::V1_1::PixelFormat;
|
||||
using mapper::V2_1::IMapper;
|
||||
using mapper::V2_1::vts::Gralloc;
|
||||
using V2_1::Display;
|
||||
using V2_1::Layer;
|
||||
using V2_1::vts::AccessRegion;
|
||||
using V2_1::vts::TestCommandReader;
|
||||
|
||||
static const IComposerClient::Color BLACK = {0, 0, 0, 0xff};
|
||||
@@ -296,14 +296,13 @@ class ReadbackBuffer {
|
||||
mComposerClient = client;
|
||||
mGralloc = gralloc;
|
||||
|
||||
mPixelFormat = pixelFormat;
|
||||
mFormat = pixelFormat;
|
||||
mDataspace = dataspace;
|
||||
|
||||
mInfo.width = width;
|
||||
mInfo.height = height;
|
||||
mInfo.layerCount = 1;
|
||||
mInfo.format = mPixelFormat;
|
||||
mInfo.usage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::GPU_TEXTURE);
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mLayerCount = 1;
|
||||
mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::GPU_TEXTURE);
|
||||
|
||||
mAccessRegion.top = 0;
|
||||
mAccessRegion.left = 0;
|
||||
@@ -322,8 +321,10 @@ class ReadbackBuffer {
|
||||
mGralloc->freeBuffer(mBufferHandle);
|
||||
mBufferHandle = nullptr;
|
||||
}
|
||||
mBufferHandle = mGralloc->allocate(mInfo, /*import*/ true, &mStride);
|
||||
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mInfo, mStride));
|
||||
mBufferHandle = mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
|
||||
/*import*/ true, &mStride);
|
||||
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mWidth, mHeight, mLayerCount,
|
||||
mFormat, mUsage, mStride));
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->setReadbackBuffer(mDisplay, mBufferHandle, -1));
|
||||
}
|
||||
|
||||
@@ -332,13 +333,13 @@ class ReadbackBuffer {
|
||||
int32_t fenceHandle;
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle));
|
||||
|
||||
void* bufData = mGralloc->lock(mBufferHandle, mInfo.usage, mAccessRegion, fenceHandle);
|
||||
ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
|
||||
int32_t bytesPerPixel = GraphicsComposerReadbackTest::GetBytesPerPixel(mPixelFormat);
|
||||
void* bufData = mGralloc->lock(mBufferHandle, mUsage, mAccessRegion, fenceHandle);
|
||||
ASSERT_TRUE(mFormat == PixelFormat::RGB_888 || mFormat == PixelFormat::RGBA_8888);
|
||||
int32_t bytesPerPixel = GraphicsComposerReadbackTest::GetBytesPerPixel(mFormat);
|
||||
ASSERT_NE(-1, bytesPerPixel);
|
||||
for (int row = 0; row < mInfo.height; row++) {
|
||||
for (int col = 0; col < mInfo.width; col++) {
|
||||
int pixel = row * mInfo.width + col;
|
||||
for (int row = 0; row < mHeight; row++) {
|
||||
for (int col = 0; col < mWidth; col++) {
|
||||
int pixel = row * mWidth + col;
|
||||
int offset = (row * mStride + col) * bytesPerPixel;
|
||||
uint8_t* pixelColor = (uint8_t*)bufData + offset;
|
||||
|
||||
@@ -354,12 +355,16 @@ class ReadbackBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
IMapper::BufferDescriptorInfo mInfo;
|
||||
IMapper::Rect mAccessRegion;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
uint32_t mLayerCount;
|
||||
PixelFormat mFormat;
|
||||
uint64_t mUsage;
|
||||
AccessRegion mAccessRegion;
|
||||
|
||||
protected:
|
||||
uint32_t mStride;
|
||||
const native_handle_t* mBufferHandle = nullptr;
|
||||
PixelFormat mPixelFormat;
|
||||
Dataspace mDataspace;
|
||||
Display mDisplay;
|
||||
std::shared_ptr<Gralloc> mGralloc;
|
||||
@@ -392,13 +397,12 @@ class TestBufferLayer : public TestLayer {
|
||||
: TestLayer{client, display} {
|
||||
mGralloc = gralloc;
|
||||
mComposition = composition;
|
||||
mInfo.width = width;
|
||||
mInfo.height = height;
|
||||
mInfo.layerCount = 1;
|
||||
mInfo.format = format;
|
||||
mInfo.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_OVERLAY);
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mLayerCount = 1;
|
||||
mFormat = format;
|
||||
mUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_OVERLAY);
|
||||
|
||||
mAccessRegion.top = 0;
|
||||
mAccessRegion.left = 0;
|
||||
@@ -423,9 +427,9 @@ class TestBufferLayer : public TestLayer {
|
||||
}
|
||||
|
||||
void fillBuffer(std::vector<IComposerClient::Color> expectedColors) {
|
||||
void* bufData = mGralloc->lock(mBufferHandle, mInfo.usage, mAccessRegion, -1);
|
||||
void* bufData = mGralloc->lock(mBufferHandle, mUsage, mAccessRegion, -1);
|
||||
ASSERT_NO_FATAL_FAILURE(GraphicsComposerReadbackTest::fillBuffer(
|
||||
mInfo.width, mInfo.height, mStride, bufData, mInfo.format, expectedColors));
|
||||
mWidth, mHeight, mStride, bufData, mFormat, expectedColors));
|
||||
mFillFence = mGralloc->unlock(mBufferHandle);
|
||||
if (mFillFence != -1) {
|
||||
sync_wait(mFillFence, -1);
|
||||
@@ -437,10 +441,12 @@ class TestBufferLayer : public TestLayer {
|
||||
mGralloc->freeBuffer(mBufferHandle);
|
||||
mBufferHandle = nullptr;
|
||||
}
|
||||
mBufferHandle = mGralloc->allocate(mInfo, /*import*/ true, &mStride);
|
||||
mBufferHandle = mGralloc->allocate(mWidth, mHeight, mLayerCount, mFormat, mUsage,
|
||||
/*import*/ true, &mStride);
|
||||
ASSERT_NE(nullptr, mBufferHandle);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(colors));
|
||||
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mInfo, mStride));
|
||||
ASSERT_NE(false, mGralloc->validateBufferSize(mBufferHandle, mWidth, mHeight, mLayerCount,
|
||||
mFormat, mUsage, mStride));
|
||||
}
|
||||
|
||||
void setToClientComposition(const std::shared_ptr<CommandWriterBase>& writer) {
|
||||
@@ -448,11 +454,15 @@ class TestBufferLayer : public TestLayer {
|
||||
writer->setLayerCompositionType(IComposerClient::Composition::CLIENT);
|
||||
}
|
||||
|
||||
IMapper::BufferDescriptorInfo mInfo;
|
||||
IMapper::Rect mAccessRegion;
|
||||
AccessRegion mAccessRegion;
|
||||
uint32_t mStride;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
uint32_t mLayerCount;
|
||||
PixelFormat mFormat;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
uint64_t mUsage;
|
||||
IComposerClient::Composition mComposition;
|
||||
std::shared_ptr<Gralloc> mGralloc;
|
||||
int32_t mFillFence;
|
||||
@@ -568,14 +578,11 @@ TEST_F(GraphicsComposerReadbackTest, SetLayerBufferNoEffect) {
|
||||
layer->write(mWriter);
|
||||
|
||||
// This following buffer call should have no effect
|
||||
IMapper::BufferDescriptorInfo bufferInfo{};
|
||||
bufferInfo.width = mDisplayWidth;
|
||||
bufferInfo.height = mDisplayHeight;
|
||||
bufferInfo.layerCount = 1;
|
||||
bufferInfo.format = PixelFormat::RGBA_8888;
|
||||
bufferInfo.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
|
||||
const native_handle_t* bufferHandle = mGralloc->allocate(bufferInfo);
|
||||
PixelFormat format = PixelFormat::RGBA_8888;
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
|
||||
const native_handle_t* bufferHandle =
|
||||
mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, format, usage);
|
||||
mWriter->setLayerBuffer(0, bufferHandle, -1);
|
||||
|
||||
// expected color for each pixel
|
||||
@@ -642,23 +649,20 @@ TEST_F(GraphicsComposerReadbackTest, ClientComposition) {
|
||||
|
||||
// create client target buffer
|
||||
uint32_t clientStride;
|
||||
IMapper::BufferDescriptorInfo clientInfo;
|
||||
clientInfo.width = layer->mInfo.width;
|
||||
clientInfo.height = layer->mInfo.height;
|
||||
clientInfo.layerCount = layer->mInfo.layerCount;
|
||||
clientInfo.format = PixelFormat::RGBA_8888;
|
||||
clientInfo.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
PixelFormat clientFormat = PixelFormat::RGBA_8888;
|
||||
uint64_t clientUsage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
const native_handle_t* clientBufferHandle =
|
||||
mGralloc->allocate(clientInfo, /*import*/ true, &clientStride);
|
||||
mGralloc->allocate(layer->mWidth, layer->mHeight, layer->mLayerCount, clientFormat,
|
||||
clientUsage, /*import*/ true, &clientStride);
|
||||
ASSERT_NE(nullptr, clientBufferHandle);
|
||||
|
||||
void* clientBufData =
|
||||
mGralloc->lock(clientBufferHandle, clientInfo.usage, layer->mAccessRegion, -1);
|
||||
mGralloc->lock(clientBufferHandle, clientUsage, layer->mAccessRegion, -1);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(clientInfo.width, clientInfo.height, clientStride,
|
||||
clientBufData, clientInfo.format, expectedColors));
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(layer->mWidth, layer->mHeight, clientStride,
|
||||
clientBufData, clientFormat, expectedColors));
|
||||
int clientFence = mGralloc->unlock(clientBufferHandle);
|
||||
if (clientFence != -1) {
|
||||
sync_wait(clientFence, -1);
|
||||
@@ -706,14 +710,13 @@ TEST_F(GraphicsComposerReadbackTest, DeviceAndClientComposition) {
|
||||
auto deviceLayer =
|
||||
std::make_shared<TestBufferLayer>(mComposerClient, mGralloc, mPrimaryDisplay, mDisplayWidth,
|
||||
mDisplayHeight / 2, PixelFormat::RGBA_8888);
|
||||
std::vector<IComposerClient::Color> deviceColors(deviceLayer->mInfo.width *
|
||||
deviceLayer->mInfo.height);
|
||||
fillColorsArea(deviceColors, deviceLayer->mInfo.width,
|
||||
{0, 0, static_cast<int32_t>(deviceLayer->mInfo.width),
|
||||
static_cast<int32_t>(deviceLayer->mInfo.height)},
|
||||
std::vector<IComposerClient::Color> deviceColors(deviceLayer->mWidth * deviceLayer->mHeight);
|
||||
fillColorsArea(deviceColors, deviceLayer->mWidth,
|
||||
{0, 0, static_cast<int32_t>(deviceLayer->mWidth),
|
||||
static_cast<int32_t>(deviceLayer->mHeight)},
|
||||
GREEN);
|
||||
deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->mInfo.width),
|
||||
static_cast<int32_t>(deviceLayer->mInfo.height)});
|
||||
deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->mWidth),
|
||||
static_cast<int32_t>(deviceLayer->mHeight)});
|
||||
deviceLayer->setZOrder(10);
|
||||
ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors));
|
||||
deviceLayer->write(mWriter);
|
||||
@@ -728,30 +731,25 @@ TEST_F(GraphicsComposerReadbackTest, DeviceAndClientComposition) {
|
||||
execute();
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
|
||||
IMapper::BufferDescriptorInfo clientInfo;
|
||||
clientInfo.width = mDisplayWidth;
|
||||
clientInfo.height = mDisplayHeight;
|
||||
clientInfo.layerCount = 1;
|
||||
clientInfo.format = PixelFormat::RGBA_8888;
|
||||
clientInfo.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
|
||||
uint64_t clientUsage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
|
||||
BufferUsage::COMPOSER_CLIENT_TARGET);
|
||||
uint32_t clientStride;
|
||||
const native_handle_t* clientBufferHandle =
|
||||
mGralloc->allocate(clientInfo, /*import*/ true, &clientStride);
|
||||
mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, PixelFormat::RGBA_8888,
|
||||
clientUsage, /*import*/ true, &clientStride);
|
||||
ASSERT_NE(nullptr, clientBufferHandle);
|
||||
|
||||
IMapper::Rect clientAccessRegion;
|
||||
AccessRegion clientAccessRegion;
|
||||
clientAccessRegion.left = 0;
|
||||
clientAccessRegion.top = 0;
|
||||
clientAccessRegion.width = mDisplayWidth;
|
||||
clientAccessRegion.height = mDisplayHeight;
|
||||
void* clientData = mGralloc->lock(clientBufferHandle, clientInfo.usage, clientAccessRegion, -1);
|
||||
std::vector<IComposerClient::Color> clientColors(clientInfo.width * clientInfo.height);
|
||||
fillColorsArea(clientColors, clientInfo.width, clientFrame, RED);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(clientInfo.width, clientInfo.height, clientStride,
|
||||
clientData, clientInfo.format, clientColors));
|
||||
void* clientData = mGralloc->lock(clientBufferHandle, clientUsage, clientAccessRegion, -1);
|
||||
std::vector<IComposerClient::Color> clientColors(mDisplayWidth * mDisplayHeight);
|
||||
fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
|
||||
ASSERT_NO_FATAL_FAILURE(fillBuffer(mDisplayWidth, mDisplayHeight, clientStride, clientData,
|
||||
PixelFormat::RGBA_8888, clientColors));
|
||||
int clientFence = mGralloc->unlock(clientBufferHandle);
|
||||
if (clientFence != -1) {
|
||||
sync_wait(clientFence, -1);
|
||||
|
||||
@@ -40,7 +40,6 @@ using common::V1_1::Dataspace;
|
||||
using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using mapper::V2_0::IMapper;
|
||||
using mapper::V2_0::vts::Gralloc;
|
||||
|
||||
// Test environment for graphics.composer
|
||||
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
@@ -171,15 +170,10 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
}
|
||||
|
||||
const native_handle_t* allocate() {
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = 64;
|
||||
info.height = 64;
|
||||
info.layerCount = 1;
|
||||
info.format = static_cast<common::V1_0::PixelFormat>(PixelFormat::RGBA_8888);
|
||||
info.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
|
||||
|
||||
return mGralloc->allocate(info);
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
|
||||
return mGralloc->allocate(/*width*/ 64, /*height*/ 64, /*layerCount*/ 1,
|
||||
PixelFormat::RGBA_8888, usage);
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
@@ -456,18 +450,15 @@ TEST_F(GraphicsComposerHidlTest, SetReadbackBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = mDisplayWidth;
|
||||
info.height = mDisplayHeight;
|
||||
info.layerCount = 1;
|
||||
info.format = static_cast<common::V1_0::PixelFormat>(mReadbackPixelFormat);
|
||||
// BufferUsage::COMPOSER_OUTPUT is missing
|
||||
info.usage = static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
|
||||
|
||||
std::unique_ptr<Gralloc> gralloc;
|
||||
const native_handle_t* buffer;
|
||||
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
|
||||
ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(info));
|
||||
ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(mDisplayWidth, mDisplayHeight, 1,
|
||||
mReadbackPixelFormat, usage));
|
||||
|
||||
mComposerClient->setReadbackBuffer(mPrimaryDisplay, buffer, -1);
|
||||
}
|
||||
@@ -483,17 +474,14 @@ TEST_F(GraphicsComposerHidlTest, SetReadbackBufferBadDisplay) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = mDisplayWidth;
|
||||
info.height = mDisplayHeight;
|
||||
info.layerCount = 1;
|
||||
info.format = static_cast<common::V1_0::PixelFormat>(mReadbackPixelFormat);
|
||||
info.usage = static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
|
||||
uint64_t usage =
|
||||
static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN);
|
||||
|
||||
std::unique_ptr<Gralloc> gralloc;
|
||||
const native_handle_t* buffer;
|
||||
ASSERT_NO_FATAL_FAILURE(gralloc = std::make_unique<Gralloc>());
|
||||
ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(info));
|
||||
ASSERT_NO_FATAL_FAILURE(buffer = gralloc->allocate(mDisplayWidth, mDisplayHeight, 1,
|
||||
mReadbackPixelFormat, usage));
|
||||
|
||||
Error error = mComposerClient->getRaw()->setReadbackBuffer(mInvalidDisplayId, buffer, nullptr);
|
||||
ASSERT_EQ(Error::BAD_DISPLAY, error);
|
||||
|
||||
@@ -27,6 +27,12 @@ cc_library_static {
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.composer@2.2-vts",
|
||||
"android.hardware.graphics.composer@2.3",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -28,6 +28,7 @@ cc_test {
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
@@ -37,6 +38,9 @@ cc_test {
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -41,7 +41,7 @@ using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using common::V1_2::PixelFormat;
|
||||
using mapper::V2_0::IMapper;
|
||||
using mapper::V2_0::vts::Gralloc;
|
||||
using V2_2::vts::Gralloc;
|
||||
|
||||
// Test environment for graphics.composer
|
||||
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
@@ -156,15 +156,9 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
}
|
||||
|
||||
const native_handle_t* allocate() {
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = 64;
|
||||
info.height = 64;
|
||||
info.layerCount = 1;
|
||||
info.format = static_cast<common::V1_0::PixelFormat>(PixelFormat::RGBA_8888);
|
||||
info.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
|
||||
|
||||
return mGralloc->allocate(info);
|
||||
return mGralloc->allocate(
|
||||
64, 64, 1, static_cast<common::V1_1::PixelFormat>(PixelFormat::RGBA_8888),
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN));
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
|
||||
@@ -43,24 +43,25 @@ static_assert(sizeof(OldBufferDescriptorInfo) == sizeof(IMapper::BufferDescripto
|
||||
offsetof(IMapper::BufferDescriptorInfo, usage),
|
||||
"");
|
||||
|
||||
Gralloc::Gralloc() : V2_0::vts::Gralloc() {
|
||||
Gralloc::Gralloc(bool errOnFailure) : V2_0::vts::Gralloc() {
|
||||
if (::testing::Test::HasFatalFailure()) {
|
||||
return;
|
||||
}
|
||||
init();
|
||||
init(errOnFailure);
|
||||
}
|
||||
|
||||
Gralloc::Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName)
|
||||
Gralloc::Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName,
|
||||
bool errOnFailure)
|
||||
: V2_0::vts::Gralloc(allocatorServiceName, mapperServiceName) {
|
||||
if (::testing::Test::HasFatalFailure()) {
|
||||
return;
|
||||
}
|
||||
init();
|
||||
init(errOnFailure);
|
||||
}
|
||||
|
||||
void Gralloc::init() {
|
||||
void Gralloc::init(bool errOnFailure) {
|
||||
mMapperV2_1 = IMapper::castFrom(V2_0::vts::Gralloc::getMapper());
|
||||
ASSERT_NE(nullptr, mMapperV2_1.get()) << "failed to get mapper 2.1 service";
|
||||
if (errOnFailure) ASSERT_NE(nullptr, mMapperV2_1.get()) << "failed to get mapper 2.1 service";
|
||||
}
|
||||
|
||||
sp<IMapper> Gralloc::getMapper() const {
|
||||
|
||||
@@ -32,25 +32,26 @@ using V2_0::BufferDescriptor;
|
||||
// A wrapper to IAllocator and IMapper.
|
||||
class Gralloc : public V2_0::vts::Gralloc {
|
||||
public:
|
||||
Gralloc();
|
||||
Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName);
|
||||
Gralloc(bool errOnFailure = true);
|
||||
Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName,
|
||||
bool errOnFailure = true);
|
||||
|
||||
sp<IMapper> getMapper() const;
|
||||
sp<IMapper> getMapper() const;
|
||||
|
||||
bool validateBufferSize(const native_handle_t* bufferHandle,
|
||||
const IMapper::BufferDescriptorInfo& descriptorInfo, uint32_t stride);
|
||||
void getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds,
|
||||
uint32_t* outNumInts);
|
||||
bool validateBufferSize(const native_handle_t* bufferHandle,
|
||||
const IMapper::BufferDescriptorInfo& descriptorInfo, uint32_t stride);
|
||||
void getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds,
|
||||
uint32_t* outNumInts);
|
||||
|
||||
BufferDescriptor createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
BufferDescriptor createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
|
||||
const native_handle_t* allocate(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
bool import = true, uint32_t* outStride = nullptr);
|
||||
const native_handle_t* allocate(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
bool import = true, uint32_t* outStride = nullptr);
|
||||
|
||||
protected:
|
||||
void init();
|
||||
void init(bool errOnFailure = true);
|
||||
|
||||
sp<IMapper> mMapperV2_1;
|
||||
sp<IMapper> mMapperV2_1;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
|
||||
@@ -25,8 +25,13 @@ namespace mapper {
|
||||
namespace V3_0 {
|
||||
namespace vts {
|
||||
|
||||
Gralloc::Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName) {
|
||||
init(allocatorServiceName, mapperServiceName);
|
||||
Gralloc::Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName,
|
||||
bool errOnFailure) {
|
||||
if (errOnFailure) {
|
||||
init(allocatorServiceName, mapperServiceName);
|
||||
} else {
|
||||
initNoErr(allocatorServiceName, mapperServiceName);
|
||||
}
|
||||
}
|
||||
|
||||
void Gralloc::init(const std::string& allocatorServiceName, const std::string& mapperServiceName) {
|
||||
@@ -38,6 +43,16 @@ void Gralloc::init(const std::string& allocatorServiceName, const std::string& m
|
||||
ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
|
||||
}
|
||||
|
||||
void Gralloc::initNoErr(const std::string& allocatorServiceName,
|
||||
const std::string& mapperServiceName) {
|
||||
mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>(allocatorServiceName);
|
||||
|
||||
mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>(mapperServiceName);
|
||||
if (mMapper.get()) {
|
||||
ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
|
||||
}
|
||||
}
|
||||
|
||||
Gralloc::~Gralloc() {
|
||||
for (auto bufferHandle : mClonedBuffers) {
|
||||
auto buffer = const_cast<native_handle_t*>(bufferHandle);
|
||||
|
||||
@@ -36,62 +36,66 @@ using android::hardware::graphics::allocator::V3_0::IAllocator;
|
||||
// A wrapper to IAllocator and IMapper.
|
||||
class Gralloc {
|
||||
public:
|
||||
Gralloc(const std::string& allocatorServiceName = "default",
|
||||
const std::string& mapperServiceName = "default");
|
||||
~Gralloc();
|
||||
Gralloc(const std::string& allocatorServiceName = "default",
|
||||
const std::string& mapperServiceName = "default", bool errOnFailure = true);
|
||||
~Gralloc();
|
||||
|
||||
// IAllocator methods
|
||||
// IAllocator methods
|
||||
|
||||
sp<IAllocator> getAllocator() const;
|
||||
sp<IAllocator> getAllocator() const;
|
||||
|
||||
std::string dumpDebugInfo();
|
||||
std::string dumpDebugInfo();
|
||||
|
||||
// When import is false, this simply calls IAllocator::allocate. When import
|
||||
// is true, the returned buffers are also imported into the mapper.
|
||||
//
|
||||
// Either case, the returned buffers must be freed with freeBuffer.
|
||||
std::vector<const native_handle_t*> allocate(const BufferDescriptor& descriptor, uint32_t count,
|
||||
bool import = true, uint32_t* outStride = nullptr);
|
||||
const native_handle_t* allocate(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
bool import = true, uint32_t* outStride = nullptr);
|
||||
// When import is false, this simply calls IAllocator::allocate. When import
|
||||
// is true, the returned buffers are also imported into the mapper.
|
||||
//
|
||||
// Either case, the returned buffers must be freed with freeBuffer.
|
||||
std::vector<const native_handle_t*> allocate(const BufferDescriptor& descriptor,
|
||||
uint32_t count, bool import = true,
|
||||
uint32_t* outStride = nullptr);
|
||||
const native_handle_t* allocate(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
bool import = true, uint32_t* outStride = nullptr);
|
||||
|
||||
// IMapper methods
|
||||
// IMapper methods
|
||||
|
||||
sp<IMapper> getMapper() const;
|
||||
sp<IMapper> getMapper() const;
|
||||
|
||||
BufferDescriptor createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
BufferDescriptor createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
|
||||
const native_handle_t* importBuffer(const hidl_handle& rawHandle);
|
||||
void freeBuffer(const native_handle_t* bufferHandle);
|
||||
const native_handle_t* importBuffer(const hidl_handle& rawHandle);
|
||||
void freeBuffer(const native_handle_t* bufferHandle);
|
||||
|
||||
// We use fd instead of hidl_handle in these functions to pass fences
|
||||
// in and out of the mapper. The ownership of the fd is always transferred
|
||||
// with each of these functions.
|
||||
void* lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const IMapper::Rect& accessRegion, int acquireFence, int32_t* outBytesPerPixel,
|
||||
int32_t* outBytesPerStride);
|
||||
YCbCrLayout lockYCbCr(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const IMapper::Rect& accessRegion, int acquireFence);
|
||||
int unlock(const native_handle_t* bufferHandle);
|
||||
// We use fd instead of hidl_handle in these functions to pass fences
|
||||
// in and out of the mapper. The ownership of the fd is always transferred
|
||||
// with each of these functions.
|
||||
void* lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const IMapper::Rect& accessRegion, int acquireFence, int32_t* outBytesPerPixel,
|
||||
int32_t* outBytesPerStride);
|
||||
YCbCrLayout lockYCbCr(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const IMapper::Rect& accessRegion, int acquireFence);
|
||||
int unlock(const native_handle_t* bufferHandle);
|
||||
|
||||
bool validateBufferSize(const native_handle_t* bufferHandle,
|
||||
const IMapper::BufferDescriptorInfo& descriptorInfo, uint32_t stride);
|
||||
void getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds,
|
||||
uint32_t* outNumInts);
|
||||
bool validateBufferSize(const native_handle_t* bufferHandle,
|
||||
const IMapper::BufferDescriptorInfo& descriptorInfo, uint32_t stride);
|
||||
void getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds,
|
||||
uint32_t* outNumInts);
|
||||
|
||||
bool isSupported(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
bool isSupported(const IMapper::BufferDescriptorInfo& descriptorInfo);
|
||||
|
||||
private:
|
||||
void init(const std::string& allocatorServiceName, const std::string& mapperServiceName);
|
||||
const native_handle_t* cloneBuffer(const hidl_handle& rawHandle);
|
||||
void init(const std::string& allocatorServiceName, const std::string& mapperServiceName);
|
||||
|
||||
sp<IAllocator> mAllocator;
|
||||
sp<IMapper> mMapper;
|
||||
// initialize without checking for failure to get service
|
||||
void initNoErr(const std::string& allocatorServiceName, const std::string& mapperServiceName);
|
||||
const native_handle_t* cloneBuffer(const hidl_handle& rawHandle);
|
||||
|
||||
// Keep track of all cloned and imported handles. When a test fails with
|
||||
// ASSERT_*, the destructor will free the handles for the test.
|
||||
std::unordered_set<const native_handle_t*> mClonedBuffers;
|
||||
std::unordered_set<const native_handle_t*> mImportedBuffers;
|
||||
sp<IAllocator> mAllocator;
|
||||
sp<IMapper> mMapper;
|
||||
|
||||
// Keep track of all cloned and imported handles. When a test fails with
|
||||
// ASSERT_*, the destructor will free the handles for the test.
|
||||
std::unordered_set<const native_handle_t*> mClonedBuffers;
|
||||
std::unordered_set<const native_handle_t*> mImportedBuffers;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
|
||||
Reference in New Issue
Block a user