From 11c8af9ded3a319635b4e91a639a616ec97fc7e3 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 13 Oct 2010 15:31:10 -0700 Subject: Begin hooking up SurfaceConfig. Change-Id: I328138f29affbed11fcfb5e9ed0872d4ba22d241 --- graphics/java/android/renderscript/RenderScript.java | 19 ++++++++++++++++--- .../java/android/renderscript/RenderScriptGL.java | 17 +++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'graphics/java') diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 0f9ed87..97ce7dc 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -69,9 +69,22 @@ public class RenderScript { // Methods below are wrapped to protect the non-threadsafe // lockless fifo. - native int rsnContextCreateGL(int dev, int ver, boolean useDepth); - synchronized int nContextCreateGL(int dev, int ver, boolean useDepth) { - return rsnContextCreateGL(dev, ver, useDepth); + native int rsnContextCreateGL(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); + 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) { + return rsnContextCreateGL(dev, ver, colorMin, colorPref, + alphaMin, alphaPref, depthMin, depthPref, + stencilMin, stencilPref, + samplesMin, samplesPref, samplesQ); } native int rsnContextCreate(int dev, int ver); synchronized int nContextCreate(int dev, int ver) { diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java index b60c689..0477d75 100644 --- a/graphics/java/android/renderscript/RenderScriptGL.java +++ b/graphics/java/android/renderscript/RenderScriptGL.java @@ -18,6 +18,7 @@ package android.renderscript; import java.lang.reflect.Field; +import android.graphics.PixelFormat; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Config; @@ -103,7 +104,11 @@ public class RenderScriptGL extends RenderScript { SurfaceConfig mSurfaceConfig; public void configureSurface(SurfaceHolder sh) { - //getHolder().setFormat(PixelFormat.TRANSLUCENT); + if (mSurfaceConfig.mAlphaMin > 1) { + sh.setFormat(PixelFormat.RGBA_8888); + } else { + sh.setFormat(PixelFormat.RGBX_8888); + } } public void checkSurface(SurfaceHolder sh) { @@ -112,13 +117,17 @@ public class RenderScriptGL extends RenderScript { public RenderScriptGL(SurfaceConfig sc) { mSurfaceConfig = new SurfaceConfig(sc); - - mSurface = null; mWidth = 0; mHeight = 0; mDev = nDeviceCreate(); - mContext = nContextCreateGL(mDev, 0, mSurfaceConfig.mDepthMin > 0); + 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); mMessageThread = new MessageThread(this); mMessageThread.start(); Element.initPredefined(this); -- cgit v1.1