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

Side by Side Diff: ui/gl/gl_context_egl.cc

Issue 10822029: Use EXT_robustness where available on GLES2 platforms to detect and respond to resets of the graphi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review feedback. Rebuilt and re-tested. Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_context_glx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_context_egl.h" 5 #include "ui/gl/gl_context_egl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "third_party/angle/include/EGL/egl.h" 11 #include "third_party/angle/include/EGL/egl.h"
12 #include "third_party/angle/include/EGL/eglext.h"
12 #include "ui/gl/egl_util.h" 13 #include "ui/gl/egl_util.h"
13 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface_egl.h"
14 15
15 // This header must come after the above third-party include, as 16 // This header must come after the above third-party include, as
16 // it brings in #defines that cause conflicts. 17 // it brings in #defines that cause conflicts.
17 #include "ui/gl/gl_bindings.h" 18 #include "ui/gl/gl_bindings.h"
18 19
19 #if defined(USE_X11) 20 #if defined(USE_X11)
20 extern "C" { 21 extern "C" {
21 #include <X11/Xlib.h> 22 #include <X11/Xlib.h>
22 } 23 }
23 #endif 24 #endif
24 25
25 namespace gfx { 26 namespace gfx {
26 27
27 GLContextEGL::GLContextEGL(GLShareGroup* share_group) 28 GLContextEGL::GLContextEGL(GLShareGroup* share_group)
28 : GLContext(share_group), 29 : GLContext(share_group),
29 context_(NULL), 30 context_(NULL),
30 display_(NULL), 31 display_(NULL),
31 config_(NULL) { 32 config_(NULL) {
32 } 33 }
33 34
34 bool GLContextEGL::Initialize( 35 bool GLContextEGL::Initialize(
35 GLSurface* compatible_surface, GpuPreference gpu_preference) { 36 GLSurface* compatible_surface, GpuPreference gpu_preference) {
36 DCHECK(compatible_surface); 37 DCHECK(compatible_surface);
37 DCHECK(!context_); 38 DCHECK(!context_);
38 39
39 static const EGLint kContextAttributes[] = { 40 static const EGLint kContextAttributes[] = {
40 EGL_CONTEXT_CLIENT_VERSION, 2, 41 EGL_CONTEXT_CLIENT_VERSION, 2,
41 EGL_NONE 42 EGL_NONE
42 }; 43 };
44 static const EGLint kContextRobustnessAttributes[] = {
45 EGL_CONTEXT_CLIENT_VERSION, 2,
46 EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
47 EGL_LOSE_CONTEXT_ON_RESET_EXT,
48 EGL_NONE
49 };
43 50
44 display_ = compatible_surface->GetDisplay(); 51 display_ = compatible_surface->GetDisplay();
45 config_ = compatible_surface->GetConfig(); 52 config_ = compatible_surface->GetConfig();
46 53
54 const EGLint* context_attributes = NULL;
55 if (GLSurfaceEGL::IsCreateContextRobustnessSupported()) {
56 DVLOG(1) << "EGL_EXT_create_context_robustness supported.";
57 context_attributes = kContextRobustnessAttributes;
58 } else {
59 // At some point we should require the presence of the robustness
60 // extension and remove this code path.
61 DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported.";
62 context_attributes = kContextAttributes;
63 }
64
47 context_ = eglCreateContext( 65 context_ = eglCreateContext(
48 display_, 66 display_,
49 config_, 67 config_,
50 share_group() ? share_group()->GetHandle() : NULL, 68 share_group() ? share_group()->GetHandle() : NULL,
51 kContextAttributes); 69 context_attributes);
70
52 if (!context_) { 71 if (!context_) {
53 LOG(ERROR) << "eglCreateContext failed with error " 72 LOG(ERROR) << "eglCreateContext failed with error "
54 << GetLastEGLErrorString(); 73 << GetLastEGLErrorString();
55 Destroy(); 74 Destroy();
56 return false; 75 return false;
57 } 76 }
58 77
59 return true; 78 return true;
60 } 79 }
61 80
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 167
149 std::string GLContextEGL::GetExtensions() { 168 std::string GLContextEGL::GetExtensions() {
150 const char* extensions = eglQueryString(display_, 169 const char* extensions = eglQueryString(display_,
151 EGL_EXTENSIONS); 170 EGL_EXTENSIONS);
152 if (!extensions) 171 if (!extensions)
153 return GLContext::GetExtensions(); 172 return GLContext::GetExtensions();
154 173
155 return GLContext::GetExtensions() + " " + extensions; 174 return GLContext::GetExtensions() + " " + extensions;
156 } 175 }
157 176
177 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() {
178 return GLSurfaceEGL::IsCreateContextRobustnessSupported();
179 }
180
158 GLContextEGL::~GLContextEGL() { 181 GLContextEGL::~GLContextEGL() {
159 Destroy(); 182 Destroy();
160 } 183 }
161 184
162 } // namespace gfx 185 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_context_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698