From 88990da58d0231b5a1b9a27b32c37839e95c7487 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Mon, 9 Sep 2013 17:56:07 -0700 Subject: Don't set Allocation mSize when we have no Type. Bug: 10667740 A3D creates Allocations before knowing the underlying Type (and thus size). Moving the mSize calculation to be conditional for concrete Allocations eliminates the bug. In the future, we could let A3D dynamically update the Allocation size if it is necessary to improve heap behavior. Change-Id: I520246806b6ead0387a1a41372dade1a6e7c2271 --- graphics/java/android/renderscript/Allocation.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index ca72c25..dca934f 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -269,9 +269,12 @@ public class Allocation extends BaseObj { mType = t; mUsage = usage; - mSize = mType.getCount() * mType.getElement().getBytesSize(); if (t != null) { + // TODO: A3D doesn't have Type info during creation, so we can't + // calculate the size ahead of time. We can possibly add a method + // to update the size in the future if it seems reasonable. + mSize = mType.getCount() * mType.getElement().getBytesSize(); updateCacheInfo(t); } try { -- cgit v1.1