OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/compositor/compositor_vsync_manager.h" | |
6 | |
7 // These constants define a reasonable range for a calculated refresh interval. | |
8 // Calculating refreshes out of this range will be considered a fatal error. | |
9 const int64 kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; | |
10 const int64 kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; | |
11 | |
12 namespace ui { | |
13 | |
14 CompositorVSyncManager::CompositorVSyncManager() | |
15 : observer_list_(new ObserverListThreadSafe<Observer>()), | |
16 authoritative_vsync_interval_(base::TimeDelta::FromSeconds(0)) {} | |
17 | |
18 CompositorVSyncManager::~CompositorVSyncManager() {} | |
19 | |
20 void CompositorVSyncManager::SetAuthoritativeVSyncInterval( | |
21 base::TimeDelta interval) { | |
22 base::AutoLock lock(vsync_parameters_lock_); | |
23 authoritative_vsync_interval_ = interval; | |
piman
2014/02/04 04:51:01
nit: I think we should update the observers at thi
sheu
2014/02/04 22:01:45
Sure, we'll do that.
| |
24 } | |
25 | |
26 void CompositorVSyncManager::UpdateVSyncParameters(base::TimeTicks timebase, | |
27 base::TimeDelta interval) { | |
28 { | |
29 base::AutoLock lock(vsync_parameters_lock_); | |
30 if (authoritative_vsync_interval_ != base::TimeDelta::FromSeconds(0)) | |
31 interval = authoritative_vsync_interval_; | |
32 } | |
33 | |
34 // The vsync interval reported here controls the repaint rate of the | |
35 // compositor. If too low, kill the process instead of silently appearing to | |
36 // hang the UI. | |
sheu
2014/02/04 03:23:21
This is probably not the best place to kill the pr
piman
2014/02/04 04:51:01
If anything, the assert should go to SetAuthoritat
sheu
2014/02/04 22:01:45
I've moved the check so that it's run in both this
piman
2014/02/04 22:52:54
I don't think we want to kill the browser process
| |
37 if (interval.InMicroseconds() < kMinVsyncIntervalUs || | |
38 interval.InMicroseconds() > kMaxVsyncIntervalUs) { | |
39 LOG(FATAL) << "Calculated bogus refresh interval of " | |
40 << interval.InMicroseconds() << " us."; | |
41 } | |
42 | |
43 observer_list_->Notify( | |
44 &CompositorVSyncManager::Observer::OnUpdateVSyncParameters, | |
45 timebase, | |
46 interval); | |
47 } | |
48 | |
49 void CompositorVSyncManager::AddObserver(Observer* observer) { | |
50 observer_list_->AddObserver(observer); | |
piman
2014/02/04 04:51:01
It would be reasonable to Notify the observer here
sheu
2014/02/04 22:01:45
Done.
| |
51 } | |
52 | |
53 void CompositorVSyncManager::RemoveObserver(Observer* observer) { | |
54 observer_list_->RemoveObserver(observer); | |
55 } | |
56 | |
57 } // namespace ui | |
OLD | NEW |