diff options
author | 2018-01-16 21:58:18 -0800 | |
---|---|---|
committer | 2018-01-23 22:08:25 -0800 | |
commit | 4f55f16638c161834d39e1581d069780f8918c2f (patch) | |
tree | 33002c0591a5aea899d02ab1a7a9cb96dfda6fd9 /libs/ui/Gralloc2.cpp | |
parent | c6d738a320a612454e6c7588affcfb1f8886dd8c (diff) |
libui: use IMapper::createDescriptor_2_1
Update using's in Gralloc2.h to be based on common@1.1 and
mapper@2.1. Use IMapper::createDescriptor_2_1 when it is available.
Test: manual
Change-Id: Id4f805a93a5e9a6cde9ecece7dd4954dec337060
Diffstat (limited to 'libs/ui/Gralloc2.cpp')
-rw-r--r-- | libs/ui/Gralloc2.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp index 60ec38c459..153d35a0b6 100644 --- a/libs/ui/Gralloc2.cpp +++ b/libs/ui/Gralloc2.cpp @@ -57,8 +57,7 @@ uint64_t getValid11UsageBits() { for (const auto bit : hardware::hidl_enum_iterator<BufferUsage>()) { bits = bits | bit; } - // Return only the overlapping bits. - return bits & ~getValid10UsageBits(); + return bits; }(); return valid11UsageBits; } @@ -71,7 +70,7 @@ void Mapper::preload() { Mapper::Mapper() { - mMapper = IMapper::getService(); + mMapper = hardware::graphics::mapper::V2_0::IMapper::getService(); if (mMapper == nullptr) { LOG_ALWAYS_FATAL("gralloc-mapper is missing"); } @@ -80,7 +79,7 @@ Mapper::Mapper() } // IMapper 2.1 is optional - mMapperV2_1 = hardware::graphics::mapper::V2_1::IMapper::castFrom(mMapper); + mMapperV2_1 = IMapper::castFrom(mMapper); } Gralloc2::Error Mapper::validateBufferDescriptorInfo( @@ -102,30 +101,34 @@ Error Mapper::createDescriptor( const IMapper::BufferDescriptorInfo& descriptorInfo, BufferDescriptor* outDescriptor) const { - Error error; - - if (descriptorInfo.usage & getValid11UsageBits()) { - // TODO(b/66900669): Use mMapperV2_1->createDescriptorV2_1(). - ALOGW("full support for new usage bits is unimplemented 0x%" PRIx64, - descriptorInfo.usage & getValid11UsageBits()); - return Error::BAD_VALUE; - } - - error = validateBufferDescriptorInfo(descriptorInfo); + Error error = validateBufferDescriptorInfo(descriptorInfo); if (error != Error::NONE) { return error; } - auto ret = mMapper->createDescriptor(descriptorInfo, - [&](const auto& tmpError, const auto& tmpDescriptor) - { - error = tmpError; - if (error != Error::NONE) { - return; - } + auto hidl_cb = [&](const auto& tmpError, const auto& tmpDescriptor) + { + error = tmpError; + if (error != Error::NONE) { + return; + } - *outDescriptor = tmpDescriptor; - }); + *outDescriptor = tmpDescriptor; + }; + + hardware::Return<void> ret; + if (mMapperV2_1 != nullptr) { + ret = mMapperV2_1->createDescriptor_2_1(descriptorInfo, hidl_cb); + } else { + const hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo info = { + descriptorInfo.width, + descriptorInfo.height, + descriptorInfo.layerCount, + static_cast<hardware::graphics::common::V1_0::PixelFormat>(descriptorInfo.format), + descriptorInfo.usage, + }; + ret = mMapper->createDescriptor(info, hidl_cb); + } return (ret.isOk()) ? error : kTransactionError; } |