diff options
author | Tim Murray <timmurray@google.com> | 2013-04-09 17:28:56 -0700 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2013-04-09 17:47:57 -0700 |
commit | 78e64945602fc9df6f4e3f8050a794b17ba0f22c (patch) | |
tree | a5e44cb625825c06db49d06d9a4dd54ab5f91b5f /graphics/java/android/renderscript/Allocation.java | |
parent | f8c033db1edf36a0ab09568c3142054f0be2d1a1 (diff) |
Clean up USAGE_SHARED and add syncing for USAGE_SHARED.
bug 8567006
Change-Id: Ie9c01eeccdd3fa0a81893314dfbce7c012d3f7d3
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 8bc6b968cd90..1a7b8b7796cf 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -370,11 +370,20 @@ public class Allocation extends BaseObj { */ public void syncAll(int srcLocation) { switch (srcLocation) { + case USAGE_GRAPHICS_TEXTURE: case USAGE_SCRIPT: + if ((mUsage & USAGE_SHARED) != 0) { + copyFrom(mBitmap); + } + break; case USAGE_GRAPHICS_CONSTANTS: - case USAGE_GRAPHICS_TEXTURE: case USAGE_GRAPHICS_VERTEX: break; + case USAGE_SHARED: + if ((mUsage & USAGE_SHARED) != 0) { + copyTo(mBitmap); + } + break; default: throw new RSIllegalArgumentException("Source must be exactly one usage type."); } @@ -1263,7 +1272,7 @@ public class Allocation extends BaseObj { // enable optimized bitmap path only with no mipmap and script-only usage if (mips == MipmapControl.MIPMAP_NONE && t.getElement().isCompatible(Element.RGBA_8888(rs)) && - usage == (USAGE_SHARED | USAGE_SCRIPT)) { + usage == (USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE)) { int id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); @@ -1334,7 +1343,7 @@ public class Allocation extends BaseObj { static public Allocation createFromBitmap(RenderScript rs, Bitmap b) { if (rs.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) { return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, - USAGE_SHARED | USAGE_SCRIPT); + USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE); } return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); @@ -1552,7 +1561,7 @@ public class Allocation extends BaseObj { if (rs.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) { return createFromBitmapResource(rs, res, id, MipmapControl.MIPMAP_NONE, - USAGE_SHARED | USAGE_SCRIPT); + USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE); } return createFromBitmapResource(rs, res, id, MipmapControl.MIPMAP_NONE, |