| 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/frame_rate_controller.h" | 5 #include "cc/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/delay_based_time_source.h" | 9 #include "cc/delay_based_time_source.h" |
| 10 #include "cc/time_source.h" | 10 #include "cc/time_source.h" |
| 11 #include "cc/thread.h" | 11 #include "cc/thread.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 class FrameRateControllerTimeSourceAdapter : public TimeSourceClient { | 15 class FrameRateControllerTimeSourceAdapter : public TimeSourceClient { |
| 16 public: | 16 public: |
| 17 static scoped_ptr<FrameRateControllerTimeSourceAdapter> create(FrameRateCont
roller* frameRateController) { | 17 static scoped_ptr<FrameRateControllerTimeSourceAdapter> Create(FrameRateCont
roller* frameRateController) { |
| 18 return make_scoped_ptr(new FrameRateControllerTimeSourceAdapter(frameRat
eController)); | 18 return make_scoped_ptr(new FrameRateControllerTimeSourceAdapter(frameRat
eController)); |
| 19 } | 19 } |
| 20 virtual ~FrameRateControllerTimeSourceAdapter() {} | 20 virtual ~FrameRateControllerTimeSourceAdapter() {} |
| 21 | 21 |
| 22 virtual void onTimerTick() OVERRIDE { | 22 virtual void onTimerTick() OVERRIDE { |
| 23 m_frameRateController->onTimerTick(); | 23 m_frameRateController->onTimerTick(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 explicit FrameRateControllerTimeSourceAdapter(FrameRateController* frameRate
Controller) | 27 explicit FrameRateControllerTimeSourceAdapter(FrameRateController* frameRate
Controller) |
| 28 : m_frameRateController(frameRateController) {} | 28 : m_frameRateController(frameRateController) {} |
| 29 | 29 |
| 30 FrameRateController* m_frameRateController; | 30 FrameRateController* m_frameRateController; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer) | 33 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer) |
| 34 : m_client(0) | 34 : m_client(0) |
| 35 , m_numFramesPending(0) | 35 , m_numFramesPending(0) |
| 36 , m_maxFramesPending(0) | 36 , m_maxFramesPending(0) |
| 37 , m_timeSource(timer) | 37 , m_timeSource(timer) |
| 38 , m_active(false) | 38 , m_active(false) |
| 39 , m_swapBuffersCompleteSupported(true) | 39 , m_swapBuffersCompleteSupported(true) |
| 40 , m_isTimeSourceThrottling(true) | 40 , m_isTimeSourceThrottling(true) |
| 41 , m_thread(0) | 41 , m_thread(0) |
| 42 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 42 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 43 { | 43 { |
| 44 m_timeSourceClientAdapter = FrameRateControllerTimeSourceAdapter::create(thi
s); | 44 m_timeSourceClientAdapter = FrameRateControllerTimeSourceAdapter::Create(thi
s); |
| 45 m_timeSource->setClient(m_timeSourceClientAdapter.get()); | 45 m_timeSource->setClient(m_timeSourceClientAdapter.get()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 FrameRateController::FrameRateController(Thread* thread) | 48 FrameRateController::FrameRateController(Thread* thread) |
| 49 : m_client(0) | 49 : m_client(0) |
| 50 , m_numFramesPending(0) | 50 , m_numFramesPending(0) |
| 51 , m_maxFramesPending(0) | 51 , m_maxFramesPending(0) |
| 52 , m_active(false) | 52 , m_active(false) |
| 53 , m_swapBuffersCompleteSupported(true) | 53 , m_swapBuffersCompleteSupported(true) |
| 54 , m_isTimeSourceThrottling(false) | 54 , m_isTimeSourceThrottling(false) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 base::TimeTicks FrameRateController::nextTickTime() | 148 base::TimeTicks FrameRateController::nextTickTime() |
| 149 { | 149 { |
| 150 if (m_isTimeSourceThrottling) | 150 if (m_isTimeSourceThrottling) |
| 151 return m_timeSource->nextTickTime(); | 151 return m_timeSource->nextTickTime(); |
| 152 | 152 |
| 153 return base::TimeTicks(); | 153 return base::TimeTicks(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace cc | 156 } // namespace cc |
| OLD | NEW |