| 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 10 matching lines...) Expand all Loading... |
| 21 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), \ | 21 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), \ |
| 22 name, \ | 22 name, \ |
| 23 arg1_name, \ | 23 arg1_name, \ |
| 24 arg1_val, \ | 24 arg1_val, \ |
| 25 arg2_name, \ | 25 arg2_name, \ |
| 26 arg2_val); | 26 arg2_val); |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace cc { | 29 namespace cc { |
| 30 | 30 |
| 31 // BeginFrameObserverMixIn ----------------------------------------------- | 31 // BeginFrameObserverBase ----------------------------------------------- |
| 32 BeginFrameObserverMixIn::BeginFrameObserverMixIn() | 32 BeginFrameObserverBase::BeginFrameObserverBase() |
| 33 : last_begin_frame_args_(), dropped_begin_frame_args_(0) { | 33 : last_begin_frame_args_(), dropped_begin_frame_args_(0) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 const BeginFrameArgs BeginFrameObserverMixIn::LastUsedBeginFrameArgs() const { | 36 const BeginFrameArgs BeginFrameObserverBase::LastUsedBeginFrameArgs() const { |
| 37 return last_begin_frame_args_; | 37 return last_begin_frame_args_; |
| 38 } | 38 } |
| 39 void BeginFrameObserverMixIn::OnBeginFrame(const BeginFrameArgs& args) { | 39 void BeginFrameObserverBase::OnBeginFrame(const BeginFrameArgs& args) { |
| 40 DEBUG_FRAMES("BeginFrameObserverMixIn::OnBeginFrame", | 40 DEBUG_FRAMES("BeginFrameObserverBase::OnBeginFrame", |
| 41 "last args", | 41 "last args", |
| 42 last_begin_frame_args_.AsValue(), | 42 last_begin_frame_args_.AsValue(), |
| 43 "new args", | 43 "new args", |
| 44 args.AsValue()); | 44 args.AsValue()); |
| 45 DCHECK(args.IsValid()); | 45 DCHECK(args.IsValid()); |
| 46 DCHECK(args.frame_time >= last_begin_frame_args_.frame_time); | 46 DCHECK(args.frame_time >= last_begin_frame_args_.frame_time); |
| 47 bool used = OnBeginFrameMixInDelegate(args); | 47 bool used = OnBeginFrameMixInDelegate(args); |
| 48 if (used) { | 48 if (used) { |
| 49 last_begin_frame_args_ = args; | 49 last_begin_frame_args_ = args; |
| 50 } else { | 50 } else { |
| 51 ++dropped_begin_frame_args_; | 51 ++dropped_begin_frame_args_; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void BeginFrameObserverMixIn::AsValueInto( | 55 void BeginFrameObserverBase::AsValueInto( |
| 56 base::trace_event::TracedValue* dict) const { | 56 base::trace_event::TracedValue* dict) const { |
| 57 dict->BeginDictionary("last_begin_frame_args_"); | 57 dict->BeginDictionary("last_begin_frame_args_"); |
| 58 last_begin_frame_args_.AsValueInto(dict); | 58 last_begin_frame_args_.AsValueInto(dict); |
| 59 dict->EndDictionary(); | 59 dict->EndDictionary(); |
| 60 dict->SetInteger("dropped_begin_frame_args_", dropped_begin_frame_args_); | 60 dict->SetInteger("dropped_begin_frame_args_", dropped_begin_frame_args_); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // BeginFrameSourceMixIn ------------------------------------------------------ | 63 // BeginFrameSourceMixIn ------------------------------------------------------ |
| 64 BeginFrameSourceMixIn::BeginFrameSourceMixIn() | 64 BeginFrameSourceMixIn::BeginFrameSourceMixIn() |
| 65 : observer_(NULL), | 65 : observer_(NULL), |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (!observer_->LastUsedBeginFrameArgs().IsValid()) | 469 if (!observer_->LastUsedBeginFrameArgs().IsValid()) |
| 470 return true; | 470 return true; |
| 471 | 471 |
| 472 // Only allow new args have a *strictly bigger* frame_time value and statisfy | 472 // Only allow new args have a *strictly bigger* frame_time value and statisfy |
| 473 // minimum interval requirement. | 473 // minimum interval requirement. |
| 474 return (args.frame_time >= | 474 return (args.frame_time >= |
| 475 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); | 475 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); |
| 476 } | 476 } |
| 477 | 477 |
| 478 } // namespace cc | 478 } // namespace cc |
| OLD | NEW |