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 29 matching lines...) Expand all Loading... |
40 bool g_glx_texture_from_pixmap_supported = false; | 40 bool g_glx_texture_from_pixmap_supported = false; |
41 bool g_glx_oml_sync_control_supported = false; | 41 bool g_glx_oml_sync_control_supported = false; |
42 | 42 |
43 // Track support of glXGetMscRateOML separately from GLX_OML_sync_control as a | 43 // Track support of glXGetMscRateOML separately from GLX_OML_sync_control as a |
44 // whole since on some platforms (e.g. crosbug.com/34585), glXGetMscRateOML | 44 // whole since on some platforms (e.g. crosbug.com/34585), glXGetMscRateOML |
45 // always fails even though GLX_OML_sync_control is reported as being supported. | 45 // always fails even though GLX_OML_sync_control is reported as being supported. |
46 bool g_glx_get_msc_rate_oml_supported = false; | 46 bool g_glx_get_msc_rate_oml_supported = false; |
47 | 47 |
48 bool g_glx_sgi_video_sync_supported = false; | 48 bool g_glx_sgi_video_sync_supported = false; |
49 | 49 |
50 static const base::TimeDelta kGetVSyncParametersMinPeriod = | 50 static const int kGetVSyncParametersMinSeconds = |
51 #if defined(OS_LINUX) | 51 #if defined(OS_LINUX) |
52 // See crbug.com/373489 | 52 // See crbug.com/373489 |
53 // On Linux, querying the vsync parameters might burn CPU for up to an | 53 // On Linux, querying the vsync parameters might burn CPU for up to an |
54 // entire vsync, so we only query periodically to reduce CPU usage. | 54 // entire vsync, so we only query periodically to reduce CPU usage. |
55 // 5 seconds is chosen somewhat abitrarily as a balance between: | 55 // 5 seconds is chosen somewhat abitrarily as a balance between: |
56 // a) Drift in the phase of our signal. | 56 // a) Drift in the phase of our signal. |
57 // b) Potential janks from periodically pegging the CPU. | 57 // b) Potential janks from periodically pegging the CPU. |
58 base::TimeDelta::FromSeconds(5); | 58 5; |
59 #else | 59 #else |
60 base::TimeDelta::FromSeconds(0); | 60 0; |
61 #endif | 61 #endif |
62 | 62 |
63 class OMLSyncControlVSyncProvider | 63 class OMLSyncControlVSyncProvider |
64 : public gfx::SyncControlVSyncProvider { | 64 : public gfx::SyncControlVSyncProvider { |
65 public: | 65 public: |
66 explicit OMLSyncControlVSyncProvider(gfx::AcceleratedWidget window) | 66 explicit OMLSyncControlVSyncProvider(gfx::AcceleratedWidget window) |
67 : SyncControlVSyncProvider(), | 67 : SyncControlVSyncProvider(), |
68 window_(window) { | 68 window_(window) { |
69 } | 69 } |
70 | 70 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 // Hand-off |shim_| to be deleted on the |vsync_thread_|. | 256 // Hand-off |shim_| to be deleted on the |vsync_thread_|. |
257 vsync_thread_->message_loop()->DeleteSoon( | 257 vsync_thread_->message_loop()->DeleteSoon( |
258 FROM_HERE, | 258 FROM_HERE, |
259 shim_.release()); | 259 shim_.release()); |
260 } | 260 } |
261 | 261 |
262 void GetVSyncParameters( | 262 void GetVSyncParameters( |
263 const VSyncProvider::UpdateVSyncCallback& callback) override { | 263 const VSyncProvider::UpdateVSyncCallback& callback) override { |
264 if (kGetVSyncParametersMinPeriod > base::TimeDelta()) { | 264 if (kGetVSyncParametersMinSeconds > 0) { |
265 base::TimeTicks now = base::TimeTicks::Now(); | 265 base::TimeTicks now = base::TimeTicks::Now(); |
266 base::TimeDelta delta = now - last_get_vsync_parameters_time_; | 266 base::TimeDelta delta = now - last_get_vsync_parameters_time_; |
267 if (delta < kGetVSyncParametersMinPeriod) | 267 if (delta.InSeconds() < kGetVSyncParametersMinSeconds) |
268 return; | 268 return; |
269 last_get_vsync_parameters_time_ = now; | 269 last_get_vsync_parameters_time_ = now; |
270 } | 270 } |
271 | 271 |
272 // Only one outstanding request per surface. | 272 // Only one outstanding request per surface. |
273 if (!pending_callback_) { | 273 if (!pending_callback_) { |
274 pending_callback_.reset( | 274 pending_callback_.reset( |
275 new VSyncProvider::UpdateVSyncCallback(callback)); | 275 new VSyncProvider::UpdateVSyncCallback(callback)); |
276 vsync_thread_->message_loop()->PostTask( | 276 vsync_thread_->message_loop()->PostTask( |
277 FROM_HERE, | 277 FROM_HERE, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 if (!config_) | 636 if (!config_) |
637 config_ = GLSurfaceGLX::GetConfig(window_); | 637 config_ = GLSurfaceGLX::GetConfig(window_); |
638 return config_; | 638 return config_; |
639 } | 639 } |
640 | 640 |
641 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { | 641 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { |
642 Destroy(); | 642 Destroy(); |
643 } | 643 } |
644 | 644 |
645 } // namespace gfx | 645 } // namespace gfx |
OLD | NEW |