Loading libs/ui/Gralloc2.cpp +26 −23 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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"); } Loading @@ -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( Loading @@ -102,22 +101,12 @@ 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) auto hidl_cb = [&](const auto& tmpError, const auto& tmpDescriptor) { error = tmpError; if (error != Error::NONE) { Loading @@ -125,7 +114,21 @@ Error Mapper::createDescriptor( } *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; } Loading libs/ui/include/ui/Gralloc2.h +4 −4 Original line number Diff line number Diff line Loading @@ -30,11 +30,11 @@ namespace android { namespace Gralloc2 { using hardware::graphics::allocator::V2_0::IAllocator; using hardware::graphics::common::V1_0::PixelFormat; using hardware::graphics::common::V1_1::BufferUsage; using hardware::graphics::common::V1_1::PixelFormat; using hardware::graphics::mapper::V2_1::IMapper; using hardware::graphics::mapper::V2_0::BufferDescriptor; using hardware::graphics::mapper::V2_0::Error; using hardware::graphics::mapper::V2_0::IMapper; using hardware::graphics::mapper::V2_0::YCbCrLayout; // A wrapper to IMapper Loading Loading @@ -85,8 +85,8 @@ private: Error validateBufferDescriptorInfo( const IMapper::BufferDescriptorInfo& descriptorInfo) const; sp<IMapper> mMapper; sp<hardware::graphics::mapper::V2_1::IMapper> mMapperV2_1; sp<hardware::graphics::mapper::V2_0::IMapper> mMapper; sp<IMapper> mMapperV2_1; }; // A wrapper to IAllocator Loading Loading
libs/ui/Gralloc2.cpp +26 −23 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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"); } Loading @@ -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( Loading @@ -102,22 +101,12 @@ 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) auto hidl_cb = [&](const auto& tmpError, const auto& tmpDescriptor) { error = tmpError; if (error != Error::NONE) { Loading @@ -125,7 +114,21 @@ Error Mapper::createDescriptor( } *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; } Loading
libs/ui/include/ui/Gralloc2.h +4 −4 Original line number Diff line number Diff line Loading @@ -30,11 +30,11 @@ namespace android { namespace Gralloc2 { using hardware::graphics::allocator::V2_0::IAllocator; using hardware::graphics::common::V1_0::PixelFormat; using hardware::graphics::common::V1_1::BufferUsage; using hardware::graphics::common::V1_1::PixelFormat; using hardware::graphics::mapper::V2_1::IMapper; using hardware::graphics::mapper::V2_0::BufferDescriptor; using hardware::graphics::mapper::V2_0::Error; using hardware::graphics::mapper::V2_0::IMapper; using hardware::graphics::mapper::V2_0::YCbCrLayout; // A wrapper to IMapper Loading Loading @@ -85,8 +85,8 @@ private: Error validateBufferDescriptorInfo( const IMapper::BufferDescriptorInfo& descriptorInfo) const; sp<IMapper> mMapper; sp<hardware::graphics::mapper::V2_1::IMapper> mMapperV2_1; sp<hardware::graphics::mapper::V2_0::IMapper> mMapper; sp<IMapper> mMapperV2_1; }; // A wrapper to IAllocator Loading