summaryrefslogtreecommitdiffstats
path: root/cc/frame_rate_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc/frame_rate_controller.cc')
-rw-r--r--cc/frame_rate_controller.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/cc/frame_rate_controller.cc b/cc/frame_rate_controller.cc
index a9fe60f..436e80d 100644
--- a/cc/frame_rate_controller.cc
+++ b/cc/frame_rate_controller.cc
@@ -10,6 +10,14 @@
#include "cc/time_source.h"
#include "cc/thread.h"
+namespace {
+
+// This will be the maximum number of pending frames unless
+// FrameRateController::setMaxFramesPending is called.
+const int defaultMaxFramesPending = 2;
+
+} // namespace
+
namespace cc {
class FrameRateControllerTimeSourceAdapter : public TimeSourceClient {
@@ -33,7 +41,7 @@ private:
FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer)
: m_client(0)
, m_numFramesPending(0)
- , m_maxFramesPending(0)
+ , m_maxFramesPending(defaultMaxFramesPending)
, m_timeSource(timer)
, m_active(false)
, m_swapBuffersCompleteSupported(true)
@@ -48,7 +56,7 @@ FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer)
FrameRateController::FrameRateController(Thread* thread)
: m_client(0)
, m_numFramesPending(0)
- , m_maxFramesPending(0)
+ , m_maxFramesPending(defaultMaxFramesPending)
, m_active(false)
, m_swapBuffersCompleteSupported(true)
, m_isTimeSourceThrottling(false)
@@ -82,7 +90,7 @@ void FrameRateController::setActive(bool active)
void FrameRateController::setMaxFramesPending(int maxFramesPending)
{
- DCHECK(maxFramesPending >= 0);
+ DCHECK(maxFramesPending > 0);
m_maxFramesPending = maxFramesPending;
}
@@ -102,13 +110,13 @@ void FrameRateController::onTimerTick()
DCHECK(m_active);
// Check if we have too many frames in flight.
- bool throttled = m_maxFramesPending && m_numFramesPending >= m_maxFramesPending;
+ bool throttled = m_numFramesPending >= m_maxFramesPending;
TRACE_COUNTER_ID1("cc", "ThrottledVSyncInterval", m_thread, throttled);
if (m_client)
m_client->vsyncTick(throttled);
- if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && !throttled)
+ if (m_swapBuffersCompleteSupported && !m_isTimeSourceThrottling && m_numFramesPending < m_maxFramesPending)
postManualTick();
}