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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/synchronization/cancellation_flag.h" | 18 #include "base/synchronization/cancellation_flag.h" |
19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "third_party/mesa/src/include/GL/osmesa.h" | 23 #include "third_party/mesa/src/include/GL/osmesa.h" |
24 #include "ui/gfx/x/x11_connection.h" | |
25 #include "ui/gfx/x/x11_types.h" | 24 #include "ui/gfx/x/x11_types.h" |
26 #include "ui/gl/gl_bindings.h" | 25 #include "ui/gl/gl_bindings.h" |
27 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
28 #include "ui/gl/sync_control_vsync_provider.h" | 27 #include "ui/gl/sync_control_vsync_provider.h" |
29 | 28 |
30 namespace gfx { | 29 namespace gfx { |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 // scoped_ptr functor for XFree(). Use as follows: | 33 // scoped_ptr functor for XFree(). Use as follows: |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 bool GLSurfaceGLX::InitializeOneOff() { | 371 bool GLSurfaceGLX::InitializeOneOff() { |
373 static bool initialized = false; | 372 static bool initialized = false; |
374 if (initialized) | 373 if (initialized) |
375 return true; | 374 return true; |
376 | 375 |
377 // http://crbug.com/245466 | 376 // http://crbug.com/245466 |
378 setenv("force_s3tc_enable", "true", 1); | 377 setenv("force_s3tc_enable", "true", 1); |
379 | 378 |
380 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on | 379 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on |
381 // it's own thread. | 380 // it's own thread. |
382 gfx::InitializeThreadedX11(); | 381 XInitThreads(); |
383 g_display = gfx::GetXDisplay(); | 382 |
| 383 #if defined(TOOLKIT_GTK) |
| 384 // Be sure to use the X display handle and not the GTK display handle if this |
| 385 // is the GPU process. |
| 386 g_create_child_windows = |
| 387 base::MessageLoop::current() && |
| 388 base::MessageLoop::current()->type() == base::MessageLoop::TYPE_GPU; |
| 389 |
| 390 if (g_create_child_windows) |
| 391 g_display = base::MessagePumpX11::GetDefaultXDisplay(); |
| 392 else |
| 393 g_display = base::MessagePumpForUI::GetDefaultXDisplay(); |
| 394 #else |
| 395 g_display = base::MessagePumpForUI::GetDefaultXDisplay(); |
| 396 #endif |
384 | 397 |
385 if (!g_display) { | 398 if (!g_display) { |
386 LOG(ERROR) << "XOpenDisplay failed."; | 399 LOG(ERROR) << "XOpenDisplay failed."; |
387 return false; | 400 return false; |
388 } | 401 } |
389 | 402 |
390 int major, minor; | 403 int major, minor; |
391 if (!glXQueryVersion(g_display, &major, &minor)) { | 404 if (!glXQueryVersion(g_display, &major, &minor)) { |
392 LOG(ERROR) << "glxQueryVersion failed"; | 405 LOG(ERROR) << "glxQueryVersion failed"; |
393 return false; | 406 return false; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 787 |
775 void* PbufferGLSurfaceGLX::GetConfig() { | 788 void* PbufferGLSurfaceGLX::GetConfig() { |
776 return config_; | 789 return config_; |
777 } | 790 } |
778 | 791 |
779 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 792 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
780 Destroy(); | 793 Destroy(); |
781 } | 794 } |
782 | 795 |
783 } // namespace gfx | 796 } // namespace gfx |
OLD | NEW |