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

Side by Side Diff: ui/gfx/gl/gl_context_glx.cc

Issue 7889040: Change X11 error handler override to allow easy X11 error checking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 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/gfx/gl/gl_bindings.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 extern "C" { 5 extern "C" {
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 } 7 }
8 8
9 #include "ui/gfx/gl/gl_context_glx.h" 9 #include "ui/gfx/gl/gl_context_glx.h"
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" 13 #include "third_party/mesa/MesaLib/include/GL/osmesa.h"
14 #include "ui/base/x/x11_util_internal.h"
14 #include "ui/gfx/gl/gl_bindings.h" 15 #include "ui/gfx/gl/gl_bindings.h"
15 #include "ui/gfx/gl/gl_implementation.h" 16 #include "ui/gfx/gl/gl_implementation.h"
16 #include "ui/gfx/gl/gl_surface_glx.h" 17 #include "ui/gfx/gl/gl_surface_glx.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 namespace { 21 namespace {
21 22
22 // scoped_ptr functor for XFree(). Use as follows: 23 // scoped_ptr functor for XFree(). Use as follows:
23 // scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> foo(...); 24 // scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> foo(...);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // in this case, since we will likely allocate our offscreen 82 // in this case, since we will likely allocate our offscreen
82 // contexts with this bit set and the onscreen contexts without, 83 // contexts with this bit set and the onscreen contexts without,
83 // and won't be able to put them in the same share group. 84 // and won't be able to put them in the same share group.
84 // Consider what to do here; force loss of all contexts and 85 // Consider what to do here; force loss of all contexts and
85 // reallocation without ARB_robustness? 86 // reallocation without ARB_robustness?
86 LOG(ERROR) << 87 LOG(ERROR) <<
87 " FAILED to allocate GL context with LOSE_CONTEXT_ON_RESET_ARB"; 88 " FAILED to allocate GL context with LOSE_CONTEXT_ON_RESET_ARB";
88 } 89 }
89 } 90 }
90 91
92 ui::CheckForReportedX11Error();
93
91 if (!context_) { 94 if (!context_) {
92 // The means by which the context is created depends on whether 95 // The means by which the context is created depends on whether
93 // the drawable type works reliably with GLX 1.3. If it does not 96 // the drawable type works reliably with GLX 1.3. If it does not
94 // then fall back to GLX 1.2. 97 // then fall back to GLX 1.2.
95 if (surface_glx->IsOffscreen()) { 98 if (surface_glx->IsOffscreen()) {
96 context_ = glXCreateNewContext( 99 context_ = glXCreateNewContext(
97 GLSurfaceGLX::GetDisplay(), 100 GLSurfaceGLX::GetDisplay(),
98 static_cast<GLXFBConfig>(surface_glx->GetConfig()), 101 static_cast<GLXFBConfig>(surface_glx->GetConfig()),
99 GLX_RGBA_TYPE, 102 GLX_RGBA_TYPE,
100 share_handle, 103 share_handle,
101 True); 104 True);
102 } else { 105 } else {
103 Display* display = GLSurfaceGLX::GetDisplay(); 106 Display* display = GLSurfaceGLX::GetDisplay();
104 107
105 // Get the visuals for the X drawable. 108 // Get the visuals for the X drawable.
106 XWindowAttributes attributes; 109 XWindowAttributes attributes;
107 if (!XGetWindowAttributes( 110 if (!XGetWindowAttributes(
108 display, 111 display,
109 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()), 112 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()),
110 &attributes)) { 113 &attributes)) {
111 LOG(ERROR) << "XGetWindowAttributes failed for window " << 114 LOG(ERROR) << "XGetWindowAttributes failed for window " <<
112 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()) << "."; 115 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()) << ".";
113 return false; 116 return false;
114 } 117 }
115 118
119 ui::CheckForReportedX11Error();
120
116 XVisualInfo visual_info_template; 121 XVisualInfo visual_info_template;
117 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual); 122 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual);
118 123
119 int visual_info_count = 0; 124 int visual_info_count = 0;
120 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list( 125 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list(
121 XGetVisualInfo(display, VisualIDMask, 126 XGetVisualInfo(display, VisualIDMask,
122 &visual_info_template, 127 &visual_info_template,
123 &visual_info_count)); 128 &visual_info_count));
124 129
125 DCHECK(visual_info_list.get()); 130 DCHECK(visual_info_list.get());
126 if (visual_info_count == 0) { 131 if (visual_info_count == 0) {
127 LOG(ERROR) << "No visual info for visual ID."; 132 LOG(ERROR) << "No visual info for visual ID.";
128 return false; 133 return false;
129 } 134 }
130 135
131 // Attempt to create a context with each visual in turn until one works. 136 // Attempt to create a context with each visual in turn until one works.
132 context_ = glXCreateContext( 137 context_ = glXCreateContext(
133 display, 138 display,
134 visual_info_list.get(), 139 visual_info_list.get(),
135 share_handle, 140 share_handle,
136 True); 141 True);
137 } 142 }
138 } 143 }
144 ui::CheckForReportedX11Error();
139 145
140 if (!context_) { 146 if (!context_) {
141 LOG(ERROR) << "Couldn't create GL context."; 147 LOG(ERROR) << "Couldn't create GL context.";
142 Destroy(); 148 Destroy();
143 return false; 149 return false;
144 } 150 }
145 151
146 DLOG(INFO) << (surface_glx->IsOffscreen() ? "Offscreen" : "Onscreen") 152 DLOG(INFO) << (surface_glx->IsOffscreen() ? "Offscreen" : "Onscreen")
147 << " context was " 153 << " context was "
148 << (glXIsDirect(GLSurfaceGLX::GetDisplay(), 154 << (glXIsDirect(GLSurfaceGLX::GetDisplay(),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 250 }
245 251
246 return GLContext::GetExtensions(); 252 return GLContext::GetExtensions();
247 } 253 }
248 254
249 bool GLContextGLX::WasAllocatedUsingARBRobustness() { 255 bool GLContextGLX::WasAllocatedUsingARBRobustness() {
250 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); 256 return GLSurfaceGLX::IsCreateContextRobustnessSupported();
251 } 257 }
252 258
253 } // namespace gfx 259 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_bindings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698