diff options
author | Tim Murray <timmurray@google.com> | 2012-12-19 13:03:29 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-12-19 13:03:38 -0800 |
commit | 0562a0dcc1bcbda59c753e659fbb2f9c3cd76869 (patch) | |
tree | d8c705561299be3720103004f5ec12fd17d21517 /graphics | |
parent | e78fb2c680e1f515a76643c2532c414b8fca06b2 (diff) | |
parent | 00bb454bd0b26c05e1dea5651b5edfd9c69ef2e0 (diff) | |
download | frameworks_base-0562a0dcc1bcbda59c753e659fbb2f9c3cd76869.zip frameworks_base-0562a0dcc1bcbda59c753e659fbb2f9c3cd76869.tar.gz frameworks_base-0562a0dcc1bcbda59c753e659fbb2f9c3cd76869.tar.bz2 |
Merge "Add USAGE_SHARED for Allocations."
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 2ce2f33..577bcca 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -148,6 +148,19 @@ public class Allocation extends BaseObj { public static final int USAGE_IO_OUTPUT = 0x0040; /** + * USAGE_SHARED The allocation's backing store will be inherited + * from another object (usually a Bitmap); calling appropriate + * copy methods will be significantly faster than if the entire + * allocation were copied every time. + * + * This is set by default for allocations created with + * CreateFromBitmap(RenderScript, Bitmap) in API version 18 and + * higher. + * + */ + public static final int USAGE_SHARED = 0x0080; + + /** * Controls mipmap behavior when using the bitmap creation and * update functions. */ @@ -245,7 +258,8 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET | USAGE_IO_INPUT | - USAGE_IO_OUTPUT)) != 0) { + USAGE_IO_OUTPUT | + USAGE_SHARED)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } @@ -1236,8 +1250,11 @@ public class Allocation extends BaseObj { } /** - * Creates a non-mipmapped renderscript allocation to use as a - * graphics texture + * Creates a RenderScript allocation from a bitmap. + * + * With target API version 18 or greater, this allocation will be + * created with USAGE_SHARED. With target API version 17 or lower, + * this allocation will be created with USAGE_GRAPHICS_TEXTURE. * * @param rs Context to which the allocation will belong. * @param b bitmap source for the allocation data @@ -1246,6 +1263,10 @@ 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); + } return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); } |