diff options
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index acc6b99e19bb..ea29b7dc49cc 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -277,14 +277,14 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Invalid usage combination."); } } - - // 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; + if (t != null) { + // 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; @@ -355,6 +355,12 @@ public class Allocation extends BaseObj { mType.updateFromNative(); updateCacheInfo(mType); } + // don't need to account for USAGE_SHARED Allocations + if ((mUsage & USAGE_SHARED) == 0) { + int numBytes = mType.getCount() * mType.getElement().getBytesSize(); + mRS.addAllocSizeForGC(numBytes); + mGCSize = numBytes; + } } /** |