summaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-03-23 11:09:56 -0700
committerMiao Wang <miaowang@google.com>2015-03-23 11:50:18 -0700
commita4e5adf955ad7dfde3081fa8307b2d1bf562473f (patch)
treed707977ff28ecd0322832260251007e7e2214686 /rs
parent978cfc39a10e1b95f9d6dfb5c8e9eb58a10ce0ec (diff)
downloadframeworks_base-a4e5adf955ad7dfde3081fa8307b2d1bf562473f.zip
frameworks_base-a4e5adf955ad7dfde3081fa8307b2d1bf562473f.tar.gz
frameworks_base-a4e5adf955ad7dfde3081fa8307b2d1bf562473f.tar.bz2
[RenderScript] Add create(Context, int) to be compatible with
the thunker layer & minor tweaks. bug:19888167 bug:19888339 Change-Id: Ib264c4ca48c990b3476456838047f73d95f6752f
Diffstat (limited to 'rs')
-rw-r--r--rs/java/android/renderscript/RenderScript.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 5078224..45f0ca6 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -1352,7 +1352,7 @@ public class RenderScript {
}
/**
- * calls create(cts, ContextType.NORMAL, CREATE_FLAG_NONE)
+ * calls create(ctx, ContextType.NORMAL, CREATE_FLAG_NONE)
*
* See documentation for @create for details
*
@@ -1364,7 +1364,7 @@ public class RenderScript {
}
/**
- * calls create(cts, ct, CREATE_FLAG_NONE)
+ * calls create(ctx, ct, CREATE_FLAG_NONE)
*
* See documentation for @create for details
*
@@ -1376,7 +1376,8 @@ public class RenderScript {
return create(ctx, ct, CREATE_FLAG_NONE);
}
- /**
+
+ /**
* Gets or creates a RenderScript context of the specified type.
*
* The returned context will be cached for future reuse within
@@ -1398,21 +1399,49 @@ public class RenderScript {
*/
public static RenderScript create(Context ctx, ContextType ct, int flags) {
int v = ctx.getApplicationInfo().targetSdkVersion;
- if (v < 23) {
- return internalCreate(ctx, v, ct, flags);
+ return create(ctx, v, ct, flags);
+ }
+
+ /**
+ * calls create(ctx, sdkVersion, ContextType.NORMAL, CREATE_FLAG_NONE)
+ *
+ * Used by the RenderScriptThunker to maintain backward compatibility.
+ *
+ * @hide
+ * @param ctx The context.
+ * @param sdkVersion The target SDK Version.
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx, int sdkVersion) {
+ return create(ctx, sdkVersion, ContextType.NORMAL, CREATE_FLAG_NONE);
+ }
+
+ /**
+ * Gets or creates a RenderScript context of the specified type.
+ *
+ * @hide
+ * @param ctx The context.
+ * @param ct The type of context to be created.
+ * @param sdkVersion The target SDK Version.
+ * @param flags The OR of the CREATE_FLAG_* options desired
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct, int flags) {
+ if (sdkVersion < 23) {
+ return internalCreate(ctx, sdkVersion, ct, flags);
}
synchronized (mProcessContextList) {
for (RenderScript prs : mProcessContextList) {
if ((prs.mContextType == ct) &&
(prs.mContextFlags == flags) &&
- (prs.mContextSdkVersion == v)) {
+ (prs.mContextSdkVersion == sdkVersion)) {
return prs;
}
}
- RenderScript prs = internalCreate(ctx, v, ct, flags);
+ RenderScript prs = internalCreate(ctx, sdkVersion, ct, flags);
prs.mIsProcessContext = true;
mProcessContextList.add(prs);
return prs;