Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/compositor/compositor_vsync_manager.cc

Issue 138903025: Read compositor VSync information from platform, when possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 4b969456 piman@ comments; refactor logic into CompositorVSyncManager Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698