diff options
| -rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 44cdc1cd4542..cc59d18e9a83 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -155,6 +155,18 @@ public class Allocation extends BaseObj { } } + private void updateCacheInfo(Type t) { + mCurrentDimX = t.getX(); + mCurrentDimY = t.getY(); + mCurrentDimZ = t.getZ(); + mCurrentCount = mCurrentDimX; + if (mCurrentDimY > 1) { + mCurrentCount *= mCurrentDimY; + } + if (mCurrentDimZ > 1) { + mCurrentCount *= mCurrentDimZ; + } + } Allocation(int id, RenderScript rs, Type t, int usage) { super(id, rs); @@ -167,15 +179,8 @@ public class Allocation extends BaseObj { } mType = t; - mCurrentDimX = t.getX(); - mCurrentDimY = t.getY(); - mCurrentDimZ = t.getZ(); - mCurrentCount = mCurrentDimX; - if (mCurrentDimY > 1) { - mCurrentCount *= mCurrentDimY; - } - if (mCurrentDimZ > 1) { - mCurrentCount *= mCurrentDimZ; + if (t != null) { + updateCacheInfo(t); } } @@ -785,6 +790,7 @@ public class Allocation extends BaseObj { int typeID = mRS.nAllocationGetType(getID()); mType = new Type(typeID, mRS); mType.updateFromNative(); + updateCacheInfo(mType); } /* |