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

Unified Diff: cc/CCFrameRateController.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCFrameRateController.h ('k') | cc/CCFrameRateCounter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCFrameRateController.cpp
diff --git a/cc/CCFrameRateController.cpp b/cc/CCFrameRateController.cpp
deleted file mode 100644
index c996ebd767a20ab1f92506b1362d4764d22e5b70..0000000000000000000000000000000000000000
--- a/cc/CCFrameRateController.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-#include "CCFrameRateController.h"
-
-#include "CCDelayBasedTimeSource.h"
-#include "CCTimeSource.h"
-#include "TraceEvent.h"
-#include <wtf/CurrentTime.h>
-
-namespace {
-
-// This will be the maximum number of pending frames unless
-// CCFrameRateController::setMaxFramesPending is called.
-const int defaultMaxFramesPending = 2;
-
-} // namespace
-
-namespace cc {
-
-class CCFrameRateControllerTimeSourceAdapter : public CCTimeSourceClient {
-public:
- static scoped_ptr<CCFrameRateControllerTimeSourceAdapter> create(CCFrameRateController* frameRateController) {
- return make_scoped_ptr(new CCFrameRateControllerTimeSourceAdapter(frameRateController));
- }
- virtual ~CCFrameRateControllerTimeSourceAdapter() {}
-
- virtual void onTimerTick() OVERRIDE {
- m_frameRateController->onTimerTick();
- }
-
-private:
- explicit CCFrameRateControllerTimeSourceAdapter(CCFrameRateController* frameRateController)
- : m_frameRateController(frameRateController) {}
-
- CCFrameRateController* m_frameRateController;
-};
-
-CCFrameRateController::CCFrameRateController(PassRefPtr<CCTimeSource> timer)
- : m_client(0)
- , m_numFramesPending(0)
- , m_maxFramesPending(defaultMaxFramesPending)
- , m_timeSource(timer)
- , m_active(false)
- , m_swapBuffersCompleteSupported(true)
- , m_isTimeSourceThrottling(true)
-{
- m_timeSourceClientAdapter = CCFrameRateControllerTimeSourceAdapter::create(this);
- m_timeSource->setClient(m_timeSourceClientAdapter.get());
-}
-
-CCFrameRateController::CCFrameRateController(CCThread* thread)
- : m_client(0)
- , m_numFramesPending(0)
- , m_maxFramesPending(defaultMaxFramesPending)
- , m_active(false)
- , m_swapBuffersCompleteSupported(true)
- , m_isTimeSourceThrottling(false)
- , m_manualTicker(new CCTimer(thread, this))
-{
-}
-
-CCFrameRateController::~CCFrameRateController()
-{
- if (m_isTimeSourceThrottling)
- m_timeSource->setActive(false);
-}
-
-void CCFrameRateController::setActive(bool active)
-{
- if (m_active == active)
- return;
- TRACE_EVENT1("cc", "CCFrameRateController::setActive", "active", active);
- m_active = active;
-
- if (m_isTimeSourceThrottling)
- m_timeSource->setActive(active);
- else {
- if (active)
- postManualTick();
- else
- m_manualTicker->stop();
- }
-}
-
-void CCFrameRateController::setMaxFramesPending(int maxFramesPending)
-{
- ASSERT(maxFramesPending > 0);
- m_maxFramesPending = maxFramesPending;
-}
-
-void CCFrameRateController::setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interval)
-{
- if (m_isTimeSourceThrottling)
- m_timeSource->setTimebaseAndInterval(timebase, interval);
-}
-
-void CCFrameRateController::setSwapBuffersCompleteSupported(bool supported)
-{
- m_swapBuffersCompleteSupported = supported;
-}
-
-void CCFrameRateController::onTimerTick()
-{
- ASSERT(m_active);
-
- // Check if we have too many frames in flight.
- bool throttled = m_numFramesPending >= m_maxFramesPending;
-
- if (m_client)
- m_client->vsyncTick(throttled);
-
- if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && m_numFramesPending < m_maxFramesPending)
- postManualTick();
-}
-
-void CCFrameRateController::postManualTick()
-{
- if (m_active)
- m_manualTicker->startOneShot(0);
-}
-
-void CCFrameRateController::onTimerFired()
-{
- onTimerTick();
-}
-
-void CCFrameRateController::didBeginFrame()
-{
- if (m_swapBuffersCompleteSupported)
- m_numFramesPending++;
- else if (!m_isTimeSourceThrottling)
- postManualTick();
-}
-
-void CCFrameRateController::didFinishFrame()
-{
- ASSERT(m_swapBuffersCompleteSupported);
-
- m_numFramesPending--;
- if (!m_isTimeSourceThrottling)
- postManualTick();
-}
-
-void CCFrameRateController::didAbortAllPendingFrames()
-{
- m_numFramesPending = 0;
-}
-
-base::TimeTicks CCFrameRateController::nextTickTime()
-{
- if (m_isTimeSourceThrottling)
- return m_timeSource->nextTickTime();
-
- return base::TimeTicks();
-}
-
-}
« no previous file with comments | « cc/CCFrameRateController.h ('k') | cc/CCFrameRateCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698