From f8c033db1edf36a0ab09568c3142054f0be2d1a1 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Tue, 9 Apr 2013 14:33:32 -0700 Subject: Implement RS GC worker thread. Bug 8579360 Change-Id: I98a5509b68e592bcbb4958f2ca72c236a22910b5 --- graphics/java/android/renderscript/Allocation.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'graphics/java/android/renderscript/Allocation.java') diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index b8564b60bbf2..8bc6b968cd90 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -274,12 +274,20 @@ public class Allocation extends BaseObj { } } + // don't need to account for USAGE_SHARED Allocations + if ((usage & USAGE_SHARED) == 0) { + int numBytes = t.getCount() * t.getElement().getBytesSize(); + rs.addAllocSizeForGC(numBytes); + mGCSize = numBytes; + } + mType = t; mUsage = usage; if (t != null) { updateCacheInfo(t); } + } private void validateIsInt32() { @@ -1117,6 +1125,7 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } + int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); @@ -1266,7 +1275,6 @@ public class Allocation extends BaseObj { return alloc; } - int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); -- cgit v1.2.3