[chromium] Do not allow infinite pending frames in CCFrameRateController

https://bugs.webkit.org/show_bug.cgi?id=94254

Patch by Brian Anderson <brianderson@chromium.org> on 2012-09-04
Reviewed by James Robinson.

Removes support for infinite pending frames in CCFrameRateController
if swap acks are available.

Functionality covered by existing tests.

* platform/graphics/chromium/cc/CCFrameRateController.cpp:
(WebCore::CCFrameRateController::CCFrameRateController):
(WebCore::CCFrameRateController::setMaxFramesPending):
(WebCore::CCFrameRateController::setSwapBuffersCompleteSupported):
(WebCore):
(WebCore::CCFrameRateController::onTimerTick):
(WebCore::CCFrameRateController::didBeginFrame):
(WebCore::CCFrameRateController::didFinishFrame):
* platform/graphics/chromium/cc/CCFrameRateController.h:
(CCFrameRateController):
* platform/graphics/chromium/cc/CCScheduler.cpp:
(WebCore::CCScheduler::setSwapBuffersCompleteSupported):
(WebCore):
* platform/graphics/chromium/cc/CCScheduler.h:
(CCScheduler):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::initializeRendererOnImplThread):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0b338471
2012-09-04 Brian Anderson <brianderson@chromium.org>
[chromium] Do not allow infinite pending frames in CCFrameRateController
https://bugs.webkit.org/show_bug.cgi?id=94254
Reviewed by James Robinson.
Removes support for infinite pending frames in CCFrameRateController
if swap acks are available.
Functionality covered by existing tests.
* platform/graphics/chromium/cc/CCFrameRateController.cpp:
(WebCore::CCFrameRateController::CCFrameRateController):
(WebCore::CCFrameRateController::setMaxFramesPending):
(WebCore::CCFrameRateController::setSwapBuffersCompleteSupported):
(WebCore):
(WebCore::CCFrameRateController::onTimerTick):
(WebCore::CCFrameRateController::didBeginFrame):
(WebCore::CCFrameRateController::didFinishFrame):
* platform/graphics/chromium/cc/CCFrameRateController.h:
(CCFrameRateController):
* platform/graphics/chromium/cc/CCScheduler.cpp:
(WebCore::CCScheduler::setSwapBuffersCompleteSupported):
(WebCore):
* platform/graphics/chromium/cc/CCScheduler.h:
(CCScheduler):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::initializeRendererOnImplThread):
2012-09-04 Tim Horton <timothy_horton@apple.com>
ASSERTion failure when SVG element is removed from document and readded
......@@ -31,6 +31,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 {
......@@ -52,9 +60,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);
......@@ -64,8 +73,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));
......@@ -96,6 +106,7 @@ void CCFrameRateController::setActive(bool active)
void CCFrameRateController::setMaxFramesPending(int maxFramesPending)
{
ASSERT(maxFramesPending > 0);
m_maxFramesPending = maxFramesPending;
}
......@@ -105,12 +116,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;
}
......@@ -118,8 +134,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();
}
......@@ -136,11 +151,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();
......
......@@ -70,6 +70,7 @@ public:
double nextTickTimeIfActivated();
void setTimebaseAndInterval(double timebase, double intervalSeconds);
void setSwapBuffersCompleteSupported(bool);
protected:
friend class CCFrameRateControllerTimeSourceAdapter;
......@@ -86,6 +87,7 @@ protected:
RefPtr<CCTimeSource> m_timeSource;
OwnPtr<CCFrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter;
bool m_active;
bool m_swapBuffersCompleteSupported;
// Members for unthrottled frame-rate.
bool m_isTimeSourceThrottling;
......
......@@ -106,6 +106,11 @@ void CCScheduler::setMaxFramesPending(int maxFramesPending)
m_frameRateController->setMaxFramesPending(maxFramesPending);
}
void CCScheduler::setSwapBuffersCompleteSupported(bool supported)
{
m_frameRateController->setSwapBuffersCompleteSupported(supported);
}
void CCScheduler::didSwapBuffersComplete()
{
TRACE_EVENT0("cc", "CCScheduler::didSwapBuffersComplete");
......
......@@ -97,6 +97,7 @@ public:
void beginFrameAborted();
void setMaxFramesPending(int);
void setSwapBuffersCompleteSupported(bool);
void didSwapBuffersComplete();
void didLoseContext();
......
......@@ -888,8 +888,8 @@ void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion
*initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitializationOnImplThread.release(), textureUploader);
if (*initializeSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities();
if (capabilities->usingSwapCompleteCallback)
m_schedulerOnImplThread->setMaxFramesPending(2);
m_schedulerOnImplThread->setSwapBuffersCompleteSupported(
capabilities->usingSwapCompleteCallback);
}
completion->signal();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment