diff options
| author | 2020-09-10 17:22:18 +0000 | |
|---|---|---|
| committer | 2020-09-10 17:22:18 +0000 | |
| commit | cdb6b16dec3a541b455be99d075004cb2f0a0cd7 (patch) | |
| tree | f7110d50445c67a337105034b1f2db3946a88fef /libs/ui/Gralloc2.cpp | |
| parent | 171cac1b603e4bb83412eb596d05a500af5d7a76 (diff) | |
| parent | ac07d0f5ab16bb9e8bbbabb589d1c7d36817baa9 (diff) | |
Merge "Merge Android R"
Diffstat (limited to 'libs/ui/Gralloc2.cpp')
| -rw-r--r-- | libs/ui/Gralloc2.cpp | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp index 5dc453005d..040a62b542 100644 --- a/libs/ui/Gralloc2.cpp +++ b/libs/ui/Gralloc2.cpp @@ -351,12 +351,6 @@ 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) { @@ -369,7 +363,7 @@ bool Gralloc2Allocator::isLoaded() const { return mAllocator != nullptr; } -std::string Gralloc2Allocator::dumpDebugInfo() const { +std::string Gralloc2Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { @@ -379,9 +373,10 @@ std::string Gralloc2Allocator::dumpDebugInfo() const { return debugInfo; } -status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, - uint32_t layerCount, uint64_t usage, uint32_t bufferCount, - uint32_t* outStride, buffer_handle_t* outBufferHandles) const { +status_t Gralloc2Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, + PixelFormat format, uint32_t layerCount, uint64_t usage, + uint32_t bufferCount, uint32_t* outStride, + buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo = {}; descriptorInfo.width = width; descriptorInfo.height = height; @@ -404,19 +399,33 @@ status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelForma return; } - // import buffers - for (uint32_t i = 0; i < bufferCount; i++) { - error = mMapper.importBuffer(tmpBuffers[i], - &outBufferHandles[i]); - if (error != NO_ERROR) { - for (uint32_t j = 0; j < i; j++) { - mMapper.freeBuffer(outBufferHandles[j]); - outBufferHandles[j] = nullptr; + if (importBuffers) { + for (uint32_t i = 0; i < bufferCount; i++) { + error = mMapper.importBuffer(tmpBuffers[i], + &outBufferHandles[i]); + if (error != NO_ERROR) { + for (uint32_t j = 0; j < i; j++) { + mMapper.freeBuffer(outBufferHandles[j]); + outBufferHandles[j] = nullptr; + } + return; + } + } + } else { + for (uint32_t i = 0; i < bufferCount; i++) { + outBufferHandles[i] = native_handle_clone( + tmpBuffers[i].getNativeHandle()); + if (!outBufferHandles[i]) { + for (uint32_t j = 0; j < i; j++) { + auto buffer = const_cast<native_handle_t*>( + outBufferHandles[j]); + native_handle_close(buffer); + native_handle_delete(buffer); + outBufferHandles[j] = nullptr; + } } - return; } } - *outStride = tmpStride; }); |