mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
composer-vts: support gralloc 4
Add support for gralloc 4.0 to composer-vts. Bug: 136016160 Test: Compiles and boots Change-Id: Ibfa802023ddeb3b4d09a7b69bbc796b67c4ee62d
This commit is contained in:
@@ -27,12 +27,14 @@ cc_library_static {
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
export_static_lib_headers: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -317,11 +317,16 @@ void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* write
|
||||
|
||||
Gralloc::Gralloc() {
|
||||
[this] {
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc4 = std::make_shared<Gralloc4>("default", "default",
|
||||
/*errOnFailure=*/false));
|
||||
if (mGralloc3->getAllocator() == nullptr || mGralloc3->getMapper() == nullptr) {
|
||||
mGralloc3 = nullptr;
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
|
||||
if (mGralloc4->getAllocator() == nullptr || mGralloc4->getMapper() == nullptr) {
|
||||
mGralloc4 = nullptr;
|
||||
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>());
|
||||
}
|
||||
}
|
||||
}();
|
||||
}
|
||||
@@ -329,7 +334,15 @@ Gralloc::Gralloc() {
|
||||
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) {
|
||||
if (mGralloc4) {
|
||||
IMapper4::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
|
||||
info.usage = usage;
|
||||
return mGralloc4->allocate(info, import, outStride);
|
||||
} else if (mGralloc3) {
|
||||
IMapper3::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
@@ -350,7 +363,17 @@ const native_handle_t* Gralloc::allocate(uint32_t width, uint32_t height, uint32
|
||||
|
||||
void* Gralloc::lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
const AccessRegion& accessRegionRect, int acquireFence) {
|
||||
if (mGralloc3) {
|
||||
if (mGralloc4) {
|
||||
IMapper4::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 mGralloc4->lock(bufferHandle, cpuUsage, accessRegion, acquireFence, &bytesPerPixel,
|
||||
&bytesPerStride);
|
||||
} else if (mGralloc3) {
|
||||
IMapper3::Rect accessRegion;
|
||||
accessRegion.left = accessRegionRect.left;
|
||||
accessRegion.top = accessRegionRect.top;
|
||||
@@ -371,7 +394,9 @@ void* Gralloc::lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
|
||||
}
|
||||
|
||||
int Gralloc::unlock(const native_handle_t* bufferHandle) {
|
||||
if (mGralloc3) {
|
||||
if (mGralloc4) {
|
||||
return mGralloc4->unlock(bufferHandle);
|
||||
} else if (mGralloc3) {
|
||||
return mGralloc3->unlock(bufferHandle);
|
||||
} else {
|
||||
return mGralloc2->unlock(bufferHandle);
|
||||
@@ -379,7 +404,9 @@ int Gralloc::unlock(const native_handle_t* bufferHandle) {
|
||||
}
|
||||
|
||||
void Gralloc::freeBuffer(const native_handle_t* bufferHandle) {
|
||||
if (mGralloc3) {
|
||||
if (mGralloc4) {
|
||||
mGralloc4->freeBuffer(bufferHandle);
|
||||
} else if (mGralloc3) {
|
||||
mGralloc3->freeBuffer(bufferHandle);
|
||||
} else {
|
||||
mGralloc2->freeBuffer(bufferHandle);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
#include <mapper-vts/3.0/MapperVts.h>
|
||||
#include <mapper-vts/4.0/MapperVts.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -44,8 +45,10 @@ 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 IMapper4 = android::hardware::graphics::mapper::V4_0::IMapper;
|
||||
using Gralloc2 = android::hardware::graphics::mapper::V2_0::vts::Gralloc;
|
||||
using Gralloc3 = android::hardware::graphics::mapper::V3_0::vts::Gralloc;
|
||||
using Gralloc4 = android::hardware::graphics::mapper::V4_0::vts::Gralloc;
|
||||
|
||||
class ComposerClient;
|
||||
|
||||
@@ -153,6 +156,7 @@ class Gralloc {
|
||||
protected:
|
||||
std::shared_ptr<Gralloc2> mGralloc2 = nullptr;
|
||||
std::shared_ptr<Gralloc3> mGralloc3 = nullptr;
|
||||
std::shared_ptr<Gralloc4> mGralloc4 = nullptr;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
|
||||
@@ -27,12 +27,17 @@ cc_test {
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.allocator@4.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@2.1",
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
#include <mapper-vts/3.0/MapperVts.h>
|
||||
#include <mapper-vts/4.0/MapperVts.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
@@ -34,6 +34,10 @@ cc_library_static {
|
||||
"libmath",
|
||||
"libnativewindow",
|
||||
"librenderengine",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
export_static_lib_headers: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
|
||||
@@ -182,17 +182,23 @@ std::array<float, 16> ComposerClient::getDataspaceSaturationMatrix(Dataspace dat
|
||||
|
||||
Gralloc::Gralloc() {
|
||||
[this] {
|
||||
ALOGD("Attempting to initialize gralloc3");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
|
||||
ALOGD("Attempting to initialize gralloc4");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc4 = std::make_shared<Gralloc4>("default", "default",
|
||||
/*errOnFailure=*/false));
|
||||
if (mGralloc3->getMapper() == nullptr || mGralloc3->getAllocator() == nullptr) {
|
||||
mGralloc3 = nullptr;
|
||||
ALOGD("Failed to initialize gralloc3, initializing gralloc2_1");
|
||||
mGralloc2_1 = std::make_shared<Gralloc2_1>(/*errOnFailure*/ false);
|
||||
if (!mGralloc2_1->getMapper()) {
|
||||
mGralloc2_1 = nullptr;
|
||||
ALOGD("Failed to initialize gralloc2_1, initializing gralloc2");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
|
||||
if (mGralloc4->getMapper() == nullptr || mGralloc4->getAllocator() == nullptr) {
|
||||
mGralloc4 = nullptr;
|
||||
ALOGD("Failed to initialize gralloc4, initializing gralloc3");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc3 = std::make_shared<Gralloc3>("default", "default",
|
||||
/*errOnFailure=*/false));
|
||||
if (mGralloc3->getMapper() == nullptr || mGralloc3->getAllocator() == nullptr) {
|
||||
mGralloc3 = nullptr;
|
||||
ALOGD("Failed to initialize gralloc3, initializing gralloc2_1");
|
||||
mGralloc2_1 = std::make_shared<Gralloc2_1>(/*errOnFailure*/ false);
|
||||
if (!mGralloc2_1->getMapper()) {
|
||||
mGralloc2_1 = nullptr;
|
||||
ALOGD("Failed to initialize gralloc2_1, initializing gralloc2");
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc2 = std::make_shared<Gralloc2>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}();
|
||||
@@ -201,7 +207,15 @@ Gralloc::Gralloc() {
|
||||
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) {
|
||||
if (mGralloc4) {
|
||||
IMapper4::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.layerCount = layerCount;
|
||||
info.format = static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format);
|
||||
info.usage = usage;
|
||||
return mGralloc4->validateBufferSize(bufferHandle, info, stride);
|
||||
} else if (mGralloc3) {
|
||||
IMapper3::BufferDescriptorInfo info{};
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
|
||||
@@ -44,9 +44,11 @@ using common::V1_1::PixelFormat;
|
||||
using common::V1_1::RenderIntent;
|
||||
using IMapper2_1 = android::hardware::graphics::mapper::V2_1::IMapper;
|
||||
using IMapper3 = android::hardware::graphics::mapper::V3_0::IMapper;
|
||||
using IMapper4 = android::hardware::graphics::mapper::V4_0::IMapper;
|
||||
using Gralloc2 = android::hardware::graphics::mapper::V2_0::vts::Gralloc;
|
||||
using Gralloc2_1 = android::hardware::graphics::mapper::V2_1::vts::Gralloc;
|
||||
using Gralloc3 = android::hardware::graphics::mapper::V3_0::vts::Gralloc;
|
||||
using Gralloc4 = android::hardware::graphics::mapper::V4_0::vts::Gralloc;
|
||||
|
||||
class ComposerClient;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ cc_test {
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.allocator@4.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
@@ -50,6 +51,8 @@ cc_test {
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
"librenderengine"
|
||||
],
|
||||
header_libs: [
|
||||
|
||||
@@ -29,6 +29,7 @@ cc_test {
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.allocator@4.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
@@ -41,6 +42,8 @@ cc_test {
|
||||
"android.hardware.graphics.mapper@2.1-vts",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@3.0-vts",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
@@ -27,6 +27,8 @@ cc_test {
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.allocator@3.0",
|
||||
"android.hardware.graphics.allocator@4.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
@@ -38,6 +40,11 @@ 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",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
"android.hardware.graphics.mapper@4.0-vts",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
|
||||
Reference in New Issue
Block a user