| 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 #include "ui/gl/gl_surface_glx.h" | 5 #include "ui/gl/gl_surface_glx.h" |
| 6 | 6 |
| 7 extern "C" { | 7 extern "C" { |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 } | 9 } |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.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/macros.h" | 15 #include "base/macros.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/single_thread_task_runner.h" |
| 19 #include "base/synchronization/cancellation_flag.h" | 19 #include "base/synchronization/cancellation_flag.h" |
| 20 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 21 #include "base/threading/non_thread_safe.h" | |
| 22 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 22 #include "base/threading/thread_checker.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "ui/events/platform/platform_event_source.h" | 27 #include "ui/events/platform/platform_event_source.h" |
| 28 #include "ui/gfx/x/x11_connection.h" | 28 #include "ui/gfx/x/x11_connection.h" |
| 29 #include "ui/gfx/x/x11_types.h" | 29 #include "ui/gfx/x/x11_types.h" |
| 30 #include "ui/gl/gl_bindings.h" | 30 #include "ui/gl/gl_bindings.h" |
| 31 #include "ui/gl/gl_implementation.h" | 31 #include "ui/gl/gl_implementation.h" |
| 32 #include "ui/gl/gl_visual_picker_glx.h" | 32 #include "ui/gl/gl_visual_picker_glx.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 GLXWindow glx_window_; | 168 GLXWindow glx_window_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(OMLSyncControlVSyncProvider); | 170 DISALLOW_COPY_AND_ASSIGN(OMLSyncControlVSyncProvider); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 class SGIVideoSyncThread : public base::Thread, | 173 class SGIVideoSyncThread : public base::Thread, |
| 174 public base::NonThreadSafe, | |
| 175 public base::RefCounted<SGIVideoSyncThread> { | 174 public base::RefCounted<SGIVideoSyncThread> { |
| 176 public: | 175 public: |
| 177 static scoped_refptr<SGIVideoSyncThread> Create() { | 176 static scoped_refptr<SGIVideoSyncThread> Create() { |
| 178 if (!g_video_sync_thread) { | 177 if (!g_video_sync_thread) { |
| 179 g_video_sync_thread = new SGIVideoSyncThread(); | 178 g_video_sync_thread = new SGIVideoSyncThread(); |
| 180 g_video_sync_thread->Start(); | 179 g_video_sync_thread->Start(); |
| 181 } | 180 } |
| 182 return g_video_sync_thread; | 181 return g_video_sync_thread; |
| 183 } | 182 } |
| 184 | 183 |
| 185 private: | 184 private: |
| 186 friend class base::RefCounted<SGIVideoSyncThread>; | 185 friend class base::RefCounted<SGIVideoSyncThread>; |
| 187 | 186 |
| 188 SGIVideoSyncThread() : base::Thread("SGI_video_sync") { | 187 SGIVideoSyncThread() : base::Thread("SGI_video_sync") { |
| 189 DCHECK(CalledOnValidThread()); | 188 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 190 } | 189 } |
| 191 | 190 |
| 192 ~SGIVideoSyncThread() override { | 191 ~SGIVideoSyncThread() override { |
| 193 DCHECK(CalledOnValidThread()); | 192 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 194 g_video_sync_thread = nullptr; | 193 g_video_sync_thread = nullptr; |
| 195 Stop(); | 194 Stop(); |
| 196 } | 195 } |
| 197 | 196 |
| 198 static SGIVideoSyncThread* g_video_sync_thread; | 197 static SGIVideoSyncThread* g_video_sync_thread; |
| 199 | 198 |
| 199 THREAD_CHECKER(thread_checker_); |
| 200 |
| 200 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncThread); | 201 DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncThread); |
| 201 }; | 202 }; |
| 202 | 203 |
| 203 class SGIVideoSyncProviderThreadShim { | 204 class SGIVideoSyncProviderThreadShim { |
| 204 public: | 205 public: |
| 205 explicit SGIVideoSyncProviderThreadShim(gfx::AcceleratedWidget parent_window) | 206 explicit SGIVideoSyncProviderThreadShim(gfx::AcceleratedWidget parent_window) |
| 206 : parent_window_(parent_window), | 207 : parent_window_(parent_window), |
| 207 window_(0), | 208 window_(0), |
| 208 glx_window_(0), | 209 glx_window_(0), |
| 209 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 210 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 732 |
| 732 unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() { | 733 unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() { |
| 733 return XVisualIDFromVisual(g_visual); | 734 return XVisualIDFromVisual(g_visual); |
| 734 } | 735 } |
| 735 | 736 |
| 736 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { | 737 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { |
| 737 Destroy(); | 738 Destroy(); |
| 738 } | 739 } |
| 739 | 740 |
| 740 } // namespace gl | 741 } // namespace gl |
| OLD | NEW |