Commit 64ad8b25 authored by andersca@apple.com's avatar andersca@apple.com

2011-03-11 Anders Carlsson <andersca@apple.com>

        Reviewed by Dan Bernstein.

        Don't paint more than 60 times per second
        https://bugs.webkit.org/show_bug.cgi?id=56206
        <rdar://problem/9085989>

        * WebProcess/WebPage/DrawingAreaImpl.cpp:
        (WebKit::DrawingAreaImpl::DrawingAreaImpl):
        Initialize m_lastDisplayTime to 0. Change the display timer to call displayTimerFired.

        (WebKit::DrawingAreaImpl::didUpdate):
        Call displayTimerFired instead of display.

        (WebKit::DrawingAreaImpl::displayTimerFired):
        If we're asked to paint again less than 1/60th of a second after we've already painted,
        defer painting.

        (WebKit::DrawingAreaImpl::display):
        Update m_lastDisplayTime.


git-svn-id: svn://svn.chromium.org/blink/trunk@80875 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fe7ffcba
2011-03-11 Anders Carlsson <andersca@apple.com>
Reviewed by Dan Bernstein.
Don't paint more than 60 times per second
https://bugs.webkit.org/show_bug.cgi?id=56206
<rdar://problem/9085989>
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::DrawingAreaImpl):
Initialize m_lastDisplayTime to 0. Change the display timer to call displayTimerFired.
(WebKit::DrawingAreaImpl::didUpdate):
Call displayTimerFired instead of display.
(WebKit::DrawingAreaImpl::displayTimerFired):
If we're asked to paint again less than 1/60th of a second after we've already painted,
defer painting.
(WebKit::DrawingAreaImpl::display):
Update m_lastDisplayTime.
2011-03-11 Mark Rowe <mrowe@apple.com>
Reviewed by Alice Liu.
......
......@@ -64,7 +64,8 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete
, m_isWaitingForDidUpdate(false)
, m_isPaintingSuspended(!parameters.isVisible)
, m_alwaysUseCompositing(false)
, m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display)
, m_lastDisplayTime(0)
, m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::displayTimerFired)
, m_exitCompositingTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode)
{
if (webPage->corePage()->settings()->acceleratedDrawingEnabled())
......@@ -327,8 +328,8 @@ void DrawingAreaImpl::didUpdate()
m_isWaitingForDidUpdate = false;
// Display if needed.
display();
// Display if needed. We call displayTimerFired here since it will throttle updates to 60fps.
displayTimerFired();
}
void DrawingAreaImpl::suspendPainting()
......@@ -428,6 +429,21 @@ void DrawingAreaImpl::scheduleDisplay()
m_displayTimer.startOneShot(0);
}
void DrawingAreaImpl::displayTimerFired()
{
static const double minimumFrameInterval = 1.0 / 60.0;
double timeSinceLastDisplay = currentTime() - m_lastDisplayTime;
double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay;
if (timeUntilNextDisplay > 0) {
m_displayTimer.startOneShot(timeUntilNextDisplay);
return;
}
display();
}
void DrawingAreaImpl::display()
{
ASSERT(!m_layerTreeHost);
......@@ -534,6 +550,8 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
// Layout can trigger more calls to setNeedsDisplay and we don't want to process them
// until the UI process has painted the update, so we stop the timer here.
m_displayTimer.stop();
m_lastDisplayTime = currentTime();
}
......
......@@ -72,6 +72,7 @@ private:
void exitAcceleratedCompositingMode();
void scheduleDisplay();
void displayTimerFired();
void display();
void display(UpdateInfo&);
......@@ -97,6 +98,8 @@ private:
bool m_isPaintingSuspended;
bool m_alwaysUseCompositing;
double m_lastDisplayTime;
RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;
......
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