Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp

Issue 1582313002: VisualBench: Use first succeeding EGL API (Closed) Base URL: https://skia.googlesource.com/skia.git@android-sampleapp-paths
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp
diff --git a/platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp b/platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp
index a35742b2d084530ba3a2604f5cc07a91f3fac98a..df1ca96374a19f933ce7cea18b299bf87ceea2a7 100644
--- a/platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp
+++ b/platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp
@@ -50,15 +50,21 @@ bool SkOSWindow::attach(SkBackEndTypes attachType,
},
};
- size_t apiLimit = SK_ARRAY_COUNT(kAPIs);
-
- for (size_t api = 0; api < apiLimit; ++api) {
- EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (EGL_NO_DISPLAY == display) {
+ return false;
+ }
- EGLint majorVersion;
- EGLint minorVersion;
- eglInitialize(display, &majorVersion, &minorVersion);
+ EGLint majorVersion;
+ EGLint minorVersion;
+ if (!eglInitialize(display, &majorVersion, &minorVersion)) {
+ return false;
+ }
+ for (size_t api = 0; api < SK_ARRAY_COUNT(kAPIs); ++api) {
+ if (!eglBindAPI(kAPIs[api].fAPI)) {
+ continue;
+ }
#if 0
SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR));
SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS));
@@ -66,10 +72,6 @@ bool SkOSWindow::attach(SkBackEndTypes attachType,
SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
#endif
- if (!eglBindAPI(kAPIs[api].fAPI)) {
- continue;
- }
-
const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
@@ -89,31 +91,44 @@ bool SkOSWindow::attach(SkBackEndTypes attachType,
/* Here, the application chooses the configuration it desires. In this
* sample, we have a very simplified selection process, where we pick
* the first EGLConfig that matches our criteria */
- eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);
+ if (!eglChooseConfig(display, configAttribs, &config, 1, &numConfigs) ||
+ numConfigs != 1) {
+ continue;
+ }
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
* As soon as we picked a EGLConfig, we can safely reconfigure the
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
- eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
+ if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format)) {
+ continue;
+ }
ANativeWindow_setBuffersGeometry(fNativeWindow, 0, 0, format);
surface = eglCreateWindowSurface(display, config, fNativeWindow, nullptr);
+ if (EGL_NO_SURFACE == surface) {
+ SkDebugf("eglCreateWindowSurface failed. EGL Error: 0x%08x\n", eglGetError());
+ continue;
+ }
context = eglCreateContext(display, config, nullptr, kAPIs[api].fContextAttribs);
if (EGL_NO_CONTEXT == context) {
SkDebugf("eglCreateContext failed. EGL Error: 0x%08x\n", eglGetError());
+ eglDestroySurface(display, surface);
continue;
}
if (!eglMakeCurrent(display, surface, surface, context)) {
SkDebugf("eglMakeCurrent failed. EGL Error: 0x%08x\n", eglGetError());
+ eglDestroyContext(display, context);
+ eglDestroySurface(display, surface);
continue;
}
fWindow.fDisplay = display;
fWindow.fContext = context;
fWindow.fSurface = surface;
+ break;
}
if (fWindow.fDisplay && fWindow.fContext && fWindow.fSurface) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698