From e4673b2650ffc642afa872458dbf51e1a24b00c8 Mon Sep 17 00:00:00 2001 From: George Mount Date: Mon, 7 Jan 2013 14:15:10 -0800 Subject: Instantiate GLCanvas rather than reinitialize current GLCanvas. GLCanvas was being used as a singleton when it really should allow separate instances for correctness. Change-Id: I650884e843a4a78997b70826f6012ae19b8df549 --- src/com/android/gallery3d/ui/GLRootView.java | 7 ++++--- src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java | 3 +-- src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/com/android/gallery3d/ui') diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 755e10733..775e4a518 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -35,6 +35,8 @@ import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.glrenderer.BasicTexture; import com.android.gallery3d.glrenderer.GLCanvas; +import com.android.gallery3d.glrenderer.GLES11Canvas; +import com.android.gallery3d.glrenderer.GLES20Canvas; import com.android.gallery3d.glrenderer.UploadedTexture; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.MotionEventHelper; @@ -120,7 +122,7 @@ public class GLRootView extends GLSurfaceView super(context, attrs); mFlags |= FLAG_INITIALIZED; setBackgroundDrawable(null); - setEGLContextClientVersion(GLCanvas.getEGLContextClientVersion()); + setEGLContextClientVersion(ApiHelper.HAS_GLES20_REQUIRED ? 2 : 1); setEGLConfigChooser(mEglConfigChooser); setRenderer(this); if (ApiHelper.USE_888_PIXEL_FORMAT) { @@ -287,8 +289,7 @@ public class GLRootView extends GLSurfaceView mRenderLock.lock(); try { mGL = gl; - mCanvas = GLCanvas.getInstance(); - mCanvas.initialize(gl); + mCanvas = ApiHelper.HAS_GLES20_REQUIRED ? new GLES20Canvas() : new GLES11Canvas(gl); BasicTexture.invalidateAllTextures(); } finally { mRenderLock.unlock(); diff --git a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java b/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java index 4cf3edb34..f7673bce5 100644 --- a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java +++ b/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java @@ -18,7 +18,6 @@ package com.android.gallery3d.ui; import android.opengl.GLSurfaceView.EGLConfigChooser; import com.android.gallery3d.common.ApiHelper; -import com.android.gallery3d.glrenderer.GLCanvas; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; @@ -73,7 +72,7 @@ class GalleryEGLConfigChooser implements EGLConfigChooser { int[] numConfig = new int[1]; int configSpec[]; - if (GLCanvas.getEGLContextClientVersion() == 2) { + if (ApiHelper.HAS_GLES20_REQUIRED) { configSpec = ApiHelper.USE_888_PIXEL_FORMAT ? mConfig2Spec888 : mConfig2Spec565; } else { configSpec = ApiHelper.USE_888_PIXEL_FORMAT ? mConfigSpec888 : mConfigSpec565; diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index ef8959c9d..18121e63b 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -42,8 +42,8 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail, public SurfaceTextureScreenNail() { } - public void acquireSurfaceTexture() { - mExtTexture = new ExtTexture(GL_TEXTURE_EXTERNAL_OES); + public void acquireSurfaceTexture(GLCanvas canvas) { + mExtTexture = new ExtTexture(canvas, GL_TEXTURE_EXTERNAL_OES); mExtTexture.setSize(mWidth, mHeight); mSurfaceTexture = new SurfaceTexture(mExtTexture.getId()); setDefaultBufferSize(mSurfaceTexture, mWidth, mHeight); -- cgit v1.2.3