Reviewed by Sam Weinig.
Suspend/resume painting as the WKView visibility changes
https://bugs.webkit.org/show_bug.cgi?id=52738
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::visibilityDidChange):
Add new member function. It should really be pure virtual once setPageIsVisible
is removed.
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::visibilityDidChange):
Send SuspendPainting/ResumePainting messages based on whether the view is visible or not.
(WebKit::DrawingAreaProxyImpl::setPageIsVisible):
Make this a stub; it should really be removed.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewStateDidChange):
Call visibilityDidChange.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isViewVisible):
Add new getter.
* WebProcess/WebPage/DrawingArea.messages.in:
Add SuspendPainting and ResumePainting messages.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::DrawingAreaImpl):
Initialize m_isPaintingSuspended.
(WebKit::DrawingAreaImpl::suspendPainting):
Set m_isPaintingSuspended to true and stop the display timer.
(WebKit::DrawingAreaImpl::resumePainting):
Set m_isPaintingSuspended to false.
(WebKit::DrawingAreaImpl::scheduleDisplay):
(WebKit::DrawingAreaImpl::display):
Bail if m_isPaintingSuspended is true.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76157
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-01-19 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Suspend/resume painting as the WKView visibility changes
+ https://bugs.webkit.org/show_bug.cgi?id=52738
+
+ * UIProcess/DrawingAreaProxy.h:
+ (WebKit::DrawingAreaProxy::visibilityDidChange):
+ Add new member function. It should really be pure virtual once setPageIsVisible
+ is removed.
+
+ * UIProcess/DrawingAreaProxyImpl.cpp:
+ (WebKit::DrawingAreaProxyImpl::visibilityDidChange):
+ Send SuspendPainting/ResumePainting messages based on whether the view is visible or not.
+
+ (WebKit::DrawingAreaProxyImpl::setPageIsVisible):
+ Make this a stub; it should really be removed.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::viewStateDidChange):
+ Call visibilityDidChange.
+
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::isViewVisible):
+ Add new getter.
+
+ * WebProcess/WebPage/DrawingArea.messages.in:
+ Add SuspendPainting and ResumePainting messages.
+
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::DrawingAreaImpl):
+ Initialize m_isPaintingSuspended.
+
+ (WebKit::DrawingAreaImpl::suspendPainting):
+ Set m_isPaintingSuspended to true and stop the display timer.
+
+ (WebKit::DrawingAreaImpl::resumePainting):
+ Set m_isPaintingSuspended to false.
+
+ (WebKit::DrawingAreaImpl::scheduleDisplay):
+ (WebKit::DrawingAreaImpl::display):
+ Bail if m_isPaintingSuspended is true.
+
2011-01-19 Andreas Kling <kling@webkit.org>
Reviewed by Simon Hausmann.
virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext) = 0;
virtual void sizeDidChange() = 0;
+
+ // FIXME: visibilityDidChange() should be pure virtual.
+ virtual void visibilityDidChange() { }
+
virtual void setPageIsVisible(bool isVisible) = 0;
#if USE(ACCELERATED_COMPOSITING)
sendSetSize();
}
-void DrawingAreaProxyImpl::setPageIsVisible(bool pageIsVisible)
+void DrawingAreaProxyImpl::visibilityDidChange()
+{
+ if (!m_webPageProxy->isViewVisible()) {
+ // Suspend painting.
+ m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
+ return;
+ }
+
+ // Resume painting.
+ m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
+}
+
+void DrawingAreaProxyImpl::setPageIsVisible(bool)
{
- // FIXME: Implement.
}
void DrawingAreaProxyImpl::attachCompositingContext(uint32_t contextID)
virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
virtual void sizeDidChange();
+ virtual void visibilityDidChange();
virtual void setPageIsVisible(bool);
virtual void attachCompositingContext(uint32_t contextID);
virtual void detachCompositingContext();
bool isVisible = m_pageClient->isViewVisible();
if (isVisible != m_isVisible) {
m_isVisible = isVisible;
+ m_drawingArea->visibilityDidChange();
m_drawingArea->setPageIsVisible(isVisible);
}
}
void viewStateDidChange(ViewStateFlags flags);
WebCore::IntSize viewSize() const;
+ bool isViewVisible() const { return m_isVisible; }
void executeEditCommand(const String& commandName);
void validateMenuItem(const String& commandName);
// FIXME: These should be pure virtual.
virtual void setSize(const WebCore::IntSize&) { }
virtual void didUpdate() { }
+ virtual void suspendPainting() { }
+ virtual void resumePainting() { }
};
} // namespace WebKit
messages -> DrawingArea {
SetSize(WebCore::IntSize size)
- DidUpdate()
+ DidUpdate()
+ SuspendPainting()
+ ResumePainting()
}
DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters)
: DrawingArea(DrawingAreaInfo::Impl, parameters.drawingAreaInfo.identifier, webPage)
, m_isWaitingForDidUpdate(false)
+ , m_isPaintingSuspended(!parameters.isVisible)
, m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display)
{
}
display();
}
+void DrawingAreaImpl::suspendPainting()
+{
+ ASSERT(!m_isPaintingSuspended);
+
+ m_isPaintingSuspended = true;
+ m_displayTimer.stop();
+}
+
+void DrawingAreaImpl::resumePainting()
+{
+ ASSERT(m_isPaintingSuspended);
+
+ m_isPaintingSuspended = false;
+
+ // FIXME: Repaint if needed.
+}
+
void DrawingAreaImpl::scheduleDisplay()
{
if (m_isWaitingForDidUpdate)
return;
+ if (m_isPaintingSuspended)
+ return;
+
if (m_dirtyRegion.isEmpty())
return;
void DrawingAreaImpl::display()
{
+ ASSERT(!m_isWaitingForDidUpdate);
+
+ if (m_isPaintingSuspended)
+ return;
+
if (m_dirtyRegion.isEmpty())
return;
// CoreIPC message handlers.
virtual void setSize(const WebCore::IntSize&);
virtual void didUpdate();
+ virtual void suspendPainting();
+ virtual void resumePainting();
void scheduleDisplay();
void display();
// Whether we're waiting for a DidUpdate message. Used for throttling paints so that the
// web process won't paint more frequent than the UI process can handle.
bool m_isWaitingForDidUpdate;
-
+
+ // Whether painting is suspended. We'll still keep track of the dirty region but we
+ // won't paint until painting has resumed again.
+ bool m_isPaintingSuspended;
+
RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
};