summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/glrenderer/GLCanvas.java31
-rw-r--r--src/com/android/gallery3d/glrenderer/GLES11Canvas.java28
-rw-r--r--src/com/android/gallery3d/glrenderer/GLES20Canvas.java27
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java9
-rw-r--r--src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java158
-rw-r--r--tests/src/com/android/gallery3d/ui/GLCanvasStub.java15
6 files changed, 5 insertions, 263 deletions
diff --git a/src/com/android/gallery3d/glrenderer/GLCanvas.java b/src/com/android/gallery3d/glrenderer/GLCanvas.java
index 941002e..305e905 100644
--- a/src/com/android/gallery3d/glrenderer/GLCanvas.java
+++ b/src/com/android/gallery3d/glrenderer/GLCanvas.java
@@ -197,37 +197,6 @@ public interface GLCanvas {
public abstract int uploadBuffer(java.nio.ByteBuffer buffer);
/**
- * Enable stencil test
- */
- public abstract void enableStencil();
-
- /**
- * Disable stencil.
- */
- public abstract void disableStencil();
-
- /**
- * Clears the stencil so that a new stencil can be generated.
- */
- public abstract void clearStencilBuffer();
-
- /**
- * Start/stop updating the stencil buffer.
- *
- * @param update True if the stencil should be updated, false otherwise.
- */
- public abstract void updateStencil(boolean update);
-
- /**
- * Changes how the stencil buffer is used.
- *
- * @param onlyOutside If true, only the area outside the stencil can be
- * changed. If false, the area inside the stencil can be drawn to
- * as well.
- */
- public abstract void drawOnlyOutsideStencil(boolean onlyOutside);
-
- /**
* After LightCycle makes GL calls, this method is called to restore the GL
* configuration to the one expected by GLCanvas.
*/
diff --git a/src/com/android/gallery3d/glrenderer/GLES11Canvas.java b/src/com/android/gallery3d/glrenderer/GLES11Canvas.java
index efb9d80..7013c3d 100644
--- a/src/com/android/gallery3d/glrenderer/GLES11Canvas.java
+++ b/src/com/android/gallery3d/glrenderer/GLES11Canvas.java
@@ -612,7 +612,6 @@ public class GLES11Canvas implements GLCanvas {
// Set the background color
gl.glClearColor(0f, 0f, 0f, 0f);
- gl.glClearStencil(0);
gl.glEnable(GL11.GL_BLEND);
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -982,33 +981,6 @@ public class GLES11Canvas implements GLCanvas {
}
@Override
- public void enableStencil() {
- mGL.glEnable(GL11.GL_STENCIL_TEST);
- }
-
- @Override
- public void disableStencil() {
- mGL.glDisable(GL11.GL_STENCIL_TEST);
- }
-
- @Override
- public void clearStencilBuffer() {
- mGL.glClear(GL11.GL_STENCIL_BUFFER_BIT);
- }
-
- @Override
- public void updateStencil(boolean update) {
- int passOp = update ? GL11.GL_REPLACE : GL11.GL_KEEP;
- mGL.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, passOp);
- }
-
- @Override
- public void drawOnlyOutsideStencil(boolean onlyOutside) {
- int func = onlyOutside ? GL11.GL_NOTEQUAL : GL11.GL_ALWAYS;
- mGL.glStencilFunc(func, 1, 1);
- }
-
- @Override
public void recoverFromLightCycle() {
// This is only required for GLES20
}
diff --git a/src/com/android/gallery3d/glrenderer/GLES20Canvas.java b/src/com/android/gallery3d/glrenderer/GLES20Canvas.java
index 28b72ec..4ead131 100644
--- a/src/com/android/gallery3d/glrenderer/GLES20Canvas.java
+++ b/src/com/android/gallery3d/glrenderer/GLES20Canvas.java
@@ -960,33 +960,6 @@ public class GLES20Canvas implements GLCanvas {
return bufferId;
}
- @Override
- public void enableStencil() {
- GLES20.glEnable(GLES20.GL_STENCIL_TEST);
- }
-
- @Override
- public void disableStencil() {
- GLES20.glDisable(GLES20.GL_STENCIL_TEST);
- }
-
- @Override
- public void clearStencilBuffer() {
- GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
- }
-
- @Override
- public void updateStencil(boolean update) {
- int passOp = update ? GLES20.GL_REPLACE : GLES20.GL_KEEP;
- GLES20.glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, passOp);
- }
-
- @Override
- public void drawOnlyOutsideStencil(boolean onlyOutside) {
- int func = onlyOutside ? GLES20.GL_NOTEQUAL : GLES20.GL_ALWAYS;
- GLES20.glStencilFunc(func, 1, 1);
- }
-
public static void checkError() {
int error = GLES20.glGetError();
if (error != 0) {
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index 775e4a5..f00bd54 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -94,9 +94,6 @@ public class GLRootView extends GLSurfaceView
private int mFlags = FLAG_NEED_LAYOUT;
private volatile boolean mRenderRequested = false;
- private final GalleryEGLConfigChooser mEglConfigChooser =
- new GalleryEGLConfigChooser();
-
private final ArrayList<CanvasAnimation> mAnimations =
new ArrayList<CanvasAnimation>();
@@ -123,7 +120,11 @@ public class GLRootView extends GLSurfaceView
mFlags |= FLAG_INITIALIZED;
setBackgroundDrawable(null);
setEGLContextClientVersion(ApiHelper.HAS_GLES20_REQUIRED ? 2 : 1);
- setEGLConfigChooser(mEglConfigChooser);
+ if (ApiHelper.USE_888_PIXEL_FORMAT) {
+ setEGLConfigChooser(8, 8, 8, 0, 0, 0);
+ } else {
+ setEGLConfigChooser(5, 6, 5, 0, 0, 0);
+ }
setRenderer(this);
if (ApiHelper.USE_888_PIXEL_FORMAT) {
getHolder().setFormat(PixelFormat.RGB_888);
diff --git a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java b/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java
deleted file mode 100644
index f7673bc..0000000
--- a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.
- */
-package com.android.gallery3d.ui;
-
-import android.opengl.GLSurfaceView.EGLConfigChooser;
-
-import com.android.gallery3d.common.ApiHelper;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLDisplay;
-
-/*
- * The code is copied/adapted from
- * <code>android.opengl.GLSurfaceView.BaseConfigChooser</code>. Here we try to
- * choose a configuration that support RGBA_8888 format and if possible,
- * with stencil buffer, but is not required.
- */
-class GalleryEGLConfigChooser implements EGLConfigChooser {
-
- private static final String TAG = "GalleryEGLConfigChooser";
-
- private final int mConfigSpec565[] = new int[] {
- EGL10.EGL_RED_SIZE, 5,
- EGL10.EGL_GREEN_SIZE, 6,
- EGL10.EGL_BLUE_SIZE, 5,
- EGL10.EGL_ALPHA_SIZE, 0,
- EGL10.EGL_NONE
- };
-
- private final int mConfigSpec888[] = new int[] {
- EGL10.EGL_RED_SIZE, 8,
- EGL10.EGL_GREEN_SIZE, 8,
- EGL10.EGL_BLUE_SIZE, 8,
- EGL10.EGL_ALPHA_SIZE, 0,
- EGL10.EGL_NONE
- };
-
- private final int mConfig2Spec565[] = new int[] {
- EGL10.EGL_RED_SIZE, 5,
- EGL10.EGL_GREEN_SIZE, 6,
- EGL10.EGL_BLUE_SIZE, 5,
- EGL10.EGL_ALPHA_SIZE, 0,
- EGL10.EGL_RENDERABLE_TYPE, 4, /* EGL_OPENGL_ES2_BIT */
- EGL10.EGL_NONE
- };
-
- private final int mConfig2Spec888[] = new int[] {
- EGL10.EGL_RED_SIZE, 8,
- EGL10.EGL_GREEN_SIZE, 8,
- EGL10.EGL_BLUE_SIZE, 8,
- EGL10.EGL_ALPHA_SIZE, 0,
- EGL10.EGL_RENDERABLE_TYPE, 4, /* EGL_OPENGL_ES2_BIT */
- EGL10.EGL_NONE
- };
-
- @Override
- public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
- int[] numConfig = new int[1];
-
- int configSpec[];
- if (ApiHelper.HAS_GLES20_REQUIRED) {
- configSpec = ApiHelper.USE_888_PIXEL_FORMAT ? mConfig2Spec888 : mConfig2Spec565;
- } else {
- configSpec = ApiHelper.USE_888_PIXEL_FORMAT ? mConfigSpec888 : mConfigSpec565;
- }
- if (!egl.eglChooseConfig(display, configSpec, null, 0, numConfig)) {
- throw new RuntimeException("eglChooseConfig failed");
- }
-
- if (numConfig[0] <= 0) {
- throw new RuntimeException("No configs match configSpec");
- }
-
- EGLConfig[] configs = new EGLConfig[numConfig[0]];
- if (!egl.eglChooseConfig(display,
- configSpec, configs, configs.length, numConfig)) {
- throw new RuntimeException();
- }
-
- return chooseConfig(egl, display, configs);
- }
-
- private EGLConfig chooseConfig(
- EGL10 egl, EGLDisplay display, EGLConfig configs[]) {
-
- EGLConfig result = null;
- int minStencil = Integer.MAX_VALUE;
- int value[] = new int[1];
-
- // Because we need only one bit of stencil, try to choose a config that
- // has stencil support but with smallest number of stencil bits. If
- // none is found, choose any one.
- for (int i = 0, n = configs.length; i < n; ++i) {
- if (!ApiHelper.USE_888_PIXEL_FORMAT) {
- if (egl.eglGetConfigAttrib(
- display, configs[i], EGL10.EGL_RED_SIZE, value)) {
- // Filter out ARGB 8888 configs.
- if (value[0] == 8) continue;
- }
- }
- if (egl.eglGetConfigAttrib(
- display, configs[i], EGL10.EGL_STENCIL_SIZE, value)) {
- if (value[0] == 0) continue;
- if (value[0] < minStencil) {
- minStencil = value[0];
- result = configs[i];
- }
- } else {
- throw new RuntimeException(
- "eglGetConfigAttrib error: " + egl.eglGetError());
- }
- }
- if (result == null) result = configs[0];
- egl.eglGetConfigAttrib(
- display, result, EGL10.EGL_STENCIL_SIZE, value);
- logConfig(egl, display, result);
- return result;
- }
-
- private static final int[] ATTR_ID = {
- EGL10.EGL_RED_SIZE,
- EGL10.EGL_GREEN_SIZE,
- EGL10.EGL_BLUE_SIZE,
- EGL10.EGL_ALPHA_SIZE,
- EGL10.EGL_DEPTH_SIZE,
- EGL10.EGL_STENCIL_SIZE,
- EGL10.EGL_CONFIG_ID,
- EGL10.EGL_CONFIG_CAVEAT
- };
-
- private static final String[] ATTR_NAME = {
- "R", "G", "B", "A", "D", "S", "ID", "CAVEAT"
- };
-
- private void logConfig(EGL10 egl, EGLDisplay display, EGLConfig config) {
- int value[] = new int[1];
- StringBuilder sb = new StringBuilder();
- for (int j = 0; j < ATTR_ID.length; j++) {
- egl.eglGetConfigAttrib(display, config, ATTR_ID[j], value);
- sb.append(ATTR_NAME[j] + value[0] + " ");
- }
- Log.i(TAG, "Config chosen: " + sb.toString());
- }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
index d258a77..01f0350 100644
--- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
+++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
@@ -148,21 +148,6 @@ public class GLCanvasStub implements GLCanvas {
return 0;
}
@Override
- public void enableStencil() {
- }
- @Override
- public void disableStencil() {
- }
- @Override
- public void clearStencilBuffer() {
- }
- @Override
- public void updateStencil(boolean update) {
- }
- @Override
- public void drawOnlyOutsideStencil(boolean onlyOutside) {
- }
- @Override
public void recoverFromLightCycle() {
}
@Override