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

Side by Side Diff: cc/scheduler/begin_frame_source.cc

Issue 2897263003: Fix Omnibox.CharTypedToRepaintLatency regression with D3DVsync experiment (Closed)
Patch Set: Address the test flakiness Created 3 years, 7 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
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 "cc/scheduler/begin_frame_source.h" 5 #include "cc/scheduler/begin_frame_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DCHECK(obs); 277 DCHECK(obs);
278 DCHECK(observers_.find(obs) == observers_.end()); 278 DCHECK(observers_.find(obs) == observers_.end());
279 279
280 bool observers_was_empty = observers_.empty(); 280 bool observers_was_empty = observers_.empty();
281 observers_.insert(obs); 281 observers_.insert(obs);
282 obs->OnBeginFrameSourcePausedChanged(paused_); 282 obs->OnBeginFrameSourcePausedChanged(paused_);
283 if (observers_was_empty) 283 if (observers_was_empty)
284 client_->OnNeedsBeginFrames(true); 284 client_->OnNeedsBeginFrames(true);
285 285
286 // Send a MISSED begin frame if necessary. 286 // Send a MISSED begin frame if necessary.
287 if (last_begin_frame_args_.IsValid()) { 287 BeginFrameArgs missed_args;
288 const BeginFrameArgs& last_args = obs->LastUsedBeginFrameArgs(); 288 if (GetMissedBeginFrameArgs(obs, &missed_args))
sunnyps 2017/05/30 22:13:16 nit: Can you add a DCHECK_EQ(missed_args.type, Beg
stanisc 2017/05/31 01:17:52 Done.
289 if (!last_args.IsValid() || 289 obs->OnBeginFrame(missed_args);
290 (last_begin_frame_args_.frame_time > last_args.frame_time)) {
291 DCHECK(
292 (last_begin_frame_args_.source_id != last_args.source_id) ||
293 (last_begin_frame_args_.sequence_number > last_args.sequence_number))
294 << "current " << last_begin_frame_args_.AsValue()->ToString()
295 << ", last " << last_args.AsValue()->ToString();
296 BeginFrameArgs missed_args = last_begin_frame_args_;
297 missed_args.type = BeginFrameArgs::MISSED;
298 obs->OnBeginFrame(missed_args);
299 }
300 }
301 } 290 }
302 291
303 void ExternalBeginFrameSource::RemoveObserver(BeginFrameObserver* obs) { 292 void ExternalBeginFrameSource::RemoveObserver(BeginFrameObserver* obs) {
304 DCHECK(obs); 293 DCHECK(obs);
305 DCHECK(observers_.find(obs) != observers_.end()); 294 DCHECK(observers_.find(obs) != observers_.end());
306 295
307 observers_.erase(obs); 296 observers_.erase(obs);
308 if (observers_.empty()) { 297 if (observers_.empty()) {
309 last_begin_frame_args_ = BeginFrameArgs(); 298 last_begin_frame_args_ = BeginFrameArgs();
sunnyps 2017/05/30 22:13:17 nit: Can you remove this line: last_begin_frame_ar
stanisc 2017/05/31 01:17:52 Done.
310 client_->OnNeedsBeginFrames(false); 299 client_->OnNeedsBeginFrames(false);
311 } 300 }
312 } 301 }
313 302
314 void ExternalBeginFrameSource::DidFinishFrame(BeginFrameObserver* obs, 303 void ExternalBeginFrameSource::DidFinishFrame(BeginFrameObserver* obs,
315 const BeginFrameAck& ack) {} 304 const BeginFrameAck& ack) {}
316 305
317 bool ExternalBeginFrameSource::IsThrottled() const { 306 bool ExternalBeginFrameSource::IsThrottled() const {
318 return true; 307 return true;
319 } 308 }
(...skipping 18 matching lines...) Expand all
338 if (!last_args.IsValid() || (args.frame_time > last_args.frame_time)) { 327 if (!last_args.IsValid() || (args.frame_time > last_args.frame_time)) {
339 DCHECK((args.source_id != last_args.source_id) || 328 DCHECK((args.source_id != last_args.source_id) ||
340 (args.sequence_number > last_args.sequence_number)) 329 (args.sequence_number > last_args.sequence_number))
341 << "current " << args.AsValue()->ToString() << ", last " 330 << "current " << args.AsValue()->ToString() << ", last "
342 << last_args.AsValue()->ToString(); 331 << last_args.AsValue()->ToString();
343 obs->OnBeginFrame(args); 332 obs->OnBeginFrame(args);
344 } 333 }
345 } 334 }
346 } 335 }
347 336
337 bool ExternalBeginFrameSource::GetMissedBeginFrameArgs(
338 BeginFrameObserver* obs,
339 BeginFrameArgs* missed_args) {
340 if (!last_begin_frame_args_.IsValid())
341 return false;
342
343 const BeginFrameArgs& last_args = obs->LastUsedBeginFrameArgs();
344 if (last_args.IsValid() &&
345 last_begin_frame_args_.frame_time == last_args.frame_time) {
346 return false;
347 }
348
349 DCHECK((last_begin_frame_args_.source_id != last_args.source_id) ||
350 (last_begin_frame_args_.sequence_number > last_args.sequence_number))
351 << "current " << last_begin_frame_args_.AsValue()->ToString() << ", last "
352 << last_args.AsValue()->ToString();
353 *missed_args = last_begin_frame_args_;
354 missed_args->type = BeginFrameArgs::MISSED;
355 return true;
356 }
357
348 } // namespace cc 358 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698