diff options
author | Jason Sams <rjsams@android.com> | 2009-09-23 13:57:02 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-09-23 13:57:02 -0700 |
commit | ebfb436a49673693b98469683451bd9ede797557 (patch) | |
tree | 62300ba279079ae34c56dc883430afe4b336f7c6 | |
parent | 59038ca98b5f258784687523ee3be11b5dfa995d (diff) | |
download | frameworks_base-ebfb436a49673693b98469683451bd9ede797557.zip frameworks_base-ebfb436a49673693b98469683451bd9ede797557.tar.gz frameworks_base-ebfb436a49673693b98469683451bd9ede797557.tar.bz2 |
Add raster object to control point and line params. Add flag to force SW rendering.
-rw-r--r-- | graphics/java/android/renderscript/ProgramRaster.java | 110 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RSSurfaceView.java | 9 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 15 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 49 | ||||
-rw-r--r-- | libs/rs/Android.mk | 1 | ||||
-rw-r--r-- | libs/rs/RenderScript.h | 7 | ||||
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 2 | ||||
-rw-r--r-- | libs/rs/rs.spec | 22 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 39 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 8 | ||||
-rw-r--r-- | libs/rs/rsDevice.cpp | 11 | ||||
-rw-r--r-- | libs/rs/rsDevice.h | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramRaster.cpp | 137 | ||||
-rw-r--r-- | libs/rs/rsProgramRaster.h | 72 |
14 files changed, 469 insertions, 15 deletions
diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/graphics/java/android/renderscript/ProgramRaster.java new file mode 100644 index 0000000..ab327f1 --- /dev/null +++ b/graphics/java/android/renderscript/ProgramRaster.java @@ -0,0 +1,110 @@ +/* + * 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 ProgramRaster extends BaseObj { + boolean mPointSmooth; + boolean mLineSmooth; + boolean mPointSprite; + float mPointSize; + float mLineWidth; + Element mIn; + Element mOut; + + ProgramRaster(int id, RenderScript rs) { + super(rs); + mID = id; + + mPointSize = 1.0f; + mLineWidth = 1.0f; + mPointSmooth = false; + mLineSmooth = false; + mPointSprite = false; + } + + public void setLineWidth(float w) { + mLineWidth = w; + mRS.nProgramRasterSetLineWidth(mID, w); + } + + public void setPointSize(float s) { + mPointSize = s; + mRS.nProgramRasterSetPointSize(mID, s); + } + + void internalInit() { + int inID = 0; + int outID = 0; + if (mIn != null) { + inID = mIn.mID; + } + if (mOut != null) { + outID = mOut.mID; + } + mID = mRS.nProgramRasterCreate(inID, outID, mPointSmooth, mLineSmooth, mPointSprite); + } + + + public static class Builder { + RenderScript mRS; + ProgramRaster mPR; + + public Builder(RenderScript rs, Element in, Element out) { + mRS = rs; + mPR = new ProgramRaster(0, rs); + } + + public void setPointSpriteEnable(boolean enable) { + mPR.mPointSprite = enable; + } + + public void setPointSmoothEnable(boolean enable) { + mPR.mPointSmooth = enable; + } + + public void setLineSmoothEnable(boolean enable) { + mPR.mLineSmooth = enable; + } + + + static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) { + b.mPR.internalInit(); + ProgramRaster pr = b.mPR; + b.mPR = new ProgramRaster(0, b.mRS); + return pr; + } + + public ProgramRaster create() { + return internalCreate(mRS, this); + } + } + +} + + + + + diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java index a3f1ded..3d6acc9 100644 --- a/graphics/java/android/renderscript/RSSurfaceView.java +++ b/graphics/java/android/renderscript/RSSurfaceView.java @@ -133,14 +133,19 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback // ---------------------------------------------------------------------- - public RenderScript createRenderScript(boolean useDepth) { + public RenderScript createRenderScript(boolean useDepth, boolean forceSW) { Surface sur = null; while ((sur == null) || (mSurfaceHolder == null)) { sur = getHolder().getSurface(); } - RenderScript rs = new RenderScript(sur, useDepth); + RenderScript rs = new RenderScript(sur, useDepth, forceSW); return rs; } + public RenderScript createRenderScript(boolean useDepth) { + return createRenderScript(useDepth, false); + } + + } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 5831d13..1ce7083 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -61,6 +61,7 @@ public class RenderScript { native int nDeviceCreate(); native void nDeviceDestroy(int dev); + native void nDeviceSetConfig(int dev, int param, int value); native int nContextCreate(int dev, Surface sur, int ver, boolean useDepth); native void nContextDestroy(int con); @@ -71,6 +72,7 @@ public class RenderScript { native void nContextBindProgramFragmentStore(int pfs); native void nContextBindProgramFragment(int pf); native void nContextBindProgramVertex(int pf); + native void nContextBindProgramRaster(int pr); native void nContextAddDefineI32(String name, int value); native void nContextAddDefineF(String name, float value); @@ -163,6 +165,10 @@ public class RenderScript { native void nProgramFragmentStoreDither(boolean enable); native int nProgramFragmentStoreCreate(); + native int nProgramRasterCreate(int in, int out, boolean pointSmooth, boolean lineSmooth, boolean pointSprite); + native void nProgramRasterSetLineWidth(int pr, float v); + native void nProgramRasterSetPointSize(int pr, float v); + native void nProgramFragmentBegin(int in, int out, boolean pointSpriteEnable); native void nProgramFragmentBindTexture(int vpf, int slot, int a); native void nProgramFragmentBindSampler(int vpf, int slot, int s); @@ -200,9 +206,12 @@ public class RenderScript { /////////////////////////////////////////////////////////////////////////////////// // - public RenderScript(Surface sur, boolean useDepth) { + public RenderScript(Surface sur, boolean useDepth, boolean forceSW) { mSurface = sur; mDev = nDeviceCreate(); + if(forceSW) { + nDeviceSetConfig(mDev, 0, 1); + } mContext = nContextCreate(mDev, mSurface, 0, useDepth); // TODO: This should be protected by a lock @@ -312,6 +321,10 @@ public class RenderScript { nContextBindProgramFragment(pf.mID); } + public void contextBindProgramRaster(ProgramRaster pf) { + nContextBindProgramRaster(pf.mID); + } + public void contextBindProgramVertex(ProgramVertex pf) { nContextBindProgramVertex(pf.mID); } diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 56a4223..4a8f8a3 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -143,6 +143,13 @@ nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) return rsDeviceDestroy((RsDevice)dev); } +static void +nDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value) +{ + LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); + return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); +} + static jint nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver, jboolean useDepth) { @@ -1132,6 +1139,34 @@ nProgramVertexCreate(JNIEnv *_env, jobject _this) } +// --------------------------------------------------------------------------- + +static jint +nProgramRasterCreate(JNIEnv *_env, jobject _this, jint in, jint out, + jboolean pointSmooth, jboolean lineSmooth, jboolean pointSprite) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nProgramRasterCreate, con(%p), in(%p), out(%p), pointSmooth(%i), lineSmooth(%i), pointSprite(%i)", + con, (RsElement)in, (RsElement)out, pointSmooth, lineSmooth, pointSprite); + return (jint)rsProgramRasterCreate(con, (RsElement)in, (RsElement)out, pointSmooth, lineSmooth, pointSprite); +} + +static void +nProgramRasterSetPointSize(JNIEnv *_env, jobject _this, jint vpr, jfloat v) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nProgramRasterSetPointSize, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v); + rsProgramRasterSetPointSize(con, (RsProgramFragment)vpr, v); +} + +static void +nProgramRasterSetLineWidth(JNIEnv *_env, jobject _this, jint vpr, jfloat v) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nProgramRasterSetLineWidth, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v); + rsProgramRasterSetLineWidth(con, (RsProgramFragment)vpr, v); +} + // --------------------------------------------------------------------------- @@ -1168,6 +1203,14 @@ nContextBindProgramVertex(JNIEnv *_env, jobject _this, jint pf) } static void +nContextBindProgramRaster(JNIEnv *_env, jobject _this, jint pf) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nContextBindProgramRaster, con(%p), pf(%p)", con, (RsProgramRaster)pf); + rsContextBindProgramRaster(con, (RsProgramRaster)pf); +} + +static void nContextAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); @@ -1306,6 +1349,7 @@ static JNINativeMethod methods[] = { {"nDeviceCreate", "()I", (void*)nDeviceCreate }, {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, +{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, {"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate }, {"nContextDestroy", "(I)V", (void*)nContextDestroy }, {"nAssignName", "(I[B)V", (void*)nAssignName }, @@ -1396,6 +1440,10 @@ static JNINativeMethod methods[] = { {"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot }, {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, +{"nProgramRasterCreate", "(IIZZZ)I", (void*)nProgramRasterCreate }, +{"nProgramRasterSetPointSize", "(IF)V", (void*)nProgramRasterSetPointSize }, +{"nProgramRasterSetLineWidth", "(IF)V", (void*)nProgramRasterSetLineWidth }, + {"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation }, {"nProgramVertexBegin", "(II)V", (void*)nProgramVertexBegin }, {"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable }, @@ -1413,6 +1461,7 @@ static JNINativeMethod methods[] = { {"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore }, {"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment }, {"nContextBindProgramVertex", "(I)V", (void*)nContextBindProgramVertex }, +{"nContextBindProgramRaster", "(I)V", (void*)nContextBindProgramRaster }, {"nSamplerBegin", "()V", (void*)nSamplerBegin }, {"nSamplerSet", "(II)V", (void*)nSamplerSet }, diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index bc466be..2c17599 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -90,6 +90,7 @@ LOCAL_SRC_FILES:= \ rsProgram.cpp \ rsProgramFragment.cpp \ rsProgramFragmentStore.cpp \ + rsProgramRaster.cpp \ rsProgramVertex.cpp \ rsSampler.cpp \ rsScript.cpp \ diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index 1e24cd2..9f18b78 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -45,9 +45,16 @@ typedef void * RsLight; typedef void * RsProgramVertex; typedef void * RsProgramFragment; typedef void * RsProgramFragmentStore; +typedef void * RsProgramRaster; + +enum RsDeviceParam { + RS_DEVICE_PARAM_FORCE_SOFTWARE_GL, + RS_DEVICE_PARAM_COUNT +}; RsDevice rsDeviceCreate(); void rsDeviceDestroy(RsDevice); +void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value); RsContext rsContextCreate(RsDevice, void *, uint32_t version, bool useDepth); void rsContextDestroy(RsContext); diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java index 7826161..1b07f98 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -52,7 +52,7 @@ public class FountainView extends RSSurfaceView { public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { super.surfaceChanged(holder, format, w, h); - mRS = createRenderScript(false); + mRS = createRenderScript(false, true); mRender = new FountainRS(); mRender.init(mRS, getResources(), w, h); } diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 87ad97c..d7ae532 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -16,6 +16,10 @@ ContextBindProgramVertex { param RsProgramVertex pgm } +ContextBindProgramRaster { + param RsProgramRaster pgm + } + ContextSetDefineF { param const char* name param float value @@ -369,6 +373,24 @@ ProgramFragmentStoreCreate { ret RsProgramFragmentStore } +ProgramRasterCreate { + param RsElement in + param RsElement out + param bool pointSmooth + param bool lineSmooth + param bool pointSprite + ret RsProgramRaster +} + +ProgramRasterSetLineWidth { + param RsProgramRaster pr + param float lw +} + +ProgramRasterSetPointSize{ + param RsProgramRaster pr + param float ps +} ProgramFragmentBegin { diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 3e4c9af..ab8d065 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -46,6 +46,12 @@ void Context::initEGL() configAttribsPtr += 2; } + if (mDev->mForceSW) { + configAttribsPtr[0] = EGL_CONFIG_CAVEAT; + configAttribsPtr[1] = EGL_SLOW_CONFIG; + configAttribsPtr += 2; + } + configAttribsPtr[0] = EGL_NONE; rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint)))); @@ -116,7 +122,7 @@ bool Context::runRootScript() eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); glViewport(0, 0, mEGL.mWidth, mEGL.mHeight); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glEnable(GL_POINT_SMOOTH); + //glEnable(GL_POINT_SMOOTH); glClearColor(mRootScript->mEnviroment.mClearColor[0], mRootScript->mEnviroment.mClearColor[1], @@ -192,16 +198,10 @@ void Context::timerPrint() void Context::setupCheck() { - if (mFragmentStore.get()) { - mFragmentStore->setupGL(this, &mStateFragmentStore); - } - if (mFragment.get()) { - mFragment->setupGL(this, &mStateFragment); - } - if (mVertex.get()) { - mVertex->setupGL(this, &mStateVertex); - } - + mFragmentStore->setupGL(this, &mStateFragmentStore); + mFragment->setupGL(this, &mStateFragment); + mRaster->setupGL(this, &mStateRaster); + mVertex->setupGL(this, &mStateVertex); } @@ -223,6 +223,8 @@ void * Context::threadProc(void *vrsc) LOGE("pthread_setspecific %i", status); } + rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); + rsc->setRaster(NULL); rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); rsc->setVertex(NULL); rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); @@ -350,6 +352,15 @@ void Context::setFragment(ProgramFragment *pf) } } +void Context::setRaster(ProgramRaster *pr) +{ + if (pr == NULL) { + mRaster.set(mStateRaster.mDefault); + } else { + mRaster.set(pr); + } +} + void Context::allocationCheck(const Allocation *a) { mVertex->checkUpdatedAllocation(a); @@ -519,6 +530,12 @@ void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf) rsc->setFragment(pf); } +void rsi_ContextBindProgramRaster(Context *rsc, RsProgramRaster vpr) +{ + ProgramRaster *pr = static_cast<ProgramRaster *>(vpr); + rsc->setRaster(pr); +} + void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) { ProgramVertex *pv = static_cast<ProgramVertex *>(vpv); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 634416b..3e07f3e 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -36,6 +36,7 @@ #include "rsLight.h" #include "rsProgramFragment.h" #include "rsProgramFragmentStore.h" +#include "rsProgramRaster.h" #include "rsProgramVertex.h" #include "rsgApiStructs.h" @@ -65,6 +66,7 @@ public: SamplerState mStateSampler; ProgramFragmentState mStateFragment; ProgramFragmentStoreState mStateFragmentStore; + ProgramRasterState mStateRaster; ProgramVertexState mStateVertex; LightState mStateLight; @@ -74,6 +76,7 @@ public: void swapBuffers(); void setRootScript(Script *); + void setRaster(ProgramRaster *); void setVertex(ProgramVertex *); void setFragment(ProgramFragment *); void setFragmentStore(ProgramFragmentStore *); @@ -82,6 +85,7 @@ public: const ProgramFragment * getFragment() {return mFragment.get();} const ProgramFragmentStore * getFragmentStore() {return mFragmentStore.get();} + const ProgramRaster * getRaster() {return mRaster.get();} const ProgramVertex * getVertex() {return mVertex.get();} void setupCheck(); @@ -102,6 +106,9 @@ public: ProgramFragmentStore * getDefaultProgramFragmentStore() const { return mStateFragmentStore.mDefault.get(); } + ProgramRaster * getDefaultProgramRaster() const { + return mStateRaster.mDefault.get(); + } void addInt32Define(const char* name, int32_t value) { mInt32Defines.add(String8(name), value); @@ -172,6 +179,7 @@ protected: ObjectBaseRef<ProgramFragment> mFragment; ObjectBaseRef<ProgramVertex> mVertex; ObjectBaseRef<ProgramFragmentStore> mFragmentStore; + ObjectBaseRef<ProgramRaster> mRaster; struct ObjDestroyOOB { diff --git a/libs/rs/rsDevice.cpp b/libs/rs/rsDevice.cpp index 1b3c41b..b670ad4 100644 --- a/libs/rs/rsDevice.cpp +++ b/libs/rs/rsDevice.cpp @@ -22,6 +22,7 @@ using namespace android::renderscript; Device::Device() { + mForceSW = false; } @@ -60,3 +61,13 @@ void rsDeviceDestroy(RsDevice dev) } +void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) +{ + Device * d = static_cast<Device *>(dev); + if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) { + d->mForceSW = value != 0; + return; + } + rsAssert(0); +} + diff --git a/libs/rs/rsDevice.h b/libs/rs/rsDevice.h index 156315f..a8a4e77 100644 --- a/libs/rs/rsDevice.h +++ b/libs/rs/rsDevice.h @@ -33,6 +33,8 @@ public: void addContext(Context *); void removeContext(Context *); + bool mForceSW; + protected: Vector<Context *> mContexts; diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp new file mode 100644 index 0000000..0f5ec51 --- /dev/null +++ b/libs/rs/rsProgramRaster.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2009 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. + */ + +#include "rsContext.h" +#include "rsProgramRaster.h" + +#include <GLES/gl.h> +#include <GLES/glext.h> + +using namespace android; +using namespace android::renderscript; + + +ProgramRaster::ProgramRaster(Element *in, + Element *out, + bool pointSmooth, + bool lineSmooth, + bool pointSprite) : + Program(in, out) +{ + mPointSmooth = pointSmooth; + mLineSmooth = lineSmooth; + mPointSprite = pointSprite; + + mPointSize = 1.0f; + mLineWidth = 1.0f; +} + +ProgramRaster::~ProgramRaster() +{ +} + +void ProgramRaster::setLineWidth(float s) +{ + mLineWidth = s; +} + +void ProgramRaster::setPointSize(float s) +{ + mPointSize = s; +} + +void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state) +{ + if (state->mLast.get() == this) { + return; + } + state->mLast.set(this); + + LOGE("setup %i %i %i %f %f", mPointSmooth, mLineSmooth, mPointSprite, mPointSize, mLineWidth); + + glPointSize(mPointSize); + if (mPointSmooth) { + glEnable(GL_POINT_SMOOTH); + } else { + glDisable(GL_POINT_SMOOTH); + } + + glLineWidth(mLineWidth); + if (mLineSmooth) { + glEnable(GL_LINE_SMOOTH); + } else { + glEnable(GL_LINE_SMOOTH); + } + + if (rsc->checkVersion1_1()) { + if (mPointSprite) { + glEnable(GL_POINT_SPRITE_OES); + } else { + glDisable(GL_POINT_SPRITE_OES); + } + } +} + + + +ProgramRasterState::ProgramRasterState() +{ +} + +ProgramRasterState::~ProgramRasterState() +{ +} + +void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h) +{ + ProgramRaster *pr = new ProgramRaster(NULL, NULL, false, false, false); + mDefault.set(pr); +} + + +namespace android { +namespace renderscript { + +RsProgramRaster rsi_ProgramRasterCreate(Context * rsc, RsElement in, RsElement out, + bool pointSmooth, + bool lineSmooth, + bool pointSprite) +{ + ProgramRaster *pr = new ProgramRaster(static_cast<Element *>(in), + static_cast<Element *>(out), + pointSmooth, + lineSmooth, + pointSprite); + pr->incUserRef(); + return pr; +} + +void rsi_ProgramRasterSetPointSize(Context * rsc, RsProgramRaster vpr, float s) +{ + ProgramRaster *pr = static_cast<ProgramRaster *>(vpr); + pr->setPointSize(s); +} + +void rsi_ProgramRasterSetLineWidth(Context * rsc, RsProgramRaster vpr, float s) +{ + ProgramRaster *pr = static_cast<ProgramRaster *>(vpr); + pr->setLineWidth(s); +} + + +} +} + diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h new file mode 100644 index 0000000..5984868 --- /dev/null +++ b/libs/rs/rsProgramRaster.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 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. + */ + +#ifndef ANDROID_RS_PROGRAM_RASTER_H +#define ANDROID_RS_PROGRAM_RASTER_H + +#include "rsProgram.h" + +// --------------------------------------------------------------------------- +namespace android { +namespace renderscript { + +class ProgramRasterState; + +class ProgramRaster : public Program +{ +public: + ProgramRaster(Element *in, + Element *out, + bool pointSmooth, + bool lineSmooth, + bool pointSprite); + virtual ~ProgramRaster(); + + virtual void setupGL(const Context *, ProgramRasterState *); + + void setLineWidth(float w); + void setPointSize(float s); + +protected: + bool mPointSmooth; + bool mLineSmooth; + bool mPointSprite; + + float mPointSize; + float mLineWidth; + + +}; + +class ProgramRasterState +{ +public: + ProgramRasterState(); + ~ProgramRasterState(); + void init(Context *rsc, int32_t w, int32_t h); + + ObjectBaseRef<ProgramRaster> mDefault; + ObjectBaseRef<ProgramRaster> mLast; +}; + + +} +} +#endif + + + + |