OLD | NEW |
---|---|
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.h" | |
Ami GONE FROM CHROMIUM
2011/09/20 23:45:51
Why this file?
dominich
2011/09/21 19:47:30
Done.
| |
15 #include "ui/base/x/x11_util_internal.h" | |
14 #include "ui/gfx/gl/gl_bindings.h" | 16 #include "ui/gfx/gl/gl_bindings.h" |
15 #include "ui/gfx/gl/gl_implementation.h" | 17 #include "ui/gfx/gl/gl_implementation.h" |
16 #include "ui/gfx/gl/gl_surface_glx.h" | 18 #include "ui/gfx/gl/gl_surface_glx.h" |
17 | 19 |
18 namespace gfx { | 20 namespace gfx { |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 // scoped_ptr functor for XFree(). Use as follows: | 24 // scoped_ptr functor for XFree(). Use as follows: |
23 // scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> foo(...); | 25 // scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> foo(...); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // in this case, since we will likely allocate our offscreen | 83 // in this case, since we will likely allocate our offscreen |
82 // contexts with this bit set and the onscreen contexts without, | 84 // contexts with this bit set and the onscreen contexts without, |
83 // and won't be able to put them in the same share group. | 85 // 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 | 86 // Consider what to do here; force loss of all contexts and |
85 // reallocation without ARB_robustness? | 87 // reallocation without ARB_robustness? |
86 LOG(ERROR) << | 88 LOG(ERROR) << |
87 " FAILED to allocate GL context with LOSE_CONTEXT_ON_RESET_ARB"; | 89 " FAILED to allocate GL context with LOSE_CONTEXT_ON_RESET_ARB"; |
88 } | 90 } |
89 } | 91 } |
90 | 92 |
93 ui::CheckFailOnX11Error(); | |
94 | |
91 if (!context_) { | 95 if (!context_) { |
92 // The means by which the context is created depends on whether | 96 // 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 | 97 // the drawable type works reliably with GLX 1.3. If it does not |
94 // then fall back to GLX 1.2. | 98 // then fall back to GLX 1.2. |
95 if (surface_glx->IsOffscreen()) { | 99 if (surface_glx->IsOffscreen()) { |
96 context_ = glXCreateNewContext( | 100 context_ = glXCreateNewContext( |
97 GLSurfaceGLX::GetDisplay(), | 101 GLSurfaceGLX::GetDisplay(), |
98 static_cast<GLXFBConfig>(surface_glx->GetConfig()), | 102 static_cast<GLXFBConfig>(surface_glx->GetConfig()), |
99 GLX_RGBA_TYPE, | 103 GLX_RGBA_TYPE, |
100 share_handle, | 104 share_handle, |
101 True); | 105 True); |
102 } else { | 106 } else { |
103 Display* display = GLSurfaceGLX::GetDisplay(); | 107 Display* display = GLSurfaceGLX::GetDisplay(); |
104 | 108 |
105 // Get the visuals for the X drawable. | 109 // Get the visuals for the X drawable. |
106 XWindowAttributes attributes; | 110 XWindowAttributes attributes; |
107 if (!XGetWindowAttributes( | 111 if (!XGetWindowAttributes( |
108 display, | 112 display, |
109 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()), | 113 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()), |
110 &attributes)) { | 114 &attributes)) { |
111 LOG(ERROR) << "XGetWindowAttributes failed for window " << | 115 LOG(ERROR) << "XGetWindowAttributes failed for window " << |
112 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()) << "."; | 116 reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()) << "."; |
113 return false; | 117 return false; |
114 } | 118 } |
115 | 119 |
120 ui::CheckFailOnX11Error(); | |
121 | |
116 XVisualInfo visual_info_template; | 122 XVisualInfo visual_info_template; |
117 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual); | 123 visual_info_template.visualid = XVisualIDFromVisual(attributes.visual); |
118 | 124 |
119 int visual_info_count = 0; | 125 int visual_info_count = 0; |
120 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list( | 126 scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info_list( |
121 XGetVisualInfo(display, VisualIDMask, | 127 XGetVisualInfo(display, VisualIDMask, |
122 &visual_info_template, | 128 &visual_info_template, |
123 &visual_info_count)); | 129 &visual_info_count)); |
124 | 130 |
125 DCHECK(visual_info_list.get()); | 131 DCHECK(visual_info_list.get()); |
126 if (visual_info_count == 0) { | 132 if (visual_info_count == 0) { |
127 LOG(ERROR) << "No visual info for visual ID."; | 133 LOG(ERROR) << "No visual info for visual ID."; |
128 return false; | 134 return false; |
129 } | 135 } |
130 | 136 |
131 // Attempt to create a context with each visual in turn until one works. | 137 // Attempt to create a context with each visual in turn until one works. |
132 context_ = glXCreateContext( | 138 context_ = glXCreateContext( |
133 display, | 139 display, |
134 visual_info_list.get(), | 140 visual_info_list.get(), |
135 share_handle, | 141 share_handle, |
136 True); | 142 True); |
137 } | 143 } |
138 } | 144 } |
145 ui::CheckFailOnX11Error(); | |
139 | 146 |
140 if (!context_) { | 147 if (!context_) { |
141 LOG(ERROR) << "Couldn't create GL context."; | 148 LOG(ERROR) << "Couldn't create GL context."; |
142 Destroy(); | 149 Destroy(); |
143 return false; | 150 return false; |
144 } | 151 } |
145 | 152 |
146 DLOG(INFO) << (surface_glx->IsOffscreen() ? "Offscreen" : "Onscreen") | 153 DLOG(INFO) << (surface_glx->IsOffscreen() ? "Offscreen" : "Onscreen") |
147 << " context was " | 154 << " context was " |
148 << (glXIsDirect(GLSurfaceGLX::GetDisplay(), | 155 << (glXIsDirect(GLSurfaceGLX::GetDisplay(), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 } | 251 } |
245 | 252 |
246 return GLContext::GetExtensions(); | 253 return GLContext::GetExtensions(); |
247 } | 254 } |
248 | 255 |
249 bool GLContextGLX::WasAllocatedUsingARBRobustness() { | 256 bool GLContextGLX::WasAllocatedUsingARBRobustness() { |
250 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); | 257 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); |
251 } | 258 } |
252 | 259 |
253 } // namespace gfx | 260 } // namespace gfx |
OLD | NEW |