diff options
Diffstat (limited to 'graphics/java/android')
6 files changed, 38 insertions, 27 deletions
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 970b207..b8327a8 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -144,6 +144,21 @@ public class SurfaceTexture { nativeGetTransformMatrix(mtx); } + /** + * Retrieve the timestamp associated with the texture image set by the most recent call to + * updateTexImage. + * + * This timestamp is in nanoseconds, and is guaranteed to be monotonically increasing. The + * specific meaning and zero point of the timestamp depends on the source providing images to + * the SurfaceTexture. Unless otherwise specified by the image source, timestamps cannot + * generally be compared across SurfaceTexture instances, or across multiple program + * invocations. It is mostly useful for determining time offsets between subsequent frames. + * @hide + */ + public long getTimestamp() { + return nativeGetTimestamp(); + } + protected void finalize() throws Throwable { try { nativeFinalize(); @@ -182,6 +197,7 @@ public class SurfaceTexture { private native void nativeInit(int texName, Object weakSelf); private native void nativeFinalize(); private native void nativeGetTransformMatrix(float[] mtx); + private native long nativeGetTimestamp(); private native void nativeUpdateTexImage(); /* diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index 669beac..8ce1d9a 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -75,11 +75,17 @@ class BaseObj { * @param name The name to assign to the object. */ public void setName(String name) { + if (name == null) { + throw new RSIllegalArgumentException( + "setName requires a string of non-zero length."); + } if(name.length() < 1) { - throw new RSIllegalArgumentException("setName does not accept a zero length string."); + throw new RSIllegalArgumentException( + "setName does not accept a zero length string."); } if(mName != null) { - throw new RSIllegalArgumentException("setName object already has a name."); + throw new RSIllegalArgumentException( + "setName object already has a name."); } try { @@ -106,9 +112,9 @@ class BaseObj { } /** - * destroy disconnects the object from the native object effectivly + * destroy disconnects the object from the native object effectively * rendering this java object dead. The primary use is to force immediate - * cleanup of resources when its believed the GC will not respond quickly + * cleanup of resources when it is believed the GC will not respond quickly * enough. */ synchronized public void destroy() { diff --git a/graphics/java/android/renderscript/Matrix2f.java b/graphics/java/android/renderscript/Matrix2f.java index 78ff97b..acc5bd8 100644 --- a/graphics/java/android/renderscript/Matrix2f.java +++ b/graphics/java/android/renderscript/Matrix2f.java @@ -42,7 +42,7 @@ public class Matrix2f { * floats long */ public Matrix2f(float[] dataArray) { - mMat = new float[2]; + mMat = new float[4]; System.arraycopy(dataArray, 0, mMat, 0, mMat.length); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 1b10c5c..f577532 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -83,17 +83,17 @@ public class RenderScript { int alphaMin, int alphaPref, int depthMin, int depthPref, int stencilMin, int stencilPref, - int samplesMin, int samplesPref, float samplesQ); + int samplesMin, int samplesPref, float samplesQ, int dpi); synchronized int nContextCreateGL(int dev, int ver, int colorMin, int colorPref, int alphaMin, int alphaPref, int depthMin, int depthPref, int stencilMin, int stencilPref, - int samplesMin, int samplesPref, float samplesQ) { + int samplesMin, int samplesPref, float samplesQ, int dpi) { return rsnContextCreateGL(dev, ver, colorMin, colorPref, alphaMin, alphaPref, depthMin, depthPref, stencilMin, stencilPref, - samplesMin, samplesPref, samplesQ); + samplesMin, samplesPref, samplesQ, dpi); } native int rsnContextCreate(int dev, int ver); synchronized int nContextCreate(int dev, int ver) { @@ -457,20 +457,11 @@ public class RenderScript { rsnScriptSetVarObj(mContext, id, slot, val); } - native void rsnScriptCBegin(int con); - synchronized void nScriptCBegin() { + native int rsnScriptCCreate(int con, String resName, String cacheDir, + byte[] script, int length); + synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { validate(); - rsnScriptCBegin(mContext); - } - native void rsnScriptCSetScript(int con, byte[] script, int offset, int length); - synchronized void nScriptCSetScript(byte[] script, int offset, int length) { - validate(); - rsnScriptCSetScript(mContext, script, offset, length); - } - native int rsnScriptCCreate(int con, String packageName, String resName, String cacheDir); - synchronized int nScriptCCreate(String packageName, String resName, String cacheDir) { - validate(); - return rsnScriptCCreate(mContext, packageName, resName, cacheDir); + return rsnScriptCCreate(mContext, resName, cacheDir, script, length); } native void rsnSamplerBegin(int con); diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java index 4359795..d4b5434 100644 --- a/graphics/java/android/renderscript/RenderScriptGL.java +++ b/graphics/java/android/renderscript/RenderScriptGL.java @@ -165,13 +165,14 @@ public class RenderScriptGL extends RenderScript { mWidth = 0; mHeight = 0; mDev = nDeviceCreate(); + int dpi = ctx.getResources().getDisplayMetrics().densityDpi; mContext = nContextCreateGL(mDev, 0, mSurfaceConfig.mColorMin, mSurfaceConfig.mColorPref, mSurfaceConfig.mAlphaMin, mSurfaceConfig.mAlphaPref, mSurfaceConfig.mDepthMin, mSurfaceConfig.mDepthPref, mSurfaceConfig.mStencilMin, mSurfaceConfig.mStencilPref, mSurfaceConfig.mSamplesMin, mSurfaceConfig.mSamplesPref, - mSurfaceConfig.mSamplesQ); + mSurfaceConfig.mSamplesQ, dpi); if (mContext == 0) { throw new RSDriverException("Failed to create RS context."); } diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java index 9445283..f865753 100644 --- a/graphics/java/android/renderscript/ScriptC.java +++ b/graphics/java/android/renderscript/ScriptC.java @@ -92,16 +92,13 @@ public class ScriptC extends Script { throw new Resources.NotFoundException(); } - rs.nScriptCBegin(); - rs.nScriptCSetScript(pgm, 0, pgmLength); - // E.g, /system/apps/Fountain.apk - String packageName = rs.getApplicationContext().getPackageResourcePath(); + //String packageName = rs.getApplicationContext().getPackageResourcePath(); // For res/raw/fountain.bc, it wil be /com.android.fountain:raw/fountain String resName = resources.getResourceName(resourceID); String cacheDir = rs.getApplicationContext().getCacheDir().toString(); Log.v(TAG, "Create script for resource = " + resName); - return rs.nScriptCCreate(packageName, resName, cacheDir); + return rs.nScriptCCreate(resName, cacheDir, pgm, pgmLength); } } |