Merge change 26667 into eclair
* changes: Add raster object to control point and line params. Add flag to force SW rendering.
This commit is contained in:
110
graphics/java/android/renderscript/ProgramRaster.java
Normal file
110
graphics/java/android/renderscript/ProgramRaster.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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;
|
Surface sur = null;
|
||||||
while ((sur == null) || (mSurfaceHolder == null)) {
|
while ((sur == null) || (mSurfaceHolder == null)) {
|
||||||
sur = getHolder().getSurface();
|
sur = getHolder().getSurface();
|
||||||
}
|
}
|
||||||
RenderScript rs = new RenderScript(sur, useDepth);
|
RenderScript rs = new RenderScript(sur, useDepth, forceSW);
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RenderScript createRenderScript(boolean useDepth) {
|
||||||
|
return createRenderScript(useDepth, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class RenderScript {
|
|||||||
|
|
||||||
native int nDeviceCreate();
|
native int nDeviceCreate();
|
||||||
native void nDeviceDestroy(int dev);
|
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 int nContextCreate(int dev, Surface sur, int ver, boolean useDepth);
|
||||||
native void nContextDestroy(int con);
|
native void nContextDestroy(int con);
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ public class RenderScript {
|
|||||||
native void nContextBindProgramFragmentStore(int pfs);
|
native void nContextBindProgramFragmentStore(int pfs);
|
||||||
native void nContextBindProgramFragment(int pf);
|
native void nContextBindProgramFragment(int pf);
|
||||||
native void nContextBindProgramVertex(int pf);
|
native void nContextBindProgramVertex(int pf);
|
||||||
|
native void nContextBindProgramRaster(int pr);
|
||||||
native void nContextAddDefineI32(String name, int value);
|
native void nContextAddDefineI32(String name, int value);
|
||||||
native void nContextAddDefineF(String name, float value);
|
native void nContextAddDefineF(String name, float value);
|
||||||
|
|
||||||
@@ -163,6 +165,10 @@ public class RenderScript {
|
|||||||
native void nProgramFragmentStoreDither(boolean enable);
|
native void nProgramFragmentStoreDither(boolean enable);
|
||||||
native int nProgramFragmentStoreCreate();
|
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 nProgramFragmentBegin(int in, int out, boolean pointSpriteEnable);
|
||||||
native void nProgramFragmentBindTexture(int vpf, int slot, int a);
|
native void nProgramFragmentBindTexture(int vpf, int slot, int a);
|
||||||
native void nProgramFragmentBindSampler(int vpf, int slot, int s);
|
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;
|
mSurface = sur;
|
||||||
mDev = nDeviceCreate();
|
mDev = nDeviceCreate();
|
||||||
|
if(forceSW) {
|
||||||
|
nDeviceSetConfig(mDev, 0, 1);
|
||||||
|
}
|
||||||
mContext = nContextCreate(mDev, mSurface, 0, useDepth);
|
mContext = nContextCreate(mDev, mSurface, 0, useDepth);
|
||||||
|
|
||||||
// TODO: This should be protected by a lock
|
// TODO: This should be protected by a lock
|
||||||
@@ -312,6 +321,10 @@ public class RenderScript {
|
|||||||
nContextBindProgramFragment(pf.mID);
|
nContextBindProgramFragment(pf.mID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void contextBindProgramRaster(ProgramRaster pf) {
|
||||||
|
nContextBindProgramRaster(pf.mID);
|
||||||
|
}
|
||||||
|
|
||||||
public void contextBindProgramVertex(ProgramVertex pf) {
|
public void contextBindProgramVertex(ProgramVertex pf) {
|
||||||
nContextBindProgramVertex(pf.mID);
|
nContextBindProgramVertex(pf.mID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,13 @@ nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev)
|
|||||||
return rsDeviceDestroy((RsDevice)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
|
static jint
|
||||||
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver, jboolean useDepth)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1167,6 +1202,14 @@ nContextBindProgramVertex(JNIEnv *_env, jobject _this, jint pf)
|
|||||||
rsContextBindProgramVertex(con, (RsProgramVertex)pf);
|
rsContextBindProgramVertex(con, (RsProgramVertex)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
|
static void
|
||||||
nContextAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value)
|
nContextAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value)
|
||||||
{
|
{
|
||||||
@@ -1306,6 +1349,7 @@ static JNINativeMethod methods[] = {
|
|||||||
|
|
||||||
{"nDeviceCreate", "()I", (void*)nDeviceCreate },
|
{"nDeviceCreate", "()I", (void*)nDeviceCreate },
|
||||||
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
|
||||||
|
{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
|
||||||
{"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate },
|
{"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate },
|
||||||
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
|
||||||
{"nAssignName", "(I[B)V", (void*)nAssignName },
|
{"nAssignName", "(I[B)V", (void*)nAssignName },
|
||||||
@@ -1396,6 +1440,10 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot },
|
{"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot },
|
||||||
{"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate },
|
{"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate },
|
||||||
|
|
||||||
|
{"nProgramRasterCreate", "(IIZZZ)I", (void*)nProgramRasterCreate },
|
||||||
|
{"nProgramRasterSetPointSize", "(IF)V", (void*)nProgramRasterSetPointSize },
|
||||||
|
{"nProgramRasterSetLineWidth", "(IF)V", (void*)nProgramRasterSetLineWidth },
|
||||||
|
|
||||||
{"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation },
|
{"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation },
|
||||||
{"nProgramVertexBegin", "(II)V", (void*)nProgramVertexBegin },
|
{"nProgramVertexBegin", "(II)V", (void*)nProgramVertexBegin },
|
||||||
{"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable },
|
{"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable },
|
||||||
@@ -1413,6 +1461,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore },
|
{"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore },
|
||||||
{"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment },
|
{"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment },
|
||||||
{"nContextBindProgramVertex", "(I)V", (void*)nContextBindProgramVertex },
|
{"nContextBindProgramVertex", "(I)V", (void*)nContextBindProgramVertex },
|
||||||
|
{"nContextBindProgramRaster", "(I)V", (void*)nContextBindProgramRaster },
|
||||||
|
|
||||||
{"nSamplerBegin", "()V", (void*)nSamplerBegin },
|
{"nSamplerBegin", "()V", (void*)nSamplerBegin },
|
||||||
{"nSamplerSet", "(II)V", (void*)nSamplerSet },
|
{"nSamplerSet", "(II)V", (void*)nSamplerSet },
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ LOCAL_SRC_FILES:= \
|
|||||||
rsProgram.cpp \
|
rsProgram.cpp \
|
||||||
rsProgramFragment.cpp \
|
rsProgramFragment.cpp \
|
||||||
rsProgramFragmentStore.cpp \
|
rsProgramFragmentStore.cpp \
|
||||||
|
rsProgramRaster.cpp \
|
||||||
rsProgramVertex.cpp \
|
rsProgramVertex.cpp \
|
||||||
rsSampler.cpp \
|
rsSampler.cpp \
|
||||||
rsScript.cpp \
|
rsScript.cpp \
|
||||||
|
|||||||
@@ -45,9 +45,16 @@ typedef void * RsLight;
|
|||||||
typedef void * RsProgramVertex;
|
typedef void * RsProgramVertex;
|
||||||
typedef void * RsProgramFragment;
|
typedef void * RsProgramFragment;
|
||||||
typedef void * RsProgramFragmentStore;
|
typedef void * RsProgramFragmentStore;
|
||||||
|
typedef void * RsProgramRaster;
|
||||||
|
|
||||||
|
enum RsDeviceParam {
|
||||||
|
RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
|
||||||
|
RS_DEVICE_PARAM_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
RsDevice rsDeviceCreate();
|
RsDevice rsDeviceCreate();
|
||||||
void rsDeviceDestroy(RsDevice);
|
void rsDeviceDestroy(RsDevice);
|
||||||
|
void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value);
|
||||||
|
|
||||||
RsContext rsContextCreate(RsDevice, void *, uint32_t version, bool useDepth);
|
RsContext rsContextCreate(RsDevice, void *, uint32_t version, bool useDepth);
|
||||||
void rsContextDestroy(RsContext);
|
void rsContextDestroy(RsContext);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class FountainView extends RSSurfaceView {
|
|||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
mRS = createRenderScript(false);
|
mRS = createRenderScript(false, true);
|
||||||
mRender = new FountainRS();
|
mRender = new FountainRS();
|
||||||
mRender.init(mRS, getResources(), w, h);
|
mRender.init(mRS, getResources(), w, h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ ContextBindProgramVertex {
|
|||||||
param RsProgramVertex pgm
|
param RsProgramVertex pgm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContextBindProgramRaster {
|
||||||
|
param RsProgramRaster pgm
|
||||||
|
}
|
||||||
|
|
||||||
ContextSetDefineF {
|
ContextSetDefineF {
|
||||||
param const char* name
|
param const char* name
|
||||||
param float value
|
param float value
|
||||||
@@ -369,6 +373,24 @@ ProgramFragmentStoreCreate {
|
|||||||
ret RsProgramFragmentStore
|
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 {
|
ProgramFragmentBegin {
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ void Context::initEGL()
|
|||||||
configAttribsPtr += 2;
|
configAttribsPtr += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDev->mForceSW) {
|
||||||
|
configAttribsPtr[0] = EGL_CONFIG_CAVEAT;
|
||||||
|
configAttribsPtr[1] = EGL_SLOW_CONFIG;
|
||||||
|
configAttribsPtr += 2;
|
||||||
|
}
|
||||||
|
|
||||||
configAttribsPtr[0] = EGL_NONE;
|
configAttribsPtr[0] = EGL_NONE;
|
||||||
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
|
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
|
||||||
|
|
||||||
@@ -116,7 +122,7 @@ bool Context::runRootScript()
|
|||||||
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
||||||
glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
|
glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
//glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
glClearColor(mRootScript->mEnviroment.mClearColor[0],
|
glClearColor(mRootScript->mEnviroment.mClearColor[0],
|
||||||
mRootScript->mEnviroment.mClearColor[1],
|
mRootScript->mEnviroment.mClearColor[1],
|
||||||
@@ -192,16 +198,10 @@ void Context::timerPrint()
|
|||||||
|
|
||||||
void Context::setupCheck()
|
void Context::setupCheck()
|
||||||
{
|
{
|
||||||
if (mFragmentStore.get()) {
|
mFragmentStore->setupGL(this, &mStateFragmentStore);
|
||||||
mFragmentStore->setupGL(this, &mStateFragmentStore);
|
mFragment->setupGL(this, &mStateFragment);
|
||||||
}
|
mRaster->setupGL(this, &mStateRaster);
|
||||||
if (mFragment.get()) {
|
mVertex->setupGL(this, &mStateVertex);
|
||||||
mFragment->setupGL(this, &mStateFragment);
|
|
||||||
}
|
|
||||||
if (mVertex.get()) {
|
|
||||||
mVertex->setupGL(this, &mStateVertex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -223,6 +223,8 @@ void * Context::threadProc(void *vrsc)
|
|||||||
LOGE("pthread_setspecific %i", status);
|
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->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
|
||||||
rsc->setVertex(NULL);
|
rsc->setVertex(NULL);
|
||||||
rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
|
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)
|
void Context::allocationCheck(const Allocation *a)
|
||||||
{
|
{
|
||||||
mVertex->checkUpdatedAllocation(a);
|
mVertex->checkUpdatedAllocation(a);
|
||||||
@@ -519,6 +530,12 @@ void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf)
|
|||||||
rsc->setFragment(pf);
|
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)
|
void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv)
|
||||||
{
|
{
|
||||||
ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
|
ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "rsLight.h"
|
#include "rsLight.h"
|
||||||
#include "rsProgramFragment.h"
|
#include "rsProgramFragment.h"
|
||||||
#include "rsProgramFragmentStore.h"
|
#include "rsProgramFragmentStore.h"
|
||||||
|
#include "rsProgramRaster.h"
|
||||||
#include "rsProgramVertex.h"
|
#include "rsProgramVertex.h"
|
||||||
|
|
||||||
#include "rsgApiStructs.h"
|
#include "rsgApiStructs.h"
|
||||||
@@ -65,6 +66,7 @@ public:
|
|||||||
SamplerState mStateSampler;
|
SamplerState mStateSampler;
|
||||||
ProgramFragmentState mStateFragment;
|
ProgramFragmentState mStateFragment;
|
||||||
ProgramFragmentStoreState mStateFragmentStore;
|
ProgramFragmentStoreState mStateFragmentStore;
|
||||||
|
ProgramRasterState mStateRaster;
|
||||||
ProgramVertexState mStateVertex;
|
ProgramVertexState mStateVertex;
|
||||||
LightState mStateLight;
|
LightState mStateLight;
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ public:
|
|||||||
|
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
void setRootScript(Script *);
|
void setRootScript(Script *);
|
||||||
|
void setRaster(ProgramRaster *);
|
||||||
void setVertex(ProgramVertex *);
|
void setVertex(ProgramVertex *);
|
||||||
void setFragment(ProgramFragment *);
|
void setFragment(ProgramFragment *);
|
||||||
void setFragmentStore(ProgramFragmentStore *);
|
void setFragmentStore(ProgramFragmentStore *);
|
||||||
@@ -82,6 +85,7 @@ public:
|
|||||||
|
|
||||||
const ProgramFragment * getFragment() {return mFragment.get();}
|
const ProgramFragment * getFragment() {return mFragment.get();}
|
||||||
const ProgramFragmentStore * getFragmentStore() {return mFragmentStore.get();}
|
const ProgramFragmentStore * getFragmentStore() {return mFragmentStore.get();}
|
||||||
|
const ProgramRaster * getRaster() {return mRaster.get();}
|
||||||
const ProgramVertex * getVertex() {return mVertex.get();}
|
const ProgramVertex * getVertex() {return mVertex.get();}
|
||||||
|
|
||||||
void setupCheck();
|
void setupCheck();
|
||||||
@@ -102,6 +106,9 @@ public:
|
|||||||
ProgramFragmentStore * getDefaultProgramFragmentStore() const {
|
ProgramFragmentStore * getDefaultProgramFragmentStore() const {
|
||||||
return mStateFragmentStore.mDefault.get();
|
return mStateFragmentStore.mDefault.get();
|
||||||
}
|
}
|
||||||
|
ProgramRaster * getDefaultProgramRaster() const {
|
||||||
|
return mStateRaster.mDefault.get();
|
||||||
|
}
|
||||||
|
|
||||||
void addInt32Define(const char* name, int32_t value) {
|
void addInt32Define(const char* name, int32_t value) {
|
||||||
mInt32Defines.add(String8(name), value);
|
mInt32Defines.add(String8(name), value);
|
||||||
@@ -172,6 +179,7 @@ protected:
|
|||||||
ObjectBaseRef<ProgramFragment> mFragment;
|
ObjectBaseRef<ProgramFragment> mFragment;
|
||||||
ObjectBaseRef<ProgramVertex> mVertex;
|
ObjectBaseRef<ProgramVertex> mVertex;
|
||||||
ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
|
ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
|
||||||
|
ObjectBaseRef<ProgramRaster> mRaster;
|
||||||
|
|
||||||
|
|
||||||
struct ObjDestroyOOB {
|
struct ObjDestroyOOB {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using namespace android::renderscript;
|
|||||||
|
|
||||||
Device::Device()
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public:
|
|||||||
void addContext(Context *);
|
void addContext(Context *);
|
||||||
void removeContext(Context *);
|
void removeContext(Context *);
|
||||||
|
|
||||||
|
bool mForceSW;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Vector<Context *> mContexts;
|
Vector<Context *> mContexts;
|
||||||
|
|
||||||
|
|||||||
137
libs/rs/rsProgramRaster.cpp
Normal file
137
libs/rs/rsProgramRaster.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
72
libs/rs/rsProgramRaster.h
Normal file
72
libs/rs/rsProgramRaster.h
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user