Loading libs/ui/Gralloc2.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,12 @@ int Gralloc2Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc2Mapper::isSupported(uint32_t /*width*/, uint32_t /*height*/, android::PixelFormat /*format*/, uint32_t /*layerCount*/, uint64_t /*usage*/, bool* /*outSupported*/) const { return INVALID_OPERATION; } Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading libs/ui/Gralloc3.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,36 @@ int Gralloc3Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc3Mapper::isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) const { IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Error error; auto ret = mMapper->isSupported(descriptorInfo, [&](const auto& tmpError, const auto& tmpSupported) { error = tmpError; if (error != Error::NONE) { return; } if (outSupported) { *outSupported = tmpSupported; } }); if (!ret.isOk()) { error = kTransactionError; } if (error != Error::NONE) { ALOGE("isSupported(%u, %u, %d, %u, ...) failed with %d", width, height, format, layerCount, error); } return static_cast<status_t>(error); } Gralloc3Allocator::Gralloc3Allocator(const Gralloc3Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading libs/ui/GraphicBuffer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,13 @@ status_t GraphicBuffer::unlockAsync(int *fenceFd) return res; } status_t GraphicBuffer::isSupported(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inLayerCount, uint64_t inUsage, bool* outSupported) const { return mBufferMapper.isSupported(inWidth, inHeight, inFormat, inLayerCount, inUsage, outSupported); } size_t GraphicBuffer::getFlattenedSize() const { return static_cast<size_t>(13 + (handle ? mTransportNumInts : 0)) * sizeof(int); } Loading libs/ui/GraphicBufferMapper.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -161,5 +161,10 @@ status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd) return NO_ERROR; } status_t GraphicBufferMapper::isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) { return mMapper->isSupported(width, height, format, layerCount, usage, outSupported); } // --------------------------------------------------------------------------- }; // namespace android libs/ui/include/ui/Gralloc.h +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,15 @@ public: // unlock returns a fence sync object (or -1) and the fence sync object is // owned by the caller virtual int unlock(buffer_handle_t bufferHandle) const = 0; // isSupported queries whether or not a buffer with the given width, height, // format, layer count, and usage can be allocated on the device. If // *outSupported is set to true, a buffer with the given specifications may be successfully // allocated if resources are available. If false, a buffer with the given specifications will // never successfully allocate on this device. Note that this function is not guaranteed to be // supported on all devices, in which case a status_t of INVALID_OPERATION will be returned. virtual status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) const = 0; }; // A wrapper to IAllocator Loading Loading
libs/ui/Gralloc2.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,12 @@ int Gralloc2Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc2Mapper::isSupported(uint32_t /*width*/, uint32_t /*height*/, android::PixelFormat /*format*/, uint32_t /*layerCount*/, uint64_t /*usage*/, bool* /*outSupported*/) const { return INVALID_OPERATION; } Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading
libs/ui/Gralloc3.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,36 @@ int Gralloc3Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc3Mapper::isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) const { IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Error error; auto ret = mMapper->isSupported(descriptorInfo, [&](const auto& tmpError, const auto& tmpSupported) { error = tmpError; if (error != Error::NONE) { return; } if (outSupported) { *outSupported = tmpSupported; } }); if (!ret.isOk()) { error = kTransactionError; } if (error != Error::NONE) { ALOGE("isSupported(%u, %u, %d, %u, ...) failed with %d", width, height, format, layerCount, error); } return static_cast<status_t>(error); } Gralloc3Allocator::Gralloc3Allocator(const Gralloc3Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading
libs/ui/GraphicBuffer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,13 @@ status_t GraphicBuffer::unlockAsync(int *fenceFd) return res; } status_t GraphicBuffer::isSupported(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inLayerCount, uint64_t inUsage, bool* outSupported) const { return mBufferMapper.isSupported(inWidth, inHeight, inFormat, inLayerCount, inUsage, outSupported); } size_t GraphicBuffer::getFlattenedSize() const { return static_cast<size_t>(13 + (handle ? mTransportNumInts : 0)) * sizeof(int); } Loading
libs/ui/GraphicBufferMapper.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -161,5 +161,10 @@ status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd) return NO_ERROR; } status_t GraphicBufferMapper::isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) { return mMapper->isSupported(width, height, format, layerCount, usage, outSupported); } // --------------------------------------------------------------------------- }; // namespace android
libs/ui/include/ui/Gralloc.h +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,15 @@ public: // unlock returns a fence sync object (or -1) and the fence sync object is // owned by the caller virtual int unlock(buffer_handle_t bufferHandle) const = 0; // isSupported queries whether or not a buffer with the given width, height, // format, layer count, and usage can be allocated on the device. If // *outSupported is set to true, a buffer with the given specifications may be successfully // allocated if resources are available. If false, a buffer with the given specifications will // never successfully allocate on this device. Note that this function is not guaranteed to be // supported on all devices, in which case a status_t of INVALID_OPERATION will be returned. virtual status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, bool* outSupported) const = 0; }; // A wrapper to IAllocator Loading