| 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" |
| 24 #include "ui/gfx/x/x11_types.h" | 25 #include "ui/gfx/x/x11_types.h" |
| 25 #include "ui/gl/gl_bindings.h" | 26 #include "ui/gl/gl_bindings.h" |
| 26 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
| 27 #include "ui/gl/sync_control_vsync_provider.h" | 28 #include "ui/gl/sync_control_vsync_provider.h" |
| 28 | 29 |
| 29 namespace gfx { | 30 namespace gfx { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // scoped_ptr functor for XFree(). Use as follows: | 34 // scoped_ptr functor for XFree(). Use as follows: |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 bool GLSurfaceGLX::InitializeOneOff() { | 372 bool GLSurfaceGLX::InitializeOneOff() { |
| 372 static bool initialized = false; | 373 static bool initialized = false; |
| 373 if (initialized) | 374 if (initialized) |
| 374 return true; | 375 return true; |
| 375 | 376 |
| 376 // http://crbug.com/245466 | 377 // http://crbug.com/245466 |
| 377 setenv("force_s3tc_enable", "true", 1); | 378 setenv("force_s3tc_enable", "true", 1); |
| 378 | 379 |
| 379 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on | 380 // SGIVideoSyncProviderShim (if instantiated) will issue X commands on |
| 380 // it's own thread. | 381 // it's own thread. |
| 381 XInitThreads(); | 382 gfx::InitializeX11(); |
| 382 | 383 g_display = gfx::GetXDisplay(); |
| 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 | |
| 397 | 384 |
| 398 if (!g_display) { | 385 if (!g_display) { |
| 399 LOG(ERROR) << "XOpenDisplay failed."; | 386 LOG(ERROR) << "XOpenDisplay failed."; |
| 400 return false; | 387 return false; |
| 401 } | 388 } |
| 402 | 389 |
| 403 int major, minor; | 390 int major, minor; |
| 404 if (!glXQueryVersion(g_display, &major, &minor)) { | 391 if (!glXQueryVersion(g_display, &major, &minor)) { |
| 405 LOG(ERROR) << "glxQueryVersion failed"; | 392 LOG(ERROR) << "glxQueryVersion failed"; |
| 406 return false; | 393 return false; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 | 774 |
| 788 void* PbufferGLSurfaceGLX::GetConfig() { | 775 void* PbufferGLSurfaceGLX::GetConfig() { |
| 789 return config_; | 776 return config_; |
| 790 } | 777 } |
| 791 | 778 |
| 792 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 779 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
| 793 Destroy(); | 780 Destroy(); |
| 794 } | 781 } |
| 795 | 782 |
| 796 } // namespace gfx | 783 } // namespace gfx |
| OLD | NEW |