summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-09-23 13:57:02 -0700
committerJason Sams <rjsams@android.com>2009-09-23 13:57:02 -0700
commitebfb436a49673693b98469683451bd9ede797557 (patch)
tree62300ba279079ae34c56dc883430afe4b336f7c6 /graphics/java
parent59038ca98b5f258784687523ee3be11b5dfa995d (diff)
downloadframeworks_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.
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/renderscript/ProgramRaster.java110
-rw-r--r--graphics/java/android/renderscript/RSSurfaceView.java9
-rw-r--r--graphics/java/android/renderscript/RenderScript.java15
3 files changed, 131 insertions, 3 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);
}