diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 92ac5737ce125..acc58bc832d44 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -134,9 +134,6 @@ public class RenderScript { native int nAdapter2DCreate(); 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 nScriptInvoke(int id, int slot); native void nScriptInvokeData(int id, int slot); diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index 632a459069a56..4c4071a25f3bd 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -81,21 +81,6 @@ public class Script extends BaseObj { mRS.nScriptSetVarV(mID, index, v.getData()); } - public void setClearColor(float r, float g, float b, float a) { - mRS.validate(); - mRS.nScriptSetClearColor(mID, r, g, b, a); - } - - public void setClearDepth(float d) { - mRS.validate(); - mRS.nScriptSetClearDepth(mID, d); - } - - public void setClearStencil(int stencil) { - mRS.validate(); - mRS.nScriptSetClearStencil(mID, stencil); - } - public void setTimeZone(String timeZone) { mRS.validate(); try { diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 7170e5aeb1718..223ef4bd7e5e0 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -880,29 +880,6 @@ nScriptSetVarV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray d _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } -static void -nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a); - rsScriptSetClearColor(con, (RsScript)script, r, g, b, a); -} - -static void -nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d); - rsScriptSetClearDepth(con, (RsScript)script, d); -} - -static void -nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil); - rsScriptSetClearStencil(con, (RsScript)script, stencil); -} static void nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone) @@ -1410,9 +1387,6 @@ static JNINativeMethod methods[] = { {"nAdapter2DCreate", "()I", (void*)nAdapter2DCreate }, {"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 }, {"nScriptInvoke", "(II)V", (void*)nScriptInvoke }, {"nScriptInvokeData", "(II)V", (void*)nScriptInvokeData }, diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java index e26b051c9a538..93438a0b2c2ec 100644 --- a/libs/rs/java/Film/src/com/android/film/FilmRS.java +++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java @@ -213,13 +213,9 @@ public class FilmRS { Log.e("rs", "Done loading named"); - //mStripPositionType = Type.createFromClass(mRS, StripPosition.class, 1); - ScriptC.Builder sb = new ScriptC.Builder(mRS); sb.setScript(mRes, R.raw.filmstrip); - //sb.setType(mStripPositionType, "Pos", 1); mScriptStrip = sb.create(); - mScriptStrip.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mAllocPos = Allocation.createTyped(mRS, mStripPositionType); diff --git a/libs/rs/java/Fountain/res/raw/fountain.rs b/libs/rs/java/Fountain/res/raw/fountain.rs index 5562a7767b99b..8b6994178e939 100644 --- a/libs/rs/java/Fountain/res/raw/fountain.rs +++ b/libs/rs/java/Fountain/res/raw/fountain.rs @@ -9,7 +9,6 @@ static int newPart = 0; float4 partColor; rs_mesh partMesh; -rs_allocation partBuffer; typedef struct __attribute__((packed, aligned(4))) Point_s { float2 delta; @@ -18,17 +17,13 @@ typedef struct __attribute__((packed, aligned(4))) Point_s { } Point_t; Point_t *point; -#pragma rs export_var(point, partColor, partMesh, partBuffer) -//#pragma rs export_type(Point_s) -//#pragma rs export_element(point) +#pragma rs export_var(point, partColor, partMesh) int root() { - debugPf(1, partColor.x); - debugPi(4, partMesh); - debugPi(5, partBuffer); - - float height = getHeight(); - int size = allocGetDimX(partBuffer); + rsgClearColor(0.f, 0.f, 0.f, 1.f); + float height = rsgGetHeight(); + rs_allocation alloc = rsGetAllocation(point); + int size = rsAllocationGetDimX(alloc); Point_t * p = point; for (int ct=0; ct < size; ct++) { @@ -40,22 +35,31 @@ int root() { p++; } - uploadToBufferObject(partBuffer); - drawSimpleMesh(partMesh); + rsgUploadToBufferObject(alloc); + rsgDrawSimpleMesh(partMesh); return 1; } void addParticles(int rate, int x, int y) { - float rMax = ((float)rate) * 0.005f; - int size = allocGetDimX(partBuffer); + rsDebug("partColor", partColor); + rsDebug("partColor x", partColor.x); + rsDebug("partColor y", partColor.y); + rsDebug("partColor z", partColor.z); + rsDebug("partColor w", partColor.w); - rs_color4u c = convertColorTo8888(partColor.x, partColor.y, partColor.z); + float rMax = ((float)rate) * 0.005f; + int size = rsAllocationGetDimX(rsGetAllocation(point)); + + rs_color4u c = rsPackColorTo8888(partColor.x, partColor.y, partColor.z); Point_t * np = &point[newPart]; float2 p = {x, y}; while (rate--) { - np->delta = vec2Rand(rMax); + float angle = rsRand(3.14f * 2.f); + float len = rsRand(rMax); + np->delta.x = len * sin(angle); + np->delta.y = len * cos(angle); np->pos = p; np->color = c; newPart++; diff --git a/libs/rs/java/Fountain/res/raw/fountain_bc.bc b/libs/rs/java/Fountain/res/raw/fountain_bc.bc index f14706877eaf4..45475faf662e4 100644 Binary files a/libs/rs/java/Fountain/res/raw/fountain_bc.bc and b/libs/rs/java/Fountain/res/raw/fountain_bc.bc differ diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java index d193134c1c05a..ba09a161217a6 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java @@ -77,9 +77,7 @@ public class FountainRS { mSM.bindVertexAllocation(mPoints.getAllocation(), vtxSlot); mScript = new ScriptC_Fountain(mRS, mRes, true); - mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mScript.set_partMesh(mSM); - mScript.set_partBuffer(mPoints.getAllocation()); mScript.bind_point(mPoints); mRS.contextBindRootScript(mScript); } diff --git a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java index 7cff390c9a793..cace1ecbb4562 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java @@ -20,17 +20,14 @@ public class ScriptC_Fountain public void set_partMesh(SimpleMesh v) { setVar(1, v.getID()); } - public void set_partBuffer(Allocation v) { - setVar(2, v.getID()); - } private ScriptField_Point mField_point; public void bind_point(ScriptField_Point f) { mField_point = f; if (f == null) { - bindAllocation(null, 3); + bindAllocation(null, 2); } else { - bindAllocation(f.getAllocation(), 3); + bindAllocation(f.getAllocation(), 2); } } public ScriptField_Point get_point() { diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 4ad25aebaf29e..2a872cd21241a 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -248,13 +248,6 @@ ScriptBindAllocation { ScriptCBegin { } -ScriptSetClearColor { - param RsScript s - param float r - param float g - param float b - param float a - } ScriptSetTimeZone { param RsScript s @@ -262,16 +255,6 @@ ScriptSetTimeZone { param uint32_t length } -ScriptSetClearDepth { - param RsScript s - param float depth - } - -ScriptSetClearStencil { - param RsScript s - param uint32_t stencil - } - ScriptInvoke { param RsScript s diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index da85f83ac60ec..f99e5f217bbe7 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -111,9 +111,6 @@ void Context::initEGL(bool useGL2) LOGE("eglCreateContext returned EGL_NO_CONTEXT"); } gGLContextCount++; - - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); } void Context::deinitEGL() @@ -156,21 +153,7 @@ void Context::checkError(const char *msg) const uint32_t Context::runRootScript() { - timerSet(RS_TIMER_CLEAR_SWAP); - glViewport(0, 0, mWidth, mHeight); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(mRootScript->mEnviroment.mClearColor[0], - mRootScript->mEnviroment.mClearColor[1], - mRootScript->mEnviroment.mClearColor[2], - mRootScript->mEnviroment.mClearColor[3]); - if (mUseDepth) { - glDepthMask(GL_TRUE); - glClearDepthf(mRootScript->mEnviroment.mClearDepth); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } else { - glClear(GL_COLOR_BUFFER_BIT); - } timerSet(RS_TIMER_SCRIPT); mStateFragmentStore.mLast.clear(); @@ -485,8 +468,6 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) checkEglError("eglDestroySurface", ret); mEGL.mSurface = NULL; - mEGL.mWidth = 0; - mEGL.mHeight = 0; mWidth = 0; mHeight = 0; } @@ -514,10 +495,6 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) mStateVertex.updateSize(this); - if ((int)mWidth != mEGL.mWidth || (int)mHeight != mEGL.mHeight) { - LOGE("EGL/Surface mismatch EGL (%i x %i) SF (%i x %i)", mEGL.mWidth, mEGL.mHeight, mWidth, mHeight); - } - if (first) { mGL.mVersion = glGetString(GL_VERSION); mGL.mVendor = glGetString(GL_VENDOR); @@ -762,8 +739,7 @@ void Context::dumpDebug() const LOGE("RS Context debug"); LOGE(" EGL ver %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion); - LOGE(" EGL context %p surface %p, w=%i h=%i Display=%p", mEGL.mContext, - mEGL.mSurface, mEGL.mWidth, mEGL.mHeight, mEGL.mDisplay); + LOGE(" EGL context %p surface %p, Display=%p", mEGL.mContext, mEGL.mSurface, mEGL.mDisplay); LOGE(" GL vendor: %s", mGL.mVendor); LOGE(" GL renderer: %s", mGL.mRenderer); LOGE(" GL Version: %s", mGL.mVersion); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 4a6072d6093af..9df07dc69abd3 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -176,8 +176,6 @@ protected: EGLConfig mConfig; EGLContext mContext; EGLSurface mSurface; - EGLint mWidth; - EGLint mHeight; EGLDisplay mDisplay; } mEGL; diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp index b0bbb22a95a78..fc22fc3f39f71 100644 --- a/libs/rs/rsScript.cpp +++ b/libs/rs/rsScript.cpp @@ -24,12 +24,6 @@ Script::Script(Context *rsc) : ObjectBase(rsc) mAllocFile = __FILE__; mAllocLine = __LINE__; memset(&mEnviroment, 0, sizeof(mEnviroment)); - mEnviroment.mClearColor[0] = 0; - mEnviroment.mClearColor[1] = 0; - mEnviroment.mClearColor[2] = 0; - mEnviroment.mClearColor[3] = 1; - mEnviroment.mClearDepth = 1; - mEnviroment.mClearStencil = 0; } Script::~Script() @@ -61,33 +55,12 @@ void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint3 //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } -void rsi_ScriptSetClearColor(Context * rsc, RsScript vs, float r, float g, float b, float a) -{ - Script *s = static_cast