Loading libs/ui/Gralloc2.cpp +26 −11 Original line number Original line Diff line number Diff line Loading @@ -381,7 +381,8 @@ std::string Gralloc2Allocator::dumpDebugInfo() const { status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo = {}; IMapper::BufferDescriptorInfo descriptorInfo = {}; descriptorInfo.width = width; descriptorInfo.width = width; descriptorInfo.height = height; descriptorInfo.height = height; Loading @@ -404,7 +405,7 @@ status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelForma return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -416,7 +417,21 @@ status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelForma return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading libs/ui/Gralloc3.cpp +26 −10 Original line number Original line Diff line number Diff line Loading @@ -362,7 +362,8 @@ std::string Gralloc3Allocator::dumpDebugInfo() const { status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading @@ -381,7 +382,7 @@ status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::P return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -393,6 +394,21 @@ status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::P return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading libs/ui/Gralloc4.cpp +26 −10 Original line number Original line Diff line number Diff line Loading @@ -327,7 +327,8 @@ std::string Gralloc4Allocator::dumpDebugInfo() const { status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading @@ -346,7 +347,7 @@ status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::P return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -358,6 +359,21 @@ status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::P return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading libs/ui/GraphicBufferAllocator.cpp +47 −28 Original line number Original line Diff line number Diff line Loading @@ -111,10 +111,10 @@ void GraphicBufferAllocator::dumpToSystemLog() ALOGD("%s", s.c_str()); ALOGD("%s", s.c_str()); } } status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t GraphicBufferAllocator::allocateHelper(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { std::string requestorName, bool importBuffer) { ATRACE_CALL(); ATRACE_CALL(); // make sure to not allocate a N x 0 or 0 x N buffer, since this is // make sure to not allocate a N x 0 or 0 x N buffer, since this is Loading @@ -137,8 +137,18 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel // TODO(b/72323293, b/72703005): Remove these invalid bits from callers // TODO(b/72323293, b/72703005): Remove these invalid bits from callers usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13)); usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13)); status_t error = status_t error = mAllocator->allocate(width, height, format, layerCount, usage, 1, stride, mAllocator->allocate(width, height, format, layerCount, usage, 1, stride, handle); handle, importBuffer); if (error != NO_ERROR) { ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " "usage %" PRIx64 ": %d", width, height, layerCount, format, usage, error); return NO_MEMORY; } if (!importBuffer) { return NO_ERROR; } size_t bufSize; size_t bufSize; // if stride has no meaning or is too large, // if stride has no meaning or is too large, Loading @@ -150,7 +160,6 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel bufSize = static_cast<size_t>((*stride)) * height * bpp; bufSize = static_cast<size_t>((*stride)) * height * bpp; } } if (error == NO_ERROR) { Mutex::Autolock _l(sLock); Mutex::Autolock _l(sLock); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); alloc_rec_t rec; alloc_rec_t rec; Loading @@ -165,20 +174,30 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel list.add(*handle, rec); list.add(*handle, rec); return NO_ERROR; return NO_ERROR; } else { ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " "usage %" PRIx64 ": %d", width, height, layerCount, format, usage, error); return NO_MEMORY; } } status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, true); } status_t GraphicBufferAllocator::allocateRawHandle(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, false); } } // DEPRECATED status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, buffer_handle_t* handle, uint32_t* stride, uint64_t /*graphicBufferId*/, std::string requestorName) { uint64_t /*graphicBufferId*/, std::string requestorName) { return allocate(width, height, format, layerCount, usage, handle, stride, requestorName); return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, true); } } status_t GraphicBufferAllocator::free(buffer_handle_t handle) status_t GraphicBufferAllocator::free(buffer_handle_t handle) Loading libs/ui/include/ui/Gralloc.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,8 @@ public: */ */ virtual status_t allocate(uint32_t width, uint32_t height, PixelFormat format, virtual status_t allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const = 0; uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers = true) const = 0; }; }; } // namespace android } // namespace android Loading Loading
libs/ui/Gralloc2.cpp +26 −11 Original line number Original line Diff line number Diff line Loading @@ -381,7 +381,8 @@ std::string Gralloc2Allocator::dumpDebugInfo() const { status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo = {}; IMapper::BufferDescriptorInfo descriptorInfo = {}; descriptorInfo.width = width; descriptorInfo.width = width; descriptorInfo.height = height; descriptorInfo.height = height; Loading @@ -404,7 +405,7 @@ status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelForma return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -416,7 +417,21 @@ status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelForma return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading
libs/ui/Gralloc3.cpp +26 −10 Original line number Original line Diff line number Diff line Loading @@ -362,7 +362,8 @@ std::string Gralloc3Allocator::dumpDebugInfo() const { status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading @@ -381,7 +382,7 @@ status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::P return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -393,6 +394,21 @@ status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::P return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading
libs/ui/Gralloc4.cpp +26 −10 Original line number Original line Diff line number Diff line Loading @@ -327,7 +327,8 @@ std::string Gralloc4Allocator::dumpDebugInfo() const { status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const { uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading @@ -346,7 +347,7 @@ status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::P return; return; } } // import buffers if (importBuffers) { for (uint32_t i = 0; i < bufferCount; i++) { for (uint32_t i = 0; i < bufferCount; i++) { error = mMapper.importBuffer(tmpBuffers[i], error = mMapper.importBuffer(tmpBuffers[i], &outBufferHandles[i]); &outBufferHandles[i]); Loading @@ -358,6 +359,21 @@ status_t Gralloc4Allocator::allocate(uint32_t width, uint32_t height, android::P return; 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; } } } } *outStride = tmpStride; *outStride = tmpStride; }); }); Loading
libs/ui/GraphicBufferAllocator.cpp +47 −28 Original line number Original line Diff line number Diff line Loading @@ -111,10 +111,10 @@ void GraphicBufferAllocator::dumpToSystemLog() ALOGD("%s", s.c_str()); ALOGD("%s", s.c_str()); } } status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t GraphicBufferAllocator::allocateHelper(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { std::string requestorName, bool importBuffer) { ATRACE_CALL(); ATRACE_CALL(); // make sure to not allocate a N x 0 or 0 x N buffer, since this is // make sure to not allocate a N x 0 or 0 x N buffer, since this is Loading @@ -137,8 +137,18 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel // TODO(b/72323293, b/72703005): Remove these invalid bits from callers // TODO(b/72323293, b/72703005): Remove these invalid bits from callers usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13)); usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13)); status_t error = status_t error = mAllocator->allocate(width, height, format, layerCount, usage, 1, stride, mAllocator->allocate(width, height, format, layerCount, usage, 1, stride, handle); handle, importBuffer); if (error != NO_ERROR) { ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " "usage %" PRIx64 ": %d", width, height, layerCount, format, usage, error); return NO_MEMORY; } if (!importBuffer) { return NO_ERROR; } size_t bufSize; size_t bufSize; // if stride has no meaning or is too large, // if stride has no meaning or is too large, Loading @@ -150,7 +160,6 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel bufSize = static_cast<size_t>((*stride)) * height * bpp; bufSize = static_cast<size_t>((*stride)) * height * bpp; } } if (error == NO_ERROR) { Mutex::Autolock _l(sLock); Mutex::Autolock _l(sLock); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); alloc_rec_t rec; alloc_rec_t rec; Loading @@ -165,20 +174,30 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, Pixel list.add(*handle, rec); list.add(*handle, rec); return NO_ERROR; return NO_ERROR; } else { ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " "usage %" PRIx64 ": %d", width, height, layerCount, format, usage, error); return NO_MEMORY; } } status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, true); } status_t GraphicBufferAllocator::allocateRawHandle(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName) { return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, false); } } // DEPRECATED status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t layerCount, uint64_t usage, buffer_handle_t* handle, uint32_t* stride, buffer_handle_t* handle, uint32_t* stride, uint64_t /*graphicBufferId*/, std::string requestorName) { uint64_t /*graphicBufferId*/, std::string requestorName) { return allocate(width, height, format, layerCount, usage, handle, stride, requestorName); return allocateHelper(width, height, format, layerCount, usage, handle, stride, requestorName, true); } } status_t GraphicBufferAllocator::free(buffer_handle_t handle) status_t GraphicBufferAllocator::free(buffer_handle_t handle) Loading
libs/ui/include/ui/Gralloc.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,8 @@ public: */ */ virtual status_t allocate(uint32_t width, uint32_t height, PixelFormat format, virtual status_t allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles) const = 0; uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers = true) const = 0; }; }; } // namespace android } // namespace android Loading