diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-08-12 15:29:46 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-12 15:29:46 -0700 |
commit | c929158f0e0e02f8690c8355754ce2830c6e2dfe (patch) | |
tree | d652c0c3603a525c5c0e409f962f2fae7103fd45 /libs | |
parent | 7c0d8472d003334fafd14f7c1e7d95dbd213088b (diff) | |
parent | 065fa8deb178f00ad9957d3212ec2620c46f78e4 (diff) | |
download | frameworks_base-c929158f0e0e02f8690c8355754ce2830c6e2dfe.zip frameworks_base-c929158f0e0e02f8690c8355754ce2830c6e2dfe.tar.gz frameworks_base-c929158f0e0e02f8690c8355754ce2830c6e2dfe.tar.bz2 |
Merge "Fix to the memory leak problem."
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/rsAllocation.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index f3e0c0a..b59ade8 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -58,6 +58,19 @@ void Allocation::updateCache() { } Allocation::~Allocation() { + if (mHal.state.hasReferences && + (mHal.state.hasFaces || mHal.state.hasMipmaps)) { + LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!"); + } + + uint32_t elemCount = mHal.state.dimensionX; + if (mHal.state.dimensionY > 1) { + elemCount *= mHal.state.dimensionY; + } + if (mHal.state.dimensionZ > 1) { + elemCount *= mHal.state.dimensionZ; + } + decRefs(getPtr(), elemCount, 0); mRSC->mHal.funcs.allocation.destroy(mRSC, this); } @@ -270,6 +283,9 @@ void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const { } void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const { + if (!mHal.state.hasReferences || !getIsScript()) { + return; + } const uint8_t *p = static_cast<const uint8_t *>(ptr); const Element *e = mHal.state.type->getElement(); uint32_t stride = e->getSizeBytes(); |