Chromium Code Reviews

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

Issue 548153004: Unified BeginFrame scheduling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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, observer_list_, OnVSync(timebase_, interval_));
117 } 128 }
118 129
119 void DisplayLinkMac::StartOrContinueDisplayLink() { 130 void DisplayLinkMac::StartOrContinueDisplayLink() {
120 // Reset the timer, so that the display link won't be turned off for another 131 // Reset the timer, so that the display link won't be turned off for another
121 // second. 132 // second.
122 stop_timer_.Reset(); 133 stop_timer_.Reset();
123 134
124 if (CVDisplayLinkIsRunning(display_link_)) 135 if (CVDisplayLinkIsRunning(display_link_))
125 return; 136 return;
126 137
(...skipping 24 matching lines...)
151 display_link_mac->Tick(output_time); 162 display_link_mac->Tick(output_time);
152 return kCVReturnSuccess; 163 return kCVReturnSuccess;
153 } 164 }
154 165
155 // static 166 // static
156 base::LazyInstance<DisplayLinkMac::DisplayMap> 167 base::LazyInstance<DisplayLinkMac::DisplayMap>
157 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER; 168 DisplayLinkMac::display_map_ = LAZY_INSTANCE_INITIALIZER;
158 169
159 } // content 170 } // content
160 171
OLDNEW
« no previous file with comments | « content/browser/renderer_host/display_link_mac.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine