diff options
| author | Yang Ni <yangni@google.com> | 2015-12-11 11:01:46 -0800 |
|---|---|---|
| committer | Yang Ni <yangni@google.com> | 2016-03-03 08:48:10 -0800 |
| commit | 04dcca95461a2ffab4ce5209a453b752ab5c606b (patch) | |
| tree | 023f61c5c82bd766d39f9e9a33df6cb4021f8709 /rsAllocation.cpp | |
| parent | 8c5e658838e91bfc9953d8f280444384c78716ed (diff) | |
Added a flag to APIs for rsObj creation
Bug: 25570907
This flag will distinguish calls from Java/JNI vs. Single-Source RS.
For the latter, the user ref count should remain zero to avoid memory
leaks.
Change-Id: Id3604f93b166089e3aca896d1c6c509b3ea19bcf
(cherry picked from commit a7725cbfcdfe2eaf868571c77f004a4d7208e8ef)
Diffstat (limited to 'rsAllocation.cpp')
| -rw-r--r-- | rsAllocation.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/rsAllocation.cpp b/rsAllocation.cpp index da70cd20..c06eecee 100644 --- a/rsAllocation.cpp +++ b/rsAllocation.cpp @@ -778,12 +778,15 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32 RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype, RsAllocationMipmapControl mipmaps, - uint32_t usages, uintptr_t ptr) { + uint32_t usages, uintptr_t ptr, bool fromJava) { Allocation * alloc = Allocation::createAllocation(rsc, static_cast<Type *>(vtype), usages, mipmaps, (void*)ptr); - if (!alloc) { - return nullptr; + if (alloc) { + if (fromJava) { + alloc->incUserRef(); + } else { + alloc->incSysRef(); + } } - alloc->incUserRef(); return alloc; } @@ -802,10 +805,10 @@ RsAllocation rsi_AllocationCreateStrided(Context *rsc, RsType vtype, RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype, RsAllocationMipmapControl mipmaps, - const void *data, size_t sizeBytes, uint32_t usages) { + const void *data, size_t sizeBytes, uint32_t usages, bool fromJava) { Type *t = static_cast<Type *>(vtype); - RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mipmaps, usages, 0); + RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mipmaps, usages, 0, fromJava); Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc); if (texAlloc == nullptr) { ALOGE("Memory allocation failure"); @@ -824,13 +827,14 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype, RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype, RsAllocationMipmapControl mipmaps, - const void *data, size_t sizeBytes, uint32_t usages) { + const void *data, size_t sizeBytes, uint32_t usages, + bool fromJava) { Type *t = static_cast<Type *>(vtype); // Cubemap allocation's faces should be Width by Width each. // Source data should have 6 * Width by Width pixels // Error checking is done in the java layer - RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mipmaps, usages, 0); + RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mipmaps, usages, 0, fromJava); Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc); if (texAlloc == nullptr) { ALOGE("Memory allocation failure"); |
