diff options
author | Jason Sams <rjsams@android.com> | 2009-08-04 16:58:20 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-08-04 17:05:43 -0700 |
commit | 22534176fb5c1257130ef4ee589739ca42766a32 (patch) | |
tree | d7efb4494b65e4769203b9a879646c7407d63cc9 /graphics | |
parent | 959b7bd96b18f84510e8af72d7a439140edb5169 (diff) | |
download | frameworks_base-22534176fb5c1257130ef4ee589739ca42766a32.zip frameworks_base-22534176fb5c1257130ef4ee589739ca42766a32.tar.gz frameworks_base-22534176fb5c1257130ef4ee589739ca42766a32.tar.bz2 |
Split ProgramFragment and ProgramStore from RenderScript.java. Update Element and Type to new cached builder for easier app developement.
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Element.java | 83 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramFragment.java | 150 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramStore.java | 178 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 186 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Script.java | 25 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Type.java | 40 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 51 |
7 files changed, 454 insertions, 259 deletions
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 8e0a7a1..409d267 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -146,58 +146,75 @@ public class Element extends BaseObj { public static class Builder { RenderScript mRS; - boolean mActive = true; + Entry[] mEntries; + int mEntryCount; + + private class Entry { + Element mElement; + Element.DataType mType; + Element.DataKind mKind; + boolean mIsNormalized; + int mBits; + } - Builder(RenderScript rs) { + public Builder(RenderScript rs) { mRS = rs; + mEntryCount = 0; + mEntries = new Entry[8]; } - void begin() throws IllegalStateException { - if (mActive) { - throw new IllegalStateException("Element builder already active."); + void addEntry(Entry e) { + if(mEntries.length >= mEntryCount) { + Entry[] en = new Entry[mEntryCount + 8]; + for(int ct=0; ct < mEntries.length; ct++) { + en[ct] = mEntries[ct]; + } + mEntries = en; } - mRS.nElementBegin(); - mActive = true; + mEntries[mEntryCount] = e; + mEntryCount++; } - public Builder add(Element e) throws IllegalArgumentException, IllegalStateException { - if(!mActive) { - throw new IllegalStateException("Element builder not active."); - } + public Builder add(Element e) throws IllegalArgumentException { if(!e.mIsPredefined) { throw new IllegalArgumentException("add requires a predefined Element."); } - mRS.nElementAddPredefined(e.mID); + Entry en = new Entry(); + en.mElement = e; + addEntry(en); return this; } - public Builder add(Element.DataType dt, Element.DataKind dk, boolean isNormalized, int bits) - throws IllegalStateException { - if(!mActive) { - throw new IllegalStateException("Element builder not active."); - } - int norm = 0; - if (isNormalized) { - norm = 1; - } - mRS.nElementAdd(dt.mID, dk.mID, norm, bits); + public Builder add(Element.DataType dt, Element.DataKind dk, boolean isNormalized, int bits) { + Entry en = new Entry(); + en.mType = dt; + en.mKind = dk; + en.mIsNormalized = isNormalized; + en.mBits = bits; + addEntry(en); return this; } - public void abort() throws IllegalStateException { - if(!mActive) { - throw new IllegalStateException("Element builder not active."); + static synchronized Element internalCreate(RenderScript rs, Builder b) { + rs.nElementBegin(); + for (int ct=0; ct < b.mEntryCount; ct++) { + Entry en = b.mEntries[ct]; + if(en.mElement != null) { + rs.nElementAddPredefined(en.mElement.mPredefinedID); + } else { + int norm = 0; + if (en.mIsNormalized) { + norm = 1; + } + rs.nElementAdd(en.mType.mID, en.mKind.mID, norm, en.mBits); + } } - mActive = false; + int id = rs.nElementCreate(); + return new Element(id, rs); } - public Element create() throws IllegalStateException { - if(!mActive) { - throw new IllegalStateException("Element builder not active."); - } - int id = mRS.nElementCreate(); - mActive = false; - return new Element(id, mRS); + public Element create() { + return internalCreate(mRS, this); } } diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java new file mode 100644 index 0000000..d98fe03 --- /dev/null +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.renderscript; + + +import android.util.Config; +import android.util.Log; + + +/** + * @hide + * + **/ +public class ProgramFragment extends BaseObj { + public enum EnvMode { + REPLACE (0), + MODULATE (1), + DECAL (2); + + int mID; + EnvMode(int id) { + mID = id; + } + } + + + ProgramFragment(int id, RenderScript rs) { + super(rs); + mID = id; + } + + public void destroy() { + mRS.nProgramFragmentStoreDestroy(mID); + mID = 0; + } + + public void bindTexture(Allocation va, int slot) { + mRS.nProgramFragmentBindTexture(mID, slot, va.mID); + } + + public void bindSampler(RenderScript.Sampler vs, int slot) { + mRS.nProgramFragmentBindSampler(mID, slot, vs.mID); + } + + + public static class Builder { + public static final int MAX_SLOT = 2; + RenderScript mRS; + Element mIn; + Element mOut; + + private class Slot { + Type mType; + EnvMode mEnv; + boolean mTexEnable; + + Slot() { + mTexEnable = false; + } + } + Slot[] mSlots; + + public Builder(RenderScript rs, Element in, Element out) { + mRS = rs; + mIn = in; + mOut = out; + mSlots = new Slot[MAX_SLOT]; + for(int ct=0; ct < MAX_SLOT; ct++) { + mSlots[ct] = new Slot(); + } + } + + public void setType(int slot, Type t) + throws IllegalArgumentException { + if((slot < 0) || (slot >= MAX_SLOT)) { + throw new IllegalArgumentException("Slot ID out of range."); + } + + mSlots[slot].mType = t; + } + + public void setTexEnable(boolean enable, int slot) + throws IllegalArgumentException { + if((slot < 0) || (slot >= MAX_SLOT)) { + throw new IllegalArgumentException("Slot ID out of range."); + } + + mSlots[slot].mTexEnable = enable; + } + + public void setTexEnvMode(EnvMode env, int slot) + throws IllegalArgumentException { + if((slot < 0) || (slot >= MAX_SLOT)) { + throw new IllegalArgumentException("Slot ID out of range."); + } + + mSlots[slot].mEnv = env; + } + + + static synchronized ProgramFragment internalCreate(RenderScript rs, Builder b) { + int inID = 0; + int outID = 0; + if (b.mIn != null) { + inID = b.mIn.mID; + } + if (b.mOut != null) { + outID = b.mOut.mID; + } + rs.nProgramFragmentBegin(inID, outID); + for(int ct=0; ct < MAX_SLOT; ct++) { + if(b.mSlots[ct].mTexEnable) { + Slot s = b.mSlots[ct]; + if(s.mType != null) { + rs.nProgramFragmentSetType(ct, s.mType.mID); + } + rs.nProgramFragmentSetTexEnable(ct, true); + if(s.mEnv != null) { + rs.nProgramFragmentSetEnvMode(ct, s.mEnv.mID); + } + } + } + + + int id = rs.nProgramFragmentCreate(); + return new ProgramFragment(id, rs); + } + + public ProgramFragment create() { + return internalCreate(mRS, this); + } + } +} + + + diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java new file mode 100644 index 0000000..9039621 --- /dev/null +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.renderscript; + + +import android.util.Config; +import android.util.Log; + + +/** + * @hide + * + **/ +public class ProgramStore extends BaseObj { + public enum DepthFunc { + ALWAYS (0), + LESS (1), + LEQUAL (2), + GREATER (3), + GEQUAL (4), + EQUAL (5), + NOTEQUAL (6); + + int mID; + DepthFunc(int id) { + mID = id; + } + } + + public enum BlendSrcFunc { + ZERO (0), + ONE (1), + DST_COLOR (2), + ONE_MINUS_DST_COLOR (3), + SRC_ALPHA (4), + ONE_MINUS_SRC_ALPHA (5), + DST_ALPHA (6), + ONE_MINUS_DST_ALPA (7), + SRC_ALPHA_SATURATE (8); + + int mID; + BlendSrcFunc(int id) { + mID = id; + } + } + + public enum BlendDstFunc { + ZERO (0), + ONE (1), + SRC_COLOR (2), + ONE_MINUS_SRC_COLOR (3), + SRC_ALPHA (4), + ONE_MINUS_SRC_ALPHA (5), + DST_ALPHA (6), + ONE_MINUS_DST_ALPA (7); + + int mID; + BlendDstFunc(int id) { + mID = id; + } + } + + + ProgramStore(int id, RenderScript rs) { + super(rs); + mID = id; + } + + public void destroy() { + mRS.nProgramFragmentStoreDestroy(mID); + mID = 0; + } + + + + public static class Builder { + RenderScript mRS; + Element mIn; + Element mOut; + DepthFunc mDepthFunc; + boolean mDepthMask; + boolean mColorMaskR; + boolean mColorMaskG; + boolean mColorMaskB; + boolean mColorMaskA; + BlendSrcFunc mBlendSrc; + BlendDstFunc mBlendDst; + boolean mDither; + + + + public Builder(RenderScript rs, Element in, Element out) { + mRS = rs; + mIn = in; + mOut = out; + mDepthFunc = DepthFunc.ALWAYS; + mDepthMask = false; + mColorMaskR = true; + mColorMaskG = true; + mColorMaskB = true; + mColorMaskA = true; + mBlendSrc = BlendSrcFunc.ONE; + mBlendDst = BlendDstFunc.ZERO; + + + } + + public void setDepthFunc(DepthFunc func) { + mDepthFunc = func; + } + + public void setDepthMask(boolean enable) { + mDepthMask = enable; + } + + public void setColorMask(boolean r, boolean g, boolean b, boolean a) { + mColorMaskR = r; + mColorMaskG = g; + mColorMaskB = b; + mColorMaskA = a; + } + + public void setBlendFunc(BlendSrcFunc src, BlendDstFunc dst) { + mBlendSrc = src; + mBlendDst = dst; + } + + public void setDitherEnable(boolean enable) { + mDither = enable; + } + + static synchronized ProgramStore internalCreate(RenderScript rs, Builder b) { + int inID = 0; + int outID = 0; + if (b.mIn != null) { + inID = b.mIn.mID; + } + if (b.mOut != null) { + outID = b.mOut.mID; + } + rs.nProgramFragmentStoreBegin(inID, outID); + rs.nProgramFragmentStoreDepthFunc(b.mDepthFunc.mID); + rs.nProgramFragmentStoreDepthMask(b.mDepthMask); + rs.nProgramFragmentStoreColorMask(b.mColorMaskR, + b.mColorMaskG, + b.mColorMaskB, + b.mColorMaskA); + rs.nProgramFragmentStoreBlendFunc(b.mBlendSrc.mID, b.mBlendDst.mID); + rs.nProgramFragmentStoreDither(b.mDither); + + int id = rs.nProgramFragmentStoreCreate(); + return new ProgramStore(id, rs); + } + + public ProgramStore create() { + return internalCreate(mRS, this); + } + } + +} + + + + diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 365d053..50a4494 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -128,12 +128,13 @@ public class RenderScript { native int nAdapter2DCreate(); native void nScriptDestroy(int script); - native void nScriptBindAllocation(int vtm, int alloc, int slot); + native void nScriptBindAllocation(int script, int alloc, int slot); + native void nScriptSetClearColor(int script, float r, float g, float b, float a); + native void nScriptSetClearDepth(int script, float depth); + native void nScriptSetClearStencil(int script, int stencil); + native void nScriptSetTimeZone(int script, byte[] timeZone); + native void nScriptCBegin(); - native void nScriptCSetClearColor(float r, float g, float b, float a); - native void nScriptCSetClearDepth(float depth); - native void nScriptCSetClearStencil(int stencil); - native void nScriptCSetTimeZone(byte[] timeZone); native void nScriptCAddType(int type); native void nScriptCSetRoot(boolean isRoot); native void nScriptCSetScript(byte[] script, int offset, int length); @@ -203,77 +204,6 @@ public class RenderScript { ////////////////////////////////////////////////////////////////////////////////// // Element - Element.Builder mElementBuilder = new Element.Builder(this); - public Element.Builder elementBuilderCreate() throws IllegalStateException { - mElementBuilder.begin(); - return mElementBuilder; - } - - Type.Builder mTypeBuilder = new Type.Builder(this); - public Type.Builder typeBuilderCreate(Element e) throws IllegalStateException { - mTypeBuilder.begin(e); - return mTypeBuilder; - } - - - public enum DepthFunc { - ALWAYS (0), - LESS (1), - LEQUAL (2), - GREATER (3), - GEQUAL (4), - EQUAL (5), - NOTEQUAL (6); - - int mID; - DepthFunc(int id) { - mID = id; - } - } - - public enum BlendSrcFunc { - ZERO (0), - ONE (1), - DST_COLOR (2), - ONE_MINUS_DST_COLOR (3), - SRC_ALPHA (4), - ONE_MINUS_SRC_ALPHA (5), - DST_ALPHA (6), - ONE_MINUS_DST_ALPA (7), - SRC_ALPHA_SATURATE (8); - - int mID; - BlendSrcFunc(int id) { - mID = id; - } - } - - public enum BlendDstFunc { - ZERO (0), - ONE (1), - SRC_COLOR (2), - ONE_MINUS_SRC_COLOR (3), - SRC_ALPHA (4), - ONE_MINUS_SRC_ALPHA (5), - DST_ALPHA (6), - ONE_MINUS_DST_ALPA (7); - - int mID; - BlendDstFunc(int id) { - mID = id; - } - } - - public enum EnvMode { - REPLACE (0), - MODULATE (1), - DECAL (2); - - int mID; - EnvMode(int id) { - mID = id; - } - } public enum SamplerParam { FILTER_MIN (0), @@ -402,111 +332,9 @@ public class RenderScript { ////////////////////////////////////////////////////////////////////////////////// // ProgramFragmentStore - public class ProgramFragmentStore extends BaseObj { - ProgramFragmentStore(int id) { - super(RenderScript.this); - mID = id; - } - - public void destroy() { - nProgramFragmentStoreDestroy(mID); - mID = 0; - } - } - - public void programFragmentStoreBegin(Element in, Element out) { - int inID = 0; - int outID = 0; - if (in != null) { - inID = in.mID; - } - if (out != null) { - outID = out.mID; - } - nProgramFragmentStoreBegin(inID, outID); - } - - public void programFragmentStoreDepthFunc(DepthFunc func) { - nProgramFragmentStoreDepthFunc(func.mID); - } - - public void programFragmentStoreDepthMask(boolean enable) { - nProgramFragmentStoreDepthMask(enable); - } - - public void programFragmentStoreColorMask(boolean r, boolean g, boolean b, boolean a) { - nProgramFragmentStoreColorMask(r,g,b,a); - } - - public void programFragmentStoreBlendFunc(BlendSrcFunc src, BlendDstFunc dst) { - nProgramFragmentStoreBlendFunc(src.mID, dst.mID); - } - - public void programFragmentStoreDitherEnable(boolean enable) { - nProgramFragmentStoreDither(enable); - } - - public ProgramFragmentStore programFragmentStoreCreate() { - int id = nProgramFragmentStoreCreate(); - return new ProgramFragmentStore(id); - } - ////////////////////////////////////////////////////////////////////////////////// // ProgramFragment - public class ProgramFragment extends BaseObj { - ProgramFragment(int id) { - super(RenderScript.this); - mID = id; - } - - public void destroy() { - nProgramFragmentDestroy(mID); - mID = 0; - } - - public void bindTexture(Allocation va, int slot) { - nProgramFragmentBindTexture(mID, slot, va.mID); - } - - public void bindSampler(Sampler vs, int slot) { - nProgramFragmentBindSampler(mID, slot, vs.mID); - } - } - - public void programFragmentBegin(Element in, Element out) { - int inID = 0; - int outID = 0; - if (in != null) { - inID = in.mID; - } - if (out != null) { - outID = out.mID; - } - nProgramFragmentBegin(inID, outID); - } - - public void programFragmentSetType(int slot, Type t) { - nProgramFragmentSetType(slot, t.mID); - } - - public void programFragmentSetType(int slot, EnvMode t) { - nProgramFragmentSetEnvMode(slot, t.mID); - } - - public void programFragmentSetTexEnable(int slot, boolean enable) { - nProgramFragmentSetTexEnable(slot, enable); - } - - public void programFragmentSetTexEnvMode(int slot, EnvMode env) { - nProgramFragmentSetEnvMode(slot, env.mID); - } - - public ProgramFragment programFragmentCreate() { - int id = nProgramFragmentCreate(); - return new ProgramFragment(id); - } - ////////////////////////////////////////////////////////////////////////////////// // Sampler @@ -617,7 +445,7 @@ public class RenderScript { //nContextBindSampler(s.mID); //} - public void contextBindProgramFragmentStore(ProgramFragmentStore pfs) { + public void contextBindProgramFragmentStore(ProgramStore pfs) { nContextBindProgramFragmentStore(pfs.mID); } diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index e7bb7a5..9696cea 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -37,22 +37,28 @@ public class Script extends BaseObj { } public void setClearColor(float r, float g, float b, float a) { - //mRS.nScriptCSetClearColor(r, g, b, a); + mRS.nScriptSetClearColor(mID, r, g, b, a); } public void setClearDepth(float d) { - //mRS.nScriptCSetClearDepth(d); + mRS.nScriptSetClearDepth(mID, d); } public void setClearStencil(int stencil) { - //mRS.nScriptCSetClearStencil(stencil); + mRS.nScriptSetClearStencil(mID, stencil); } + public void setTimeZone(String timeZone) { + try { + mRS.nScriptSetTimeZone(mID, timeZone.getBytes("UTF-8")); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } public static class Builder { RenderScript mRS; boolean mIsRoot = false; - byte[] mTimeZone; Builder(RenderScript rs) { mRS = rs; @@ -63,9 +69,6 @@ public class Script extends BaseObj { } void transferCreate() { - if(mTimeZone != null) { - mRS.nScriptCSetTimeZone(mTimeZone); - } mRS.nScriptCSetRoot(mIsRoot); } @@ -73,14 +76,6 @@ public class Script extends BaseObj { s.mIsRoot = mIsRoot; } - public void setTimeZone(String timeZone) { - try { - mTimeZone = timeZone.getBytes("UTF-8"); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - public void setRoot(boolean r) { mIsRoot = r; } diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index 86932c4..4078c8a 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -45,23 +45,47 @@ public class Type extends BaseObj { public static class Builder { RenderScript mRS; - boolean mActive = true; + Entry[] mEntries; + int mEntryCount; + Element mElement; - Builder(RenderScript rs) { - mRS = rs; + class Entry { + Dimension mDim; + int mValue; } - public void begin(Element e) { - mRS.nTypeBegin(e.mID); + public Builder(RenderScript rs, Element e) { + mRS = rs; + mEntries = new Entry[4]; + mElement = e; } public void add(Dimension d, int value) { - mRS.nTypeAdd(d.mID, value); + if(mEntries.length >= mEntryCount) { + Entry[] en = new Entry[mEntryCount + 8]; + for(int ct=0; ct < mEntries.length; ct++) { + en[ct] = mEntries[ct]; + } + mEntries = en; + } + mEntries[mEntryCount] = new Entry(); + mEntries[mEntryCount].mDim = d; + mEntries[mEntryCount].mValue = value; + mEntryCount++; + } + + static synchronized Type internalCreate(RenderScript rs, Builder b) { + rs.nTypeBegin(b.mElement.mID); + for (int ct=0; ct < b.mEntryCount; ct++) { + Entry en = b.mEntries[ct]; + rs.nTypeAdd(en.mDim.mID, en.mValue); + } + int id = rs.nTypeCreate(); + return new Type(id, rs); } public Type create() { - int id = mRS.nTypeCreate(); - return new Type(id, mRS); + return internalCreate(mRS, this); } } diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index f5227a0..73380b8 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -647,54 +647,56 @@ nScriptBindAllocation(JNIEnv *_env, jobject _this, jint script, jint alloc, jint } static void -nScriptCBegin(JNIEnv *_env, jobject _this) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCBegin, con(%p)", con); - rsScriptCBegin(); -} - -static void -nScriptCSetClearColor(JNIEnv *_env, jobject _this, jfloat r, jfloat g, jfloat b, jfloat a) +nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearColor, con(%p), r(%f), g(%f), b(%f), a(%f)", con, r, g, b, a); - rsScriptCSetClearColor(r, g, b, a); + LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, script, r, g, b, a); + rsScriptSetClearColor((RsScript)script, r, g, b, a); } static void -nScriptCSetClearDepth(JNIEnv *_env, jobject _this, jfloat d) +nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearDepth, con(%p), depth(%f)", con, d); - rsScriptCSetClearDepth(d); + LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, script, d); + rsScriptSetClearDepth((RsScript)script, d); } static void -nScriptCSetClearStencil(JNIEnv *_env, jobject _this, jint stencil) +nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearStencil, con(%p), stencil(%i)", con, stencil); - rsScriptCSetClearStencil(stencil); + LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, script, stencil); + rsScriptSetClearStencil((RsScript)script, stencil); } static void -nScriptCSetTimeZone(JNIEnv *_env, jobject _this, jbyteArray timeZone) +nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetTimeZone, con(%p), timeZone(%s)", con, timeZone); + LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, script, timeZone); jint length = _env->GetArrayLength(timeZone); jbyte* timeZone_ptr; timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); - rsScriptCSetTimeZone((const char *)timeZone_ptr, length); + rsScriptSetTimeZone((RsScript)script, (const char *)timeZone_ptr, length); if (timeZone_ptr) { _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); } } +// ----------------------------------- + +static void +nScriptCBegin(JNIEnv *_env, jobject _this) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nScriptCBegin, con(%p)", con); + rsScriptCBegin(); +} + static void nScriptCAddType(JNIEnv *_env, jobject _this, jint type) { @@ -1154,11 +1156,12 @@ static JNINativeMethod methods[] = { {"nScriptDestroy", "(I)V", (void*)nScriptDestroy }, {"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation }, +{"nScriptSetClearColor", "(IFFFF)V", (void*)nScriptSetClearColor }, +{"nScriptSetClearDepth", "(IF)V", (void*)nScriptSetClearDepth }, +{"nScriptSetClearStencil", "(II)V", (void*)nScriptSetClearStencil }, +{"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone }, + {"nScriptCBegin", "()V", (void*)nScriptCBegin }, -{"nScriptCSetClearColor", "(FFFF)V", (void*)nScriptCSetClearColor }, -{"nScriptCSetClearDepth", "(F)V", (void*)nScriptCSetClearDepth }, -{"nScriptCSetClearStencil", "(I)V", (void*)nScriptCSetClearStencil }, -{"nScriptCSetTimeZone", "([B)V", (void*)nScriptCSetTimeZone }, {"nScriptCAddType", "(I)V", (void*)nScriptCAddType }, {"nScriptCSetRoot", "(Z)V", (void*)nScriptCSetRoot }, {"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript }, |