| 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/single_thread_task_runner.h" |
| 18 #include "base/synchronization/cancellation_flag.h" | 19 #include "base/synchronization/cancellation_flag.h" |
| 19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 21 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/threading/non_thread_safe.h" | 22 #include "base/threading/non_thread_safe.h" |
| 21 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 23 #include "ui/events/platform/platform_event_source.h" | 25 #include "ui/events/platform/platform_event_source.h" |
| 24 #include "ui/gfx/x/x11_connection.h" | 26 #include "ui/gfx/x/x11_connection.h" |
| 25 #include "ui/gfx/x/x11_types.h" | 27 #include "ui/gfx/x/x11_types.h" |
| 26 #include "ui/gl/gl_bindings.h" | 28 #include "ui/gl/gl_bindings.h" |
| 27 #include "ui/gl/gl_implementation.h" | 29 #include "ui/gl/gl_implementation.h" |
| 28 #include "ui/gl/sync_control_vsync_provider.h" | 30 #include "ui/gl/sync_control_vsync_provider.h" |
| 29 | 31 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 static SGIVideoSyncThread* g_video_sync_thread; | 123 static SGIVideoSyncThread* g_video_sync_thread; |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncThread); | 125 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncThread); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 class SGIVideoSyncProviderThreadShim { | 128 class SGIVideoSyncProviderThreadShim { |
| 127 public: | 129 public: |
| 128 explicit SGIVideoSyncProviderThreadShim(XID window) | 130 explicit SGIVideoSyncProviderThreadShim(XID window) |
| 129 : window_(window), | 131 : window_(window), |
| 130 context_(NULL), | 132 context_(NULL), |
| 131 message_loop_(base::MessageLoopProxy::current()), | 133 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 132 cancel_vsync_flag_(), | 134 cancel_vsync_flag_(), |
| 133 vsync_lock_() { | 135 vsync_lock_() { |
| 134 // This ensures that creation of |window_| has occured when this shim | 136 // This ensures that creation of |window_| has occured when this shim |
| 135 // is executing in the same process as the call to create |window_|. | 137 // is executing in the same process as the call to create |window_|. |
| 136 XSync(g_display, False); | 138 XSync(g_display, False); |
| 137 } | 139 } |
| 138 | 140 |
| 139 virtual ~SGIVideoSyncProviderThreadShim() { | 141 virtual ~SGIVideoSyncProviderThreadShim() { |
| 140 if (context_) { | 142 if (context_) { |
| 141 glXDestroyContext(display_, context_); | 143 glXDestroyContext(display_, context_); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 199 |
| 198 TRACE_EVENT_INSTANT0("gpu", "vblank", TRACE_EVENT_SCOPE_THREAD); | 200 TRACE_EVENT_INSTANT0("gpu", "vblank", TRACE_EVENT_SCOPE_THREAD); |
| 199 now = base::TimeTicks::HighResNow(); | 201 now = base::TimeTicks::HighResNow(); |
| 200 | 202 |
| 201 glXMakeCurrent(display_, 0, 0); | 203 glXMakeCurrent(display_, 0, 0); |
| 202 } | 204 } |
| 203 | 205 |
| 204 const base::TimeDelta kDefaultInterval = | 206 const base::TimeDelta kDefaultInterval = |
| 205 base::TimeDelta::FromSeconds(1) / 60; | 207 base::TimeDelta::FromSeconds(1) / 60; |
| 206 | 208 |
| 207 message_loop_->PostTask( | 209 task_runner_->PostTask( |
| 208 FROM_HERE, base::Bind(callback, now, kDefaultInterval)); | 210 FROM_HERE, base::Bind(callback, now, kDefaultInterval)); |
| 209 } | 211 } |
| 210 | 212 |
| 211 private: | 213 private: |
| 212 // For initialization of display_ in GLSurface::InitializeOneOff before | 214 // For initialization of display_ in GLSurface::InitializeOneOff before |
| 213 // the sandbox goes up. | 215 // the sandbox goes up. |
| 214 friend class gfx::GLSurfaceGLX; | 216 friend class gfx::GLSurfaceGLX; |
| 215 | 217 |
| 216 static Display* display_; | 218 static Display* display_; |
| 217 | 219 |
| 218 XID window_; | 220 XID window_; |
| 219 GLXContext context_; | 221 GLXContext context_; |
| 220 | 222 |
| 221 scoped_refptr<base::MessageLoopProxy> message_loop_; | 223 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 222 | 224 |
| 223 base::CancellationFlag cancel_vsync_flag_; | 225 base::CancellationFlag cancel_vsync_flag_; |
| 224 base::Lock vsync_lock_; | 226 base::Lock vsync_lock_; |
| 225 | 227 |
| 226 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncProviderThreadShim); | 228 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncProviderThreadShim); |
| 227 }; | 229 }; |
| 228 | 230 |
| 229 class SGIVideoSyncVSyncProvider | 231 class SGIVideoSyncVSyncProvider |
| 230 : public gfx::VSyncProvider, | 232 : public gfx::VSyncProvider, |
| 231 public base::SupportsWeakPtr<SGIVideoSyncVSyncProvider> { | 233 public base::SupportsWeakPtr<SGIVideoSyncVSyncProvider> { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 666 |
| 665 void* PbufferGLSurfaceGLX::GetConfig() { | 667 void* PbufferGLSurfaceGLX::GetConfig() { |
| 666 return config_; | 668 return config_; |
| 667 } | 669 } |
| 668 | 670 |
| 669 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 671 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
| 670 Destroy(); | 672 Destroy(); |
| 671 } | 673 } |
| 672 | 674 |
| 673 } // namespace gfx | 675 } // namespace gfx |
| OLD | NEW |