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

Unified Diff: cc/CCFrameRateController.cpp

Issue 10907075: Roll cc snapshot up to 127605 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/CCLayerTreeHost.cpp » ('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
index b264bc27ebcd4259b0eb6af669f4dc0d214b5198..15ff94c03c03c2e42a3cd379080d68c83226ba2b 100644
--- a/cc/CCFrameRateController.cpp
+++ b/cc/CCFrameRateController.cpp
@@ -11,6 +11,14 @@
#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 WebCore {
class CCFrameRateControllerTimeSourceAdapter : public CCTimeSourceClient {
@@ -32,9 +40,10 @@ private:
CCFrameRateController::CCFrameRateController(PassRefPtr<CCTimeSource> timer)
: m_client(0)
, m_numFramesPending(0)
- , m_maxFramesPending(0)
+ , m_maxFramesPending(defaultMaxFramesPending)
, m_timeSource(timer)
, m_active(false)
+ , m_swapBuffersCompleteSupported(true)
, m_isTimeSourceThrottling(true)
{
m_timeSourceClientAdapter = CCFrameRateControllerTimeSourceAdapter::create(this);
@@ -44,8 +53,9 @@ CCFrameRateController::CCFrameRateController(PassRefPtr<CCTimeSource> timer)
CCFrameRateController::CCFrameRateController(CCThread* thread)
: m_client(0)
, m_numFramesPending(0)
- , m_maxFramesPending(0)
+ , m_maxFramesPending(defaultMaxFramesPending)
, m_active(false)
+ , m_swapBuffersCompleteSupported(true)
, m_isTimeSourceThrottling(false)
{
m_manualTicker = adoptPtr(new CCTimer(thread, this));
@@ -76,6 +86,7 @@ void CCFrameRateController::setActive(bool active)
void CCFrameRateController::setMaxFramesPending(int maxFramesPending)
{
+ ASSERT(maxFramesPending > 0);
m_maxFramesPending = maxFramesPending;
}
@@ -85,12 +96,17 @@ void CCFrameRateController::setTimebaseAndInterval(double timebase, double inter
m_timeSource->setTimebaseAndInterval(timebase, intervalSeconds);
}
+void CCFrameRateController::setSwapBuffersCompleteSupported(bool supported)
+{
+ m_swapBuffersCompleteSupported = supported;
+}
+
void CCFrameRateController::onTimerTick()
{
ASSERT(m_active);
// Don't forward the tick if we have too many frames in flight.
- if (m_maxFramesPending && m_numFramesPending >= m_maxFramesPending) {
+ if (m_numFramesPending >= m_maxFramesPending) {
TRACE_EVENT0("cc", "CCFrameRateController::onTimerTickButMaxFramesPending");
return;
}
@@ -98,8 +114,7 @@ void CCFrameRateController::onTimerTick()
if (m_client)
m_client->vsyncTick();
- if (!m_isTimeSourceThrottling
- && (!m_maxFramesPending || m_numFramesPending < m_maxFramesPending))
+ if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && m_numFramesPending < m_maxFramesPending)
postManualTick();
}
@@ -116,11 +131,16 @@ void CCFrameRateController::onTimerFired()
void CCFrameRateController::didBeginFrame()
{
- m_numFramesPending++;
+ if (m_swapBuffersCompleteSupported)
+ m_numFramesPending++;
+ else if (!m_isTimeSourceThrottling)
+ postManualTick();
}
void CCFrameRateController::didFinishFrame()
{
+ ASSERT(m_swapBuffersCompleteSupported);
+
m_numFramesPending--;
if (!m_isTimeSourceThrottling)
postManualTick();
« no previous file with comments | « cc/CCFrameRateController.h ('k') | cc/CCLayerTreeHost.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698