summaryrefslogtreecommitdiff
path: root/rsType.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2012-04-02 20:18:48 -0700
committerStephen Hines <srhines@google.com>2012-04-02 20:22:42 -0700
commit9f70a4e63825afe9f786483722e1669b3625f5e9 (patch)
tree956673fa9b0017b93b0cd30daf3031b5de8829bd /rsType.cpp
parent69cccdf0659a193d6a75420ec745421fb5c436e6 (diff)
downloadrs-9f70a4e63825afe9f786483722e1669b3625f5e9.tar.gz
Move incRefs()/decRefs() logic from Allocation -> Type.
BUG=6009244 This refactoring will make it easier to implement proper type tracking (for updating reference counts using FieldPacker). Change-Id: If42b23193e81bc36ca5508a3d6987e73824107a1
Diffstat (limited to 'rsType.cpp')
-rw-r--r--rsType.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/rsType.cpp b/rsType.cpp
index b668a78c..e11b9c1f 100644
--- a/rsType.cpp
+++ b/rsType.cpp
@@ -268,6 +268,37 @@ ObjectBaseRef<Type> Type::cloneAndResize2D(Context *rsc,
}
+void Type::incRefs(const void *ptr, size_t ct, size_t startOff) const {
+ const uint8_t *p = static_cast<const uint8_t *>(ptr);
+ const Element *e = mHal.state.element;
+ uint32_t stride = e->getSizeBytes();
+
+ p += stride * startOff;
+ while (ct > 0) {
+ e->incRefs(p);
+ ct--;
+ p += stride;
+ }
+}
+
+
+void Type::decRefs(const void *ptr, size_t ct, size_t startOff) const {
+ if (!mHal.state.element->getHasReferences()) {
+ return;
+ }
+ const uint8_t *p = static_cast<const uint8_t *>(ptr);
+ const Element *e = mHal.state.element;
+ uint32_t stride = e->getSizeBytes();
+
+ p += stride * startOff;
+ while (ct > 0) {
+ e->decRefs(p);
+ ct--;
+ p += stride;
+ }
+}
+
+
//////////////////////////////////////////////////
//
namespace android {