OLD | NEW |
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 extern "C" { | 5 extern "C" { |
6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
7 } | 7 } |
8 | 8 |
9 #include "ui/gl/gl_surface_glx.h" | 9 #include "ui/gl/gl_surface_glx.h" |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return true; | 115 return true; |
116 } | 116 } |
117 | 117 |
118 void NativeViewGLSurfaceGLX::Destroy() { | 118 void NativeViewGLSurfaceGLX::Destroy() { |
119 } | 119 } |
120 | 120 |
121 bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) { | 121 bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) { |
122 // On Intel drivers, the frame buffer won't be resize until the next swap. If | 122 // On Intel drivers, the frame buffer won't be resize until the next swap. If |
123 // we only do PostSubBuffer, then we're stuck in the old size. Force a swap | 123 // we only do PostSubBuffer, then we're stuck in the old size. Force a swap |
124 // now. | 124 // now. |
125 if (gfx::g_GLX_MESA_copy_sub_buffer && size_ != size) | 125 if (gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer && size_ != size) |
126 SwapBuffers(); | 126 SwapBuffers(); |
127 size_ = size; | 127 size_ = size; |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 bool NativeViewGLSurfaceGLX::IsOffscreen() { | 131 bool NativeViewGLSurfaceGLX::IsOffscreen() { |
132 return false; | 132 return false; |
133 } | 133 } |
134 | 134 |
135 bool NativeViewGLSurfaceGLX::SwapBuffers() { | 135 bool NativeViewGLSurfaceGLX::SwapBuffers() { |
136 glXSwapBuffers(g_display, window_); | 136 glXSwapBuffers(g_display, window_); |
137 // For latency_tests.cc: | 137 // For latency_tests.cc: |
138 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "CompositorSwapBuffersComplete"); | 138 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "CompositorSwapBuffersComplete"); |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 gfx::Size NativeViewGLSurfaceGLX::GetSize() { | 142 gfx::Size NativeViewGLSurfaceGLX::GetSize() { |
143 return size_; | 143 return size_; |
144 } | 144 } |
145 | 145 |
146 void* NativeViewGLSurfaceGLX::GetHandle() { | 146 void* NativeViewGLSurfaceGLX::GetHandle() { |
147 return reinterpret_cast<void*>(window_); | 147 return reinterpret_cast<void*>(window_); |
148 } | 148 } |
149 | 149 |
150 std::string NativeViewGLSurfaceGLX::GetExtensions() { | 150 std::string NativeViewGLSurfaceGLX::GetExtensions() { |
151 std::string extensions = GLSurface::GetExtensions(); | 151 std::string extensions = GLSurface::GetExtensions(); |
152 if (g_GLX_MESA_copy_sub_buffer) { | 152 if (gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer) { |
153 extensions += extensions.empty() ? "" : " "; | 153 extensions += extensions.empty() ? "" : " "; |
154 extensions += "GL_CHROMIUM_post_sub_buffer"; | 154 extensions += "GL_CHROMIUM_post_sub_buffer"; |
155 } | 155 } |
156 return extensions; | 156 return extensions; |
157 } | 157 } |
158 | 158 |
159 void* NativeViewGLSurfaceGLX::GetConfig() { | 159 void* NativeViewGLSurfaceGLX::GetConfig() { |
160 if (!config_) { | 160 if (!config_) { |
161 // This code path is expensive, but we only take it when | 161 // This code path is expensive, but we only take it when |
162 // attempting to use GLX_ARB_create_context_robustness, in which | 162 // attempting to use GLX_ARB_create_context_robustness, in which |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (found) { | 212 if (found) { |
213 config_ = configs.get()[i]; | 213 config_ = configs.get()[i]; |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 return config_; | 217 return config_; |
218 } | 218 } |
219 | 219 |
220 bool NativeViewGLSurfaceGLX::PostSubBuffer( | 220 bool NativeViewGLSurfaceGLX::PostSubBuffer( |
221 int x, int y, int width, int height) { | 221 int x, int y, int width, int height) { |
222 DCHECK(g_GLX_MESA_copy_sub_buffer); | 222 DCHECK(gfx::g_driver_glx.ext.b_GLX_MESA_copy_sub_buffer); |
223 glXCopySubBufferMESA(g_display, window_, x, y, width, height); | 223 glXCopySubBufferMESA(g_display, window_, x, y, width, height); |
224 return true; | 224 return true; |
225 } | 225 } |
226 | 226 |
227 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX() | 227 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX() |
228 : window_(0), | 228 : window_(0), |
229 config_(NULL) { | 229 config_(NULL) { |
230 } | 230 } |
231 | 231 |
232 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { | 232 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 316 |
317 void* PbufferGLSurfaceGLX::GetConfig() { | 317 void* PbufferGLSurfaceGLX::GetConfig() { |
318 return config_; | 318 return config_; |
319 } | 319 } |
320 | 320 |
321 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 321 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
322 Destroy(); | 322 Destroy(); |
323 } | 323 } |
324 | 324 |
325 } // namespace gfx | 325 } // namespace gfx |
OLD | NEW |