Skip to content

Commit c77ba7b

Browse files
committed
Merge pull request #172 from ericwa/stencil-request
GLES configuration: fall back to EGL_STENCIL_SIZE 0, if 1 is not available
2 parents 90946b0 + e2b76e8 commit c77ba7b

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

document-viewer/src/main/java/org/ebookdroid/EBookDroidApp.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public void onCreate() {
6060
onAppSettingsChanged(null, AppSettings.current(), null);
6161
onBackupSettingsChanged(null, BackupSettings.current(), null);
6262

63-
GLConfiguration.stencilRequired = !IS_EMULATOR;
64-
6563
initialized.set();
6664
}
6765

document-viewer/src/main/java/org/emdev/ui/gl/BaseEGLConfigChooser.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,39 @@ public class BaseEGLConfigChooser implements EGLConfigChooser {
2929
private static final LogContext LCTX = LogManager.root().lctx("GLConfiguration");
3030

3131
private final int mConfigSpec[] = new int[] { EGL10.EGL_RED_SIZE, 5, EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_BLUE_SIZE,
32-
5, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_STENCIL_SIZE, GLConfiguration.stencilRequired ? 1 : 0, EGL10.EGL_NONE };
32+
5, EGL10.EGL_ALPHA_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 1, EGL10.EGL_NONE };
3333

3434
private static final int[] ATTR_ID = { EGL10.EGL_RED_SIZE, EGL10.EGL_GREEN_SIZE, EGL10.EGL_BLUE_SIZE,
3535
EGL10.EGL_ALPHA_SIZE, EGL10.EGL_DEPTH_SIZE, EGL10.EGL_STENCIL_SIZE, EGL10.EGL_CONFIG_ID,
3636
EGL10.EGL_CONFIG_CAVEAT };
3737

3838
private static final String[] ATTR_NAME = { "R", "G", "B", "A", "D", "S", "ID", "CAVEAT" };
3939

40+
private void setConfigValue(int key, int value) {
41+
for (int i = 0; i < mConfigSpec.length; i += 2) {
42+
if (mConfigSpec[i] == key) {
43+
mConfigSpec[i + 1] = value;
44+
break;
45+
}
46+
}
47+
}
48+
4049
@Override
4150
public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
4251
final int[] numConfig = new int[1];
4352
if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, numConfig)) {
4453
throw new RuntimeException("eglChooseConfig failed");
4554
}
4655

56+
if (numConfig[0] <= 0) {
57+
LCTX.i("No configurations found. Trying EGL_STENCIL_SIZE 0");
58+
setConfigValue(EGL10.EGL_STENCIL_SIZE, 0);
59+
60+
if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, numConfig)) {
61+
throw new RuntimeException("eglChooseConfig failed");
62+
}
63+
}
64+
4765
if (numConfig[0] <= 0) {
4866
throw new RuntimeException("Your device cannot support required GLES configuration");
4967
}

document-viewer/src/main/java/org/emdev/ui/gl/GLConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
public class GLConfiguration {
1010

11-
public static boolean stencilRequired = true;
12-
1311
public static boolean use8888 = false;
1412

1513
private static BaseEGLConfigChooser chooser;

0 commit comments

Comments
 (0)