Skip to content

Commit 54ea6bf

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Always set the EGL_BUFFER_PRESERVED EGL_SWAP_BEHAVIOR Bug #7221173" into jb-mr1-dev
2 parents 1951db8 + bd43152 commit 54ea6bf

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

core/java/android/view/HardwareRenderer.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.graphics.Paint;
2222
import android.graphics.Rect;
2323
import android.graphics.SurfaceTexture;
24+
import android.opengl.EGL14;
2425
import android.opengl.GLUtils;
2526
import android.opengl.ManagedEGLContext;
2627
import android.os.Handler;
@@ -608,12 +609,6 @@ void setRequested(boolean requested) {
608609

609610
@SuppressWarnings({"deprecation"})
610611
static abstract class GlRenderer extends HardwareRenderer {
611-
// These values are not exposed in our EGL APIs
612-
static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
613-
static final int EGL_OPENGL_ES2_BIT = 4;
614-
static final int EGL_SURFACE_TYPE = 0x3033;
615-
static final int EGL_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400;
616-
617612
static final int SURFACE_STATE_ERROR = 0;
618613
static final int SURFACE_STATE_SUCCESS = 1;
619614
static final int SURFACE_STATE_UPDATED = 2;
@@ -953,19 +948,8 @@ GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException {
953948
return null;
954949
}
955950

956-
/*
957-
* Before we can issue GL commands, we need to make sure
958-
* the context is current and bound to a surface.
959-
*/
960-
if (!sEgl.eglMakeCurrent(sEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
961-
throw new Surface.OutOfResourcesException("eglMakeCurrent failed "
962-
+ GLUtils.getEGLErrorString(sEgl.eglGetError()));
963-
}
964-
965951
initCaches();
966952

967-
enableDirtyRegions();
968-
969953
return mEglContext.getGL();
970954
}
971955

@@ -990,7 +974,7 @@ private void enableDirtyRegions() {
990974
abstract void initCaches();
991975

992976
EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) {
993-
int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE };
977+
int[] attribs = { EGL14.EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE };
994978

995979
EGLContext context = egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT,
996980
mGlVersion != 0 ? attribs : null);
@@ -1066,6 +1050,14 @@ private boolean createSurface(Surface surface) {
10661050
throw new RuntimeException("createWindowSurface failed "
10671051
+ GLUtils.getEGLErrorString(error));
10681052
}
1053+
1054+
if (!sEgl.eglMakeCurrent(sEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
1055+
throw new IllegalStateException("eglMakeCurrent failed " +
1056+
GLUtils.getEGLErrorString(sEgl.eglGetError()));
1057+
}
1058+
1059+
enableDirtyRegions();
1060+
10691061
return true;
10701062
}
10711063

@@ -1430,7 +1422,7 @@ ManagedEGLContext createManagedContext(EGLContext eglContext) {
14301422
@Override
14311423
int[] getConfig(boolean dirtyRegions) {
14321424
return new int[] {
1433-
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1425+
EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
14341426
EGL_RED_SIZE, 8,
14351427
EGL_GREEN_SIZE, 8,
14361428
EGL_BLUE_SIZE, 8,
@@ -1439,7 +1431,7 @@ int[] getConfig(boolean dirtyRegions) {
14391431
// TODO: Find a better way to choose the stencil size
14401432
EGL_STENCIL_SIZE, mShowOverdraw ? GLES20Canvas.getStencilSize() : 0,
14411433
EGL_SURFACE_TYPE, EGL_WINDOW_BIT |
1442-
(dirtyRegions ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
1434+
(dirtyRegions ? EGL14.EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
14431435
EGL_NONE
14441436
};
14451437
}

0 commit comments

Comments
 (0)