gralloc: add allocator and mapper 3.0 support to SF
Add support for IAllocator and IMapper 3.0 support
to SurfaceFlinger.
Bug: 120493579
Test: manual
Change-Id: I8b7311cfa6b58502b334460d65eb66715ef429e8
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
index c2f0732..ea7321e 100644
--- a/libs/ui/Gralloc2.cpp
+++ b/libs/ui/Gralloc2.cpp
@@ -27,11 +27,13 @@
#include <sync/sync.h>
#pragma clang diagnostic pop
+using android::hardware::graphics::allocator::V2_0::IAllocator;
using android::hardware::graphics::common::V1_1::BufferUsage;
using android::hardware::graphics::common::V1_1::PixelFormat;
using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
using android::hardware::graphics::mapper::V2_0::Error;
using android::hardware::graphics::mapper::V2_0::YCbCrLayout;
+using android::hardware::graphics::mapper::V2_1::IMapper;
namespace android {
@@ -81,7 +83,8 @@
Gralloc2Mapper::Gralloc2Mapper() {
mMapper = hardware::graphics::mapper::V2_0::IMapper::getService();
if (mMapper == nullptr) {
- LOG_ALWAYS_FATAL("gralloc-mapper is missing");
+ ALOGW("mapper 2.x is not supported");
+ return;
}
if (mMapper->isRemote()) {
LOG_ALWAYS_FATAL("gralloc-mapper must be in passthrough mode");
@@ -91,6 +94,10 @@
mMapperV2_1 = IMapper::castFrom(mMapper);
}
+bool Gralloc2Mapper::isSupported() const {
+ return mMapper != nullptr;
+}
+
status_t Gralloc2Mapper::validateBufferDescriptorInfo(
IMapper::BufferDescriptorInfo* descriptorInfo) const {
uint64_t validUsageBits = getValid10UsageBits();
@@ -340,10 +347,15 @@
Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) {
mAllocator = IAllocator::getService();
if (mAllocator == nullptr) {
- LOG_ALWAYS_FATAL("gralloc-alloc is missing");
+ ALOGW("allocator 2.x is not supported");
+ return;
}
}
+bool Gralloc2Allocator::isSupported() const {
+ return mAllocator != nullptr;
+}
+
std::string Gralloc2Allocator::dumpDebugInfo() const {
std::string debugInfo;