summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsAllocation.cpp
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-09-25 14:51:22 -0700
committerJason Sams <rjsams@android.com>2009-09-25 14:51:22 -0700
commita9e7a05b84470257637c97d65f6562aa832c66ef (patch)
tree04a3175485ae7492c3387003c244953b6880c514 /libs/rs/rsAllocation.cpp
parenta0cad2f5d19d95cfe496ebb82f3227dd4ed7c169 (diff)
downloadframeworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.zip
frameworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.tar.gz
frameworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.tar.bz2
Improve renderscript context teardown. Track object in the system and then force their cleanup by releasing all user references once destroy context is called. Java layer will no longer send destroy notifications for objects garbage collected once a context is destroyed.
Diffstat (limited to 'libs/rs/rsAllocation.cpp')
-rw-r--r--libs/rs/rsAllocation.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index cb82624..96e128b 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -22,7 +22,7 @@
using namespace android;
using namespace android::renderscript;
-Allocation::Allocation(const Type *type)
+Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc)
{
mPtr = NULL;
@@ -90,7 +90,7 @@ void Allocation::uploadToTexture(uint32_t lodOffset)
}
glBindTexture(GL_TEXTURE_2D, mTextureID);
- Adapter2D adapt(this);
+ Adapter2D adapt(getContext(), this);
for(uint32_t lod = 0; (lod + lodOffset) < mType->getLODCount(); lod++) {
adapt.setLOD(lod+lodOffset);
@@ -186,14 +186,14 @@ RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype)
{
const Type * type = static_cast<const Type *>(vtype);
- Allocation * alloc = new Allocation(type);
+ Allocation * alloc = new Allocation(rsc, type);
alloc->incUserRef();
return alloc;
}
RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
{
- Type * type = new Type();
+ Type * type = new Type(rsc);
type->setDimX(count);
type->setElement(static_cast<Element *>(e));
type->compute();
@@ -371,8 +371,8 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h
cvt(texAlloc->getPtr(), data, w * h);
if (genMips) {
- Adapter2D adapt(texAlloc);
- Adapter2D adapt2(texAlloc);
+ Adapter2D adapt(rsc, texAlloc);
+ Adapter2D adapt2(rsc, texAlloc);
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
adapt.setLOD(lod);
adapt2.setLOD(lod + 1);