summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2016-03-08 14:11:22 -0800
committerYang Ni <yangni@google.com>2016-03-09 14:43:32 -0800
commitb1f9eb6b37dace844ab927421c2dbfdff954e72d (patch)
tree8a4ee799f0a26f304c28fc609bc1e1ba0bbfcba9 /driver
parenta53bf64187bcf01ed1c62eacd52f6c6f41b5864b (diff)
downloadrs-b1f9eb6b37dace844ab927421c2dbfdff954e72d.tar.gz
Reset usrRefCount for rsObjects created by SSRS
Bug: 25570907 After calling runtime API to create an rsObject, decrement its user ref count to 0, so that they don't get leaked after the script finishes. To avoid deleting them too early, increment the sys ref count first. The increment will be matched with a rsClearObj() call inserted by slang. Change-Id: Iaa7312447efdd7d79f43be0bee44324b663de8d5 (cherry picked from commit 8133c6617ea975c0c08f28b6d1705dd27a92f35f)
Diffstat (limited to 'driver')
-rw-r--r--driver/rsdRuntimeStubs.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index 2ac731d7..b4958e24 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -233,6 +233,12 @@ static android::renderscript::rs_element CreateElement(RsDataType dt,
if (element == nullptr)
return obj;
element->callUpdateCacheObject(rsc, &obj);
+
+ // Any new rsObject created from inside a script should have the usrRefCount
+ // initialized to 0 and the sysRefCount initialized to 1.
+ element->incSysRef();
+ element->decUserRef();
+
return obj;
}
@@ -302,6 +308,12 @@ static android::renderscript::rs_type CreateType(RsElement element,
if (type == nullptr)
return obj;
type->callUpdateCacheObject(rsc, &obj);
+
+ // Any new rsObject created from inside a script should have the usrRefCount
+ // initialized to 0 and the sysRefCount initialized to 1.
+ type->incSysRef();
+ type->decUserRef();
+
return obj;
}
@@ -331,6 +343,11 @@ static android::renderscript::rs_allocation CreateAllocation(
return obj;
alloc->callUpdateCacheObject(rsc, &obj);
+ // Any new rsObject created from inside a script should have the usrRefCount
+ // initialized to 0 and the sysRefCount initialized to 1.
+ alloc->incSysRef();
+ alloc->decUserRef();
+
return obj;
}