diff options
Diffstat (limited to 'libs/ui/Gralloc3.cpp')
| -rw-r--r-- | libs/ui/Gralloc3.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/libs/ui/Gralloc3.cpp b/libs/ui/Gralloc3.cpp index eb43765733..882674f479 100644 --- a/libs/ui/Gralloc3.cpp +++ b/libs/ui/Gralloc3.cpp @@ -352,7 +352,7 @@ bool Gralloc3Allocator::isLoaded() const { return mAllocator != nullptr; } -std::string Gralloc3Allocator::dumpDebugInfo() const { +std::string Gralloc3Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); }); @@ -360,9 +360,10 @@ std::string Gralloc3Allocator::dumpDebugInfo() const { return debugInfo; } -status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, - uint32_t layerCount, uint64_t usage, uint32_t bufferCount, - uint32_t* outStride, buffer_handle_t* outBufferHandles) const { +status_t Gralloc3Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, + android::PixelFormat format, uint32_t layerCount, + uint64_t usage, uint32_t bufferCount, uint32_t* outStride, + buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); @@ -381,16 +382,31 @@ status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::P 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; |