| OLD | NEW |
| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetMinimumInterval", | 304 DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetMinimumInterval", |
| 305 "current minimum (us)", | 305 "current minimum (us)", |
| 306 minimum_interval_.InMicroseconds(), | 306 minimum_interval_.InMicroseconds(), |
| 307 "new minimum (us)", | 307 "new minimum (us)", |
| 308 new_minimum_interval.InMicroseconds()); | 308 new_minimum_interval.InMicroseconds()); |
| 309 DCHECK_GE(new_minimum_interval.ToInternalValue(), 0); | 309 DCHECK_GE(new_minimum_interval.ToInternalValue(), 0); |
| 310 minimum_interval_ = new_minimum_interval; | 310 minimum_interval_ = new_minimum_interval; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void BeginFrameSourceMultiplexer::AddSource(BeginFrameSource* new_source) { | 313 void BeginFrameSourceMultiplexer::AddSource(BeginFrameSource* new_source) { |
| 314 DEBUG_FRAMES("BeginFrameSourceMultiplexer::AddSource", | 314 DEBUG_FRAMES("BeginFrameSourceMultiplexer::AddSource", "current active", |
| 315 "current active", | 315 active_source_, "source to be added", new_source); |
| 316 active_source_, | |
| 317 "source to remove", | |
| 318 new_source); | |
| 319 DCHECK(new_source); | 316 DCHECK(new_source); |
| 320 DCHECK(!HasSource(new_source)); | 317 DCHECK(!HasSource(new_source)); |
| 321 | 318 |
| 322 source_list_.insert(new_source); | 319 source_list_.insert(new_source); |
| 323 | 320 |
| 324 // If there is no active source, set the new one as the active one. | 321 // If there is no active source, set the new one as the active one. |
| 325 if (!active_source_) | 322 if (!active_source_) |
| 326 SetActiveSource(new_source); | 323 SetActiveSource(new_source); |
| 327 } | 324 } |
| 328 | 325 |
| 329 void BeginFrameSourceMultiplexer::RemoveSource( | 326 void BeginFrameSourceMultiplexer::RemoveSource( |
| 330 BeginFrameSource* existing_source) { | 327 BeginFrameSource* existing_source) { |
| 331 DEBUG_FRAMES("BeginFrameSourceMultiplexer::RemoveSource", | 328 DEBUG_FRAMES("BeginFrameSourceMultiplexer::RemoveSource", "current active", |
| 332 "current active", | 329 active_source_, "source to be removed", existing_source); |
| 333 active_source_, | |
| 334 "source to remove", | |
| 335 existing_source); | |
| 336 DCHECK(existing_source); | 330 DCHECK(existing_source); |
| 337 DCHECK(HasSource(existing_source)); | 331 DCHECK(HasSource(existing_source)); |
| 338 DCHECK_NE(existing_source, active_source_); | 332 DCHECK_NE(existing_source, active_source_); |
| 339 source_list_.erase(existing_source); | 333 source_list_.erase(existing_source); |
| 340 } | 334 } |
| 341 | 335 |
| 342 void BeginFrameSourceMultiplexer::SetActiveSource( | 336 void BeginFrameSourceMultiplexer::SetActiveSource( |
| 343 BeginFrameSource* new_source) { | 337 BeginFrameSource* new_source) { |
| 344 DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetActiveSource", | 338 DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetActiveSource", |
| 345 "current active", | 339 "current active", |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (!observer_->LastUsedBeginFrameArgs().IsValid()) | 465 if (!observer_->LastUsedBeginFrameArgs().IsValid()) |
| 472 return true; | 466 return true; |
| 473 | 467 |
| 474 // Only allow new args have a *strictly bigger* frame_time value and statisfy | 468 // Only allow new args have a *strictly bigger* frame_time value and statisfy |
| 475 // minimum interval requirement. | 469 // minimum interval requirement. |
| 476 return (args.frame_time >= | 470 return (args.frame_time >= |
| 477 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); | 471 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); |
| 478 } | 472 } |
| 479 | 473 |
| 480 } // namespace cc | 474 } // namespace cc |
| OLD | NEW |