diff options
author | koron393 <koron393@gmail.com> | 2019-05-07 03:01:14 +0900 |
---|---|---|
committer | Arian <arian.kulmer@web.de> | 2019-10-25 22:16:13 +0200 |
commit | 5a6ff3a367c8736fef6af23608866248c2fec43e (patch) | |
tree | 6e072264562929dadeea7f4e178a6cbdd8e7a43f /libshims | |
parent | eb4c130ccf05799fe7c20a4737f21dd63c0dbed5 (diff) |
msm8974-common: libshim_camera: Apply revert patches to Marshmallow
* Fix build.
* Revert GraphicBuffer method to Marshmallow (for 23.5.A.1.291 blobs).
* Apply module loading changes.
* TODO: Remove unneeded sources.
Change-Id: Ifce6a23840bd8c6170e0b8a714233d7b5e99acb4
Diffstat (limited to 'libshims')
-rw-r--r-- | libshims/Android.mk | 9 | ||||
-rw-r--r-- | libshims/include/ui/GraphicBuffer.h | 14 | ||||
-rw-r--r-- | libshims/include/ui/GraphicBufferAllocator.h | 4 | ||||
-rw-r--r-- | libshims/include/utils/VectorImpl.h | 38 | ||||
-rw-r--r-- | libshims/ui/GraphicBuffer.cpp | 61 | ||||
-rw-r--r-- | libshims/ui/GraphicBufferAllocator.cpp | 32 | ||||
-rw-r--r-- | libshims/utils/VectorImpl.cpp | 27 |
7 files changed, 126 insertions, 59 deletions
diff --git a/libshims/Android.mk b/libshims/Android.mk index 3fd0761..591ea9d 100644 --- a/libshims/Android.mk +++ b/libshims/Android.mk @@ -29,7 +29,9 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ external/safe-iop/include \ - system/core/libutils + system/core/libutils \ + system/core/libgrallocusage/include \ + frameworks/native/libs/vr/libpdx/private LOCAL_SHARED_LIBRARIES := \ libcutils \ @@ -37,7 +39,10 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libui \ libsync \ - libutils + libutils \ + libhidlbase \ + android.hardware.graphics.allocator@2.0 \ + android.hardware.graphics.mapper@2.1 LOCAL_MODULE := libshim_camera diff --git a/libshims/include/ui/GraphicBuffer.h b/libshims/include/ui/GraphicBuffer.h index cc38982..7b4fac8 100644 --- a/libshims/include/ui/GraphicBuffer.h +++ b/libshims/include/ui/GraphicBuffer.h @@ -31,6 +31,7 @@ #include <nativebase/nativebase.h> #include <hardware/gralloc.h> +struct ANativeWindowBuffer; namespace android { @@ -126,14 +127,19 @@ public: // These functions are deprecated because they only take 32 bits of usage GraphicBuffer(const native_handle_t* handle, HandleWrapMethod method, uint32_t width, uint32_t height, - PixelFormat format, uint32_t layerCount, + PixelFormat format, uint32_t usage, uint32_t stride) : GraphicBuffer(handle, method, width, height, format, layerCount, static_cast<uint64_t>(usage), stride) {} GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, - uint32_t inLayerCount, uint32_t inUsage, uint32_t inStride, + uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle, bool keepOwnership); GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inUsage); + // create a buffer from an existing ANativeWindowBuffer + GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership); + + GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage, std::string requestorName = "<Unknown>"); // return status @@ -236,6 +242,10 @@ private: GraphicBufferMapper& mBufferMapper; ssize_t mInitCheck; + // If we're wrapping another buffer then this reference will make sure it + // doesn't get freed. + sp<ANativeWindowBuffer> mWrappedBuffer; + // numbers of fds/ints in native_handle_t to flatten uint32_t mTransportNumFds; uint32_t mTransportNumInts; diff --git a/libshims/include/ui/GraphicBufferAllocator.h b/libshims/include/ui/GraphicBufferAllocator.h index 14a865e..546fb4b 100644 --- a/libshims/include/ui/GraphicBufferAllocator.h +++ b/libshims/include/ui/GraphicBufferAllocator.h @@ -32,6 +32,8 @@ #include <utils/Mutex.h> #include <utils/Singleton.h> +#include <hardware/gralloc.h> + namespace android { namespace Gralloc2 { @@ -75,7 +77,7 @@ private: GraphicBufferAllocator(); ~GraphicBufferAllocator(); - GraphicBufferMapper& mMapper; + alloc_device_t *mAllocDev; const std::unique_ptr<const Gralloc2::Allocator> mAllocator; }; diff --git a/libshims/include/utils/VectorImpl.h b/libshims/include/utils/VectorImpl.h index 4dd91fd..f5fa742 100644 --- a/libshims/include/utils/VectorImpl.h +++ b/libshims/include/utils/VectorImpl.h @@ -53,12 +53,12 @@ public: /*! must be called from subclasses destructor */ void finish_vector(); - VectorImpl& operator = (const VectorImpl& rhs); - + VectorImpl& operator = (const VectorImpl& rhs); + /*! C-style array access */ inline const void* arrayImpl() const { return mStorage; } void* editArrayImpl(); - + /*! vector stats */ inline size_t size() const { return mCount; } inline bool isEmpty() const { return mCount == 0; } @@ -71,7 +71,7 @@ public: ssize_t appendVector(const VectorImpl& vector); ssize_t insertArrayAt(const void* array, size_t index, size_t length); ssize_t appendArray(const void* array, size_t length); - + /*! add/insert/replace items */ ssize_t insertAt(size_t where, size_t numItems = 1); ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); @@ -105,7 +105,16 @@ protected: virtual void do_splat(void* dest, const void* item, size_t num) const = 0; virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0; virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0; - + + virtual void reservedVectorImpl1(); + virtual void reservedVectorImpl2(); + virtual void reservedVectorImpl3(); + virtual void reservedVectorImpl4(); + virtual void reservedVectorImpl5(); + virtual void reservedVectorImpl6(); + virtual void reservedVectorImpl7(); + virtual void reservedVectorImpl8(); + private: void* _grow(size_t where, size_t amount); void _shrink(size_t where, size_t amount); @@ -132,10 +141,10 @@ class SortedVectorImpl : public VectorImpl { public: SortedVectorImpl(size_t itemSize, uint32_t flags); - explicit SortedVectorImpl(const VectorImpl& rhs); + SortedVectorImpl(const VectorImpl& rhs); virtual ~SortedVectorImpl(); - - SortedVectorImpl& operator = (const SortedVectorImpl& rhs); + + SortedVectorImpl& operator = (const SortedVectorImpl& rhs); //! finds the index of an item ssize_t indexOf(const void* item) const; @@ -149,13 +158,22 @@ public: //! merges a vector into this one ssize_t merge(const VectorImpl& vector); ssize_t merge(const SortedVectorImpl& vector); - + //! removes an item ssize_t remove(const void* item); - + protected: virtual int do_compare(const void* lhs, const void* rhs) const = 0; + virtual void reservedSortedVectorImpl1(); + virtual void reservedSortedVectorImpl2(); + virtual void reservedSortedVectorImpl3(); + virtual void reservedSortedVectorImpl4(); + virtual void reservedSortedVectorImpl5(); + virtual void reservedSortedVectorImpl6(); + virtual void reservedSortedVectorImpl7(); + virtual void reservedSortedVectorImpl8(); + private: ssize_t _indexOrderOf(const void* item, size_t* order = 0) const; diff --git a/libshims/ui/GraphicBuffer.cpp b/libshims/ui/GraphicBuffer.cpp index 7670ac6..a1cf872 100644 --- a/libshims/ui/GraphicBuffer.cpp +++ b/libshims/ui/GraphicBuffer.cpp @@ -58,40 +58,47 @@ GraphicBuffer::GraphicBuffer() handle = NULL; } -// deprecated GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inUsage, std::string requestorName) - : GraphicBuffer(inWidth, inHeight, inFormat, 1, static_cast<uint64_t>(inUsage), requestorName) -{ -} - -GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint64_t usage, std::string requestorName) - : GraphicBuffer() + PixelFormat inFormat, uint32_t inUsage) + : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mId(getUniqueId()) { - mInitCheck = initWithSize(inWidth, inHeight, inFormat, inLayerCount, - usage, std::move(requestorName)); + width = + height = + stride = + format = + usage = 0; + handle = NULL; + mInitCheck = initWithSize(inWidth, inHeight, inFormat, 1, + static_cast<uint64_t>(inUsage), "<Unknown>"); } -// deprecated GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage, - uint32_t inStride, native_handle_t* inHandle, bool keepOwnership) - : GraphicBuffer(inHandle, keepOwnership ? TAKE_HANDLE : WRAP_HANDLE, - inWidth, inHeight, inFormat, inLayerCount, static_cast<uint64_t>(inUsage), - inStride) + PixelFormat inFormat, uint32_t inUsage, uint32_t inStride, + native_handle_t* inHandle, bool keepOwnership) + : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), + mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mId(getUniqueId()) { -} - -GraphicBuffer::GraphicBuffer(const native_handle_t* handle, - HandleWrapMethod method, uint32_t width, uint32_t height, - PixelFormat format, uint32_t layerCount, - uint64_t usage, - uint32_t stride) - : GraphicBuffer() + width = static_cast<int>(inWidth); + height = static_cast<int>(inHeight); + stride = static_cast<int>(inStride); + format = inFormat; + usage = static_cast<int>(inUsage); + handle = inHandle; +} + +GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership) + : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), + mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mWrappedBuffer(buffer), mId(getUniqueId()) { - mInitCheck = initWithHandle(handle, method, width, height, format, - layerCount, usage, stride); + width = buffer->width; + height = buffer->height; + stride = buffer->stride; + format = buffer->format; + usage = buffer->usage; + handle = buffer->handle; } GraphicBuffer::~GraphicBuffer() diff --git a/libshims/ui/GraphicBufferAllocator.cpp b/libshims/ui/GraphicBufferAllocator.cpp index eaba1ed..3806a8d 100644 --- a/libshims/ui/GraphicBufferAllocator.cpp +++ b/libshims/ui/GraphicBufferAllocator.cpp @@ -42,13 +42,20 @@ KeyedVector<buffer_handle_t, GraphicBufferAllocator::alloc_rec_t> GraphicBufferAllocator::sAllocList; GraphicBufferAllocator::GraphicBufferAllocator() - : mMapper(GraphicBufferMapper::getInstance()), - mAllocator(std::make_unique<Gralloc2::Allocator>( - mMapper.getGrallocMapper())) + : mAllocDev(0) { + hw_module_t const* module; + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); + ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); + if (err == 0) { + gralloc_open(module, &mAllocDev); + } } -GraphicBufferAllocator::~GraphicBufferAllocator() {} +GraphicBufferAllocator::~GraphicBufferAllocator() +{ + gralloc_close(mAllocDev); +} void GraphicBufferAllocator::dump(String8& result) const { @@ -143,17 +150,18 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, status_t GraphicBufferAllocator::free(buffer_handle_t handle) { - ATRACE_CALL(); + status_t err; - // We allocated a buffer from the allocator and imported it into the - // mapper to get the handle. We just need to free the handle now. - mMapper.freeBuffer(handle); + err = mAllocDev->free(mAllocDev, handle); - Mutex::Autolock _l(sLock); - KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); - list.removeItem(handle); + ALOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err)); + if (err == NO_ERROR) { + Mutex::Autolock _l(sLock); + KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); + list.removeItem(handle); + } - return NO_ERROR; + return err; } // --------------------------------------------------------------------------- diff --git a/libshims/utils/VectorImpl.cpp b/libshims/utils/VectorImpl.cpp index ef3277f..14b331b 100644 --- a/libshims/utils/VectorImpl.cpp +++ b/libshims/utils/VectorImpl.cpp @@ -63,7 +63,7 @@ VectorImpl::~VectorImpl() "[%p] subclasses of VectorImpl must call finish_vector()" " in their destructor. Leaking %d bytes.", this, (int)(mCount*mItemSize)); - // We can't call _do_destroy() here because the vtable is already gone. + // We can't call _do_destroy() here because the vtable is already gone. } VectorImpl& VectorImpl::operator = (const VectorImpl& rhs) @@ -199,7 +199,7 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state) _do_copy(temp, item, 1); ssize_t j = i-1; - void* next = reinterpret_cast<char*>(array) + mItemSize*(i); + void* next = reinterpret_cast<char*>(array) + mItemSize*(i); do { _do_destroy(next, 1); _do_copy(next, curr, 1); @@ -216,7 +216,7 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state) } i++; } - + if (temp) { _do_destroy(temp, 1); free(temp); @@ -372,7 +372,7 @@ void VectorImpl::release_storage() if (sb->release(SharedBuffer::eKeepStorage) == 1) { _do_destroy(mStorage, mCount); SharedBuffer::dealloc(sb); - } + } } } @@ -556,6 +556,15 @@ void VectorImpl::_do_move_backward(void* dest, const void* from, size_t num) con do_move_backward(dest, from, num); } +void VectorImpl::reservedVectorImpl1() { } +void VectorImpl::reservedVectorImpl2() { } +void VectorImpl::reservedVectorImpl3() { } +void VectorImpl::reservedVectorImpl4() { } +void VectorImpl::reservedVectorImpl5() { } +void VectorImpl::reservedVectorImpl6() { } +void VectorImpl::reservedVectorImpl7() { } +void VectorImpl::reservedVectorImpl8() { } + /*****************************************************************************/ SortedVectorImpl::SortedVectorImpl(size_t itemSize, uint32_t flags) @@ -675,7 +684,15 @@ ssize_t SortedVectorImpl::remove(const void* item) return i; } +void SortedVectorImpl::reservedSortedVectorImpl1() { }; +void SortedVectorImpl::reservedSortedVectorImpl2() { }; +void SortedVectorImpl::reservedSortedVectorImpl3() { }; +void SortedVectorImpl::reservedSortedVectorImpl4() { }; +void SortedVectorImpl::reservedSortedVectorImpl5() { }; +void SortedVectorImpl::reservedSortedVectorImpl6() { }; +void SortedVectorImpl::reservedSortedVectorImpl7() { }; +void SortedVectorImpl::reservedSortedVectorImpl8() { }; + /*****************************************************************************/ }; // namespace android - |