// Path: src/com/painless/glclock/GLWallpaperService.java
// public static class ComponentSizeChooser extends BaseConfigChooser {
// 	public ComponentSizeChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize,
// 			int stencilSize) {
// 		super(new int[] { EGL10.EGL_RED_SIZE, redSize, EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE,
// 				blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize, EGL10.EGL_DEPTH_SIZE, depthSize, EGL10.EGL_STENCIL_SIZE,
// 				stencilSize, EGL10.EGL_NONE });
// 		mValue = new int[1];
// 		mRedSize = redSize;
// 		mGreenSize = greenSize;
// 		mBlueSize = blueSize;
// 		mAlphaSize = alphaSize;
// 		mDepthSize = depthSize;
// 		mStencilSize = stencilSize;
// 	}
// 
// 	@Override
// 	public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
// 		EGLConfig closestConfig = null;
// 		int closestDistance = 1000;
// 		for (final EGLConfig config : configs) {
// 			final int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
// 			final int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
// 			if (d >= mDepthSize && s >= mStencilSize) {
// 				final int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
// 				final int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
// 				final int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
// 				final int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
// 				final int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize)
// 				+ Math.abs(a - mAlphaSize);
// 				if (distance < closestDistance) {
// 					closestDistance = distance;
// 					closestConfig = config;
// 				}
// 			}
// 		}
// 		return closestConfig;
// 	}
// 
// 	private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) {
// 
// 		if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
// 			return mValue[0];
// 		}
// 		return defaultValue;
// 	}
// 
// 	private final int[] mValue;
// 	// Subclasses can adjust these values:
// 	protected int mRedSize;
// 	protected int mGreenSize;
// 	protected int mBlueSize;
// 	protected int mAlphaSize;
// 	protected int mDepthSize;
// 	protected int mStencilSize;
// }
// 
// Path: src/com/painless/glclock/GLWallpaperService.java
// public static class SimpleEGLConfigChooser extends ComponentSizeChooser {
// 	public SimpleEGLConfigChooser(boolean withDepthBuffer) {
// 		super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
// 		// Adjust target values. This way we'll accept a 4444 or
// 		// 555 buffer if there's no 565 buffer available.
// 		mRedSize = 5;
// 		mGreenSize = 6;
// 		mBlueSize = 5;
// 	}
// }


import java.io.Writer;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import android.service.wallpaper.WallpaperService;
import android.view.SurfaceHolder;
import com.painless.glclock.BaseConfigChooser.ComponentSizeChooser;
import com.painless.glclock.BaseConfigChooser.SimpleEGLConfigChooser;

			Debug.log("onSurfaceCreated()");
			mGLThread.surfaceCreated(holder);
			super.onSurfaceCreated(holder);
		}

		@Override
		public void onSurfaceDestroyed(SurfaceHolder holder) {
			Debug.log("onSurfaceDestroyed()");
			mGLThread.surfaceDestroyed();
			super.onSurfaceDestroyed(holder);
		}

		/**
		 * An EGL helper class.
		 */
		public void setGLWrapper(GLWrapper glWrapper) {
			mGLWrapper = glWrapper;
		}

		public void setDebugFlags(int debugFlags) {
			mDebugFlags = debugFlags;
		}

		public int getDebugFlags() {
			return mDebugFlags;
		}

		public void setRenderer(Renderer renderer) {
			checkRenderThreadState();
			if (mEGLConfigChooser == null) {

// Path: src/com/painless/glclock/GLWallpaperService.java
// public static class ComponentSizeChooser extends BaseConfigChooser {
// 	public ComponentSizeChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize,
// 			int stencilSize) {
// 		super(new int[] { EGL10.EGL_RED_SIZE, redSize, EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE,
// 				blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize, EGL10.EGL_DEPTH_SIZE, depthSize, EGL10.EGL_STENCIL_SIZE,
// 				stencilSize, EGL10.EGL_NONE });
// 		mValue = new int[1];
// 		mRedSize = redSize;
// 		mGreenSize = greenSize;
// 		mBlueSize = blueSize;
// 		mAlphaSize = alphaSize;
// 		mDepthSize = depthSize;
// 		mStencilSize = stencilSize;
// 	}
// 
// 	@Override
// 	public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
// 		EGLConfig closestConfig = null;
// 		int closestDistance = 1000;
// 		for (final EGLConfig config : configs) {
// 			final int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
// 			final int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
// 			if (d >= mDepthSize && s >= mStencilSize) {
// 				final int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
// 				final int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
// 				final int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
// 				final int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
// 				final int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize)
// 				+ Math.abs(a - mAlphaSize);
// 				if (distance < closestDistance) {
// 					closestDistance = distance;
// 					closestConfig = config;
// 				}
// 			}
// 		}
// 		return closestConfig;
// 	}
// 
// 	private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) {
// 
// 		if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
// 			return mValue[0];
// 		}
// 		return defaultValue;
// 	}
// 
// 	private final int[] mValue;
// 	// Subclasses can adjust these values:
// 	protected int mRedSize;
// 	protected int mGreenSize;
// 	protected int mBlueSize;
// 	protected int mAlphaSize;
// 	protected int mDepthSize;
// 	protected int mStencilSize;
// }
// 
// Path: src/com/painless/glclock/GLWallpaperService.java
// public static class SimpleEGLConfigChooser extends ComponentSizeChooser {
// 	public SimpleEGLConfigChooser(boolean withDepthBuffer) {
// 		super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
// 		// Adjust target values. This way we'll accept a 4444 or
// 		// 555 buffer if there's no 565 buffer available.
// 		mRedSize = 5;
// 		mGreenSize = 6;
// 		mBlueSize = 5;
// 	}
// }


// Path: src/com/painless/glclock/GLWallpaperService.java
import java.io.Writer;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import android.service.wallpaper.WallpaperService;
import android.view.SurfaceHolder;
import com.painless.glclock.BaseConfigChooser.ComponentSizeChooser;
import com.painless.glclock.BaseConfigChooser.SimpleEGLConfigChooser;

			Debug.log("onSurfaceCreated()");
			mGLThread.surfaceCreated(holder);
			super.onSurfaceCreated(holder);
		}

		@Override
		public void onSurfaceDestroyed(SurfaceHolder holder) {
			Debug.log("onSurfaceDestroyed()");
			mGLThread.surfaceDestroyed();
			super.onSurfaceDestroyed(holder);
		}

		/**
		 * An EGL helper class.
		 */
		public void setGLWrapper(GLWrapper glWrapper) {
			mGLWrapper = glWrapper;
		}

		public void setDebugFlags(int debugFlags) {
			mDebugFlags = debugFlags;
		}

		public int getDebugFlags() {
			return mDebugFlags;
		}

		public void setRenderer(Renderer renderer) {
			checkRenderThreadState();
			if (mEGLConfigChooser == null) {

				mEGLConfigChooser = new SimpleEGLConfigChooser(true);
