OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/frame_rate_controller.h" | 5 #include "cc/scheduler/frame_rate_controller.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 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/scheduler/delay_based_time_source.h" | 10 #include "cc/scheduler/delay_based_time_source.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 }; | 32 }; |
33 | 33 |
34 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer) | 34 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer) |
35 : client_(NULL), | 35 : client_(NULL), |
36 num_frames_pending_(0), | 36 num_frames_pending_(0), |
37 max_frames_pending_(0), | 37 max_frames_pending_(0), |
38 time_source_(timer), | 38 time_source_(timer), |
39 active_(false), | 39 active_(false), |
40 swap_buffers_complete_supported_(true), | 40 swap_buffers_complete_supported_(true), |
41 is_time_source_throttling_(true), | 41 is_time_source_throttling_(true), |
42 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 42 thread_(NULL), |
43 thread_(NULL) { | 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
44 time_source_client_adapter_ = | 44 time_source_client_adapter_ = |
45 FrameRateControllerTimeSourceAdapter::Create(this); | 45 FrameRateControllerTimeSourceAdapter::Create(this); |
46 time_source_->SetClient(time_source_client_adapter_.get()); | 46 time_source_->SetClient(time_source_client_adapter_.get()); |
47 } | 47 } |
48 | 48 |
49 FrameRateController::FrameRateController(Thread* thread) | 49 FrameRateController::FrameRateController(Thread* thread) |
50 : client_(NULL), | 50 : client_(NULL), |
51 num_frames_pending_(0), | 51 num_frames_pending_(0), |
52 max_frames_pending_(0), | 52 max_frames_pending_(0), |
53 active_(false), | 53 active_(false), |
54 swap_buffers_complete_supported_(true), | 54 swap_buffers_complete_supported_(true), |
55 is_time_source_throttling_(false), | 55 is_time_source_throttling_(false), |
56 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 56 thread_(thread), |
57 thread_(thread) {} | 57 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} |
58 | 58 |
59 FrameRateController::~FrameRateController() { | 59 FrameRateController::~FrameRateController() { |
60 if (is_time_source_throttling_) | 60 if (is_time_source_throttling_) |
61 time_source_->SetActive(false); | 61 time_source_->SetActive(false); |
62 } | 62 } |
63 | 63 |
64 void FrameRateController::SetActive(bool active) { | 64 void FrameRateController::SetActive(bool active) { |
65 if (active_ == active) | 65 if (active_ == active) |
66 return; | 66 return; |
67 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); | 67 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 base::TimeTicks FrameRateController::LastTickTime() { | 146 base::TimeTicks FrameRateController::LastTickTime() { |
147 if (is_time_source_throttling_) | 147 if (is_time_source_throttling_) |
148 return time_source_->LastTickTime(); | 148 return time_source_->LastTickTime(); |
149 | 149 |
150 return base::TimeTicks::Now(); | 150 return base::TimeTicks::Now(); |
151 } | 151 } |
152 | 152 |
153 } // namespace cc | 153 } // namespace cc |
OLD | NEW |