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

Side by Side Diff: content/browser/renderer_host/display_link_mac.cc

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP in mac and android Created 6 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/renderer_host/display_link_mac.h" 5 #include "content/browser/renderer_host/display_link_mac.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 base::AutoLock lock(lock_); 88 base::AutoLock lock(lock_);
89 if (!timebase_and_interval_valid_) 89 if (!timebase_and_interval_valid_)
90 return false; 90 return false;
91 91
92 *timebase = timebase_; 92 *timebase = timebase_;
93 *interval = interval_; 93 *interval = interval_;
94 return true; 94 return true;
95 } 95 }
96 96
97 void DisplayLinkMac::AddObserver(Observer* observer) {
98 StartOrContinueDisplayLink();
99 observer_list_.AddObserver(observer);
100 }
101
102 void DisplayLinkMac::RemoveObserver(Observer* observer) {
103 observer_list.RemoveObserver(observer);
104 }
105
97 void DisplayLinkMac::Tick(const CVTimeStamp* cv_time) { 106 void DisplayLinkMac::Tick(const CVTimeStamp* cv_time) {
98 TRACE_EVENT0("browser", "DisplayLinkMac::GetVSyncParameters"); 107 TRACE_EVENT0("browser", "DisplayLinkMac::GetVSyncParameters");
99 base::AutoLock lock(lock_); 108 base::AutoLock lock(lock_);
100 109
101 // Verify that videoRefreshPeriod is 32 bits. 110 // Verify that videoRefreshPeriod is 32 bits.
102 DCHECK((cv_time->videoRefreshPeriod & ~0xffffFFFFull) == 0ull); 111 DCHECK((cv_time->videoRefreshPeriod & ~0xffffFFFFull) == 0ull);
103 112
104 // Verify that the numerator and denominator make some sense. 113 // Verify that the numerator and denominator make some sense.
105 uint32 numerator = static_cast<uint32>(cv_time->videoRefreshPeriod); 114 uint32 numerator = static_cast<uint32>(cv_time->videoRefreshPeriod);
106 uint32 denominator = cv_time->videoTimeScale; 115 uint32 denominator = cv_time->videoTimeScale;
107 if (numerator <= 0 || denominator <= 0) { 116 if (numerator <= 0 || denominator <= 0) {
108 LOG(WARNING) << "Unexpected numerator or denominator, bailing."; 117 LOG(WARNING) << "Unexpected numerator or denominator, bailing.";
109 return; 118 return;
110 } 119 }
111 120
112 timebase_ = base::TimeTicks::FromInternalValue( 121 timebase_ = base::TimeTicks::FromInternalValue(
113 cv_time->hostTime / 1000); 122 cv_time->hostTime / 1000);
114 interval_ = base::TimeDelta::FromMicroseconds( 123 interval_ = base::TimeDelta::FromMicroseconds(
115 1000000 * static_cast<int64>(numerator) / denominator); 124 1000000 * static_cast<int64>(numerator) / denominator);
116 timebase_and_interval_valid_ = true; 125 timebase_and_interval_valid_ = true;
126
127 FOR_EACH_OBSERVER(Observer,
128 observer_list_,
129 OnVSync(timebase_, interval_));
117 } 130 }
118 131
119 void DisplayLinkMac::StartOrContinueDisplayLink() { 132 void DisplayLinkMac::StartOrContinueDisplayLink() {
120 // Reset the timer, so that the display link won't be turned off for another 133 // Reset the timer, so that the display link won't be turned off for another
121 // second. 134 // second.
122 stop_timer_.Reset(); 135 stop_timer_.Reset();
123 136
124 if (CVDisplayLinkIsRunning(display_link_)) 137 if (CVDisplayLinkIsRunning(display_link_))
125 return; 138 return;
126 139
(...skipping 24 matching lines...) Expand all
151 display_link_mac->Tick(output_time); 164 display_link_mac->Tick(output_time);
152 return kCVReturnSuccess; 165 return kCVReturnSuccess;
153 } 166 }
154 167
155 // static 168 // static
156 base::LazyInstance<DisplayLinkMac::DisplayMap> 169 base::LazyInstance<DisplayLinkMac::DisplayMap>
157 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; 170 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER;
158 171
159 } // content 172 } // content
160 173
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698