summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2013-01-07 18:20:12 -0800
committerJason Sams <jsams@google.com>2013-01-08 15:29:41 -0800
commitb109cc78616abee7291eb42094cd156b5db3355d (patch)
tree85f9838c5c050b7429f21d77551b770b9f684c1e /graphics
parent40f1fa6ed699b885e3270faf88085ed78f54a2f4 (diff)
downloadframeworks_base-b109cc78616abee7291eb42094cd156b5db3355d.zip
frameworks_base-b109cc78616abee7291eb42094cd156b5db3355d.tar.gz
frameworks_base-b109cc78616abee7291eb42094cd156b5db3355d.tar.bz2
Add YUV allocation creation.
Change-Id: I0d1ff72f60481eb9c28cf058eab72e689494d14b
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java6
-rw-r--r--graphics/java/android/renderscript/Type.java31
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp10
3 files changed, 38 insertions, 9 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 900720a..fa115ff 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -240,10 +240,10 @@ public class RenderScript {
rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
}
- native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
- synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) {
+ native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
+ synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
validate();
- return rsnTypeCreate(mContext, eid, x, y, z, mips, faces);
+ return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv);
}
native void rsnTypeGetNativeData(int con, int id, int[] typeData);
synchronized void nTypeGetNativeData(int id, int[] typeData) {
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index 93d8b4b..cb12594 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -18,6 +18,8 @@ package android.renderscript;
import java.lang.reflect.Field;
+
+import android.graphics.ImageFormat;
import android.util.Log;
/**
@@ -208,6 +210,7 @@ public class Type extends BaseObj {
int mDimZ;
boolean mDimMipmaps;
boolean mDimFaces;
+ int mYuv;
Element mElement;
@@ -263,6 +266,25 @@ public class Type extends BaseObj {
return this;
}
+ /**
+ * @hide
+ *
+ * only NV21, YV12. Enums from ImageFormat
+ */
+ public Builder setYuvFormat(int yuvFormat) {
+ switch (yuvFormat) {
+ case android.graphics.ImageFormat.NV21:
+ case android.graphics.ImageFormat.YV12:
+ break;
+
+ default:
+ throw new RSIllegalArgumentException("Only NV21 and YV12 are supported..");
+ }
+
+ mYuv = yuvFormat;
+ return this;
+ }
+
/**
* Validate structure and create a new type.
@@ -289,8 +311,14 @@ public class Type extends BaseObj {
}
}
+ if (mYuv != 0) {
+ if ((mDimZ != 0) || mDimFaces || mDimMipmaps) {
+ throw new RSInvalidStateException("YUV only supports basic 2D.");
+ }
+ }
+
int id = mRS.nTypeCreate(mElement.getID(mRS),
- mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
+ mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces, mYuv);
Type t = new Type(id, mRS);
t.mElement = mElement;
t.mDimX = mDimX;
@@ -298,6 +326,7 @@ public class Type extends BaseObj {
t.mDimZ = mDimZ;
t.mDimMipmaps = mDimMipmaps;
t.mDimFaces = mDimFaces;
+ t.mDimYuv = mYuv;
t.calcElementCount();
return t;
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 75c7903..54413b4 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -427,12 +427,12 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id,
static int
nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid,
- jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces)
+ jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv)
{
- LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i)",
- con, eid, dimx, dimy, dimz, mips, faces);
+ LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)",
+ con, eid, dimx, dimy, dimz, mips, faces, yuv);
- jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces);
+ jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv);
return (jint)id;
}
@@ -1454,7 +1454,7 @@ static JNINativeMethod methods[] = {
{"rsnElementGetNativeData", "(II[I)V", (void*)nElementGetNativeData },
{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements },
-{"rsnTypeCreate", "(IIIIIZZ)I", (void*)nTypeCreate },
+{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate },
{"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData },
{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped },