diff options
author | 2019-02-01 09:54:20 -0800 | |
---|---|---|
committer | 2019-02-04 16:47:19 -0800 | |
commit | ddbfaeb7a6b67e93f7a2519c7725561de644d671 (patch) | |
tree | 0161fdf35ad94bd2f4ee25fb25b48eee6067c4d9 | |
parent | 3b7f2022cd288f9bfcb2ba8f775eef6caca92dad (diff) |
Adding isSupported HIDL Mapper function support to framework
Bug: 123423521
Test: build, boot, manual testing
Change-Id: Iee52de6f5610a8465b1f4435d02dc61a8064064a
-rw-r--r-- | libs/ui/Gralloc2.cpp | 6 | ||||
-rw-r--r-- | libs/ui/Gralloc3.cpp | 30 | ||||
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 7 | ||||
-rw-r--r-- | libs/ui/GraphicBufferMapper.cpp | 5 | ||||
-rw-r--r-- | libs/ui/include/ui/Gralloc.h | 9 | ||||
-rw-r--r-- | libs/ui/include/ui/Gralloc2.h | 3 | ||||
-rw-r--r-- | libs/ui/include/ui/Gralloc3.h | 3 | ||||
-rw-r--r-- | libs/ui/include/ui/GraphicBuffer.h | 3 | ||||
-rw-r--r-- | libs/ui/include/ui/GraphicBufferMapper.h | 3 |
9 files changed, 69 insertions, 0 deletions
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp index 92ea07cbc4..5dc453005d 100644 --- a/libs/ui/Gralloc2.cpp +++ b/libs/ui/Gralloc2.cpp @@ -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) { diff --git a/libs/ui/Gralloc3.cpp b/libs/ui/Gralloc3.cpp index 306a74b80c..7f8e57c9cb 100644 --- a/libs/ui/Gralloc3.cpp +++ b/libs/ui/Gralloc3.cpp @@ -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) { diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 15597eb666..e678c58cfa 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -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); } diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index 79c333fce4..06981c39a5 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -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 diff --git a/libs/ui/include/ui/Gralloc.h b/libs/ui/include/ui/Gralloc.h index 1b8a930c4c..6cc23f0ef8 100644 --- a/libs/ui/include/ui/Gralloc.h +++ b/libs/ui/include/ui/Gralloc.h @@ -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 diff --git a/libs/ui/include/ui/Gralloc2.h b/libs/ui/include/ui/Gralloc2.h index 4ef9b51e4f..948f5976eb 100644 --- a/libs/ui/include/ui/Gralloc2.h +++ b/libs/ui/include/ui/Gralloc2.h @@ -61,6 +61,9 @@ public: int unlock(buffer_handle_t bufferHandle) const override; + status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format, + uint32_t layerCount, uint64_t usage, bool* outSupported) const override; + private: // Determines whether the passed info is compatible with the mapper. status_t validateBufferDescriptorInfo( diff --git a/libs/ui/include/ui/Gralloc3.h b/libs/ui/include/ui/Gralloc3.h index 879e96ed40..0965f52772 100644 --- a/libs/ui/include/ui/Gralloc3.h +++ b/libs/ui/include/ui/Gralloc3.h @@ -60,6 +60,9 @@ public: int unlock(buffer_handle_t bufferHandle) const override; + status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format, + uint32_t layerCount, uint64_t usage, bool* outSupported) const override; + private: // Determines whether the passed info is compatible with the mapper. status_t validateBufferDescriptorInfo( diff --git a/libs/ui/include/ui/GraphicBuffer.h b/libs/ui/include/ui/GraphicBuffer.h index 18a27a01dd..7d88c58937 100644 --- a/libs/ui/include/ui/GraphicBuffer.h +++ b/libs/ui/include/ui/GraphicBuffer.h @@ -191,6 +191,9 @@ public: android_ycbcr *ycbcr, int fenceFd); status_t unlockAsync(int *fenceFd); + status_t isSupported(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inLayerCount, uint64_t inUsage, bool* outSupported) const; + ANativeWindowBuffer* getNativeBuffer() const; // for debugging diff --git a/libs/ui/include/ui/GraphicBufferMapper.h b/libs/ui/include/ui/GraphicBufferMapper.h index 072926ff44..77c99ccd07 100644 --- a/libs/ui/include/ui/GraphicBufferMapper.h +++ b/libs/ui/include/ui/GraphicBufferMapper.h @@ -78,6 +78,9 @@ public: status_t unlockAsync(buffer_handle_t handle, int *fenceFd); + status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format, + uint32_t layerCount, uint64_t usage, bool* outSupported); + const GrallocMapper& getGrallocMapper() const { return reinterpret_cast<const GrallocMapper&>(*mMapper); } |