Changeset 76157 in webkit


Ignore:
Timestamp:
Jan 19, 2011 1:56:58 PM (13 years ago)
Author:
andersca@apple.com
Message:

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.

Location:
trunk/Source/WebKit2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r76149 r76157  
     12011-01-19  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Suspend/resume painting as the WKView visibility changes
     6        https://bugs.webkit.org/show_bug.cgi?id=52738
     7
     8        * UIProcess/DrawingAreaProxy.h:
     9        (WebKit::DrawingAreaProxy::visibilityDidChange):
     10        Add new member function. It should really be pure virtual once setPageIsVisible
     11        is removed.
     12
     13        * UIProcess/DrawingAreaProxyImpl.cpp:
     14        (WebKit::DrawingAreaProxyImpl::visibilityDidChange):
     15        Send SuspendPainting/ResumePainting messages based on whether the view is visible or not.
     16
     17        (WebKit::DrawingAreaProxyImpl::setPageIsVisible):
     18        Make this a stub; it should really be removed.
     19
     20        * UIProcess/WebPageProxy.cpp:
     21        (WebKit::WebPageProxy::viewStateDidChange):
     22        Call visibilityDidChange.
     23
     24        * UIProcess/WebPageProxy.h:
     25        (WebKit::WebPageProxy::isViewVisible):
     26        Add new getter.
     27
     28        * WebProcess/WebPage/DrawingArea.messages.in:
     29        Add SuspendPainting and ResumePainting messages.
     30
     31        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     32        (WebKit::DrawingAreaImpl::DrawingAreaImpl):
     33        Initialize m_isPaintingSuspended.
     34
     35        (WebKit::DrawingAreaImpl::suspendPainting):
     36        Set m_isPaintingSuspended to true and stop the display timer.
     37
     38        (WebKit::DrawingAreaImpl::resumePainting):
     39        Set m_isPaintingSuspended to false.
     40
     41        (WebKit::DrawingAreaImpl::scheduleDisplay):
     42        (WebKit::DrawingAreaImpl::display):
     43        Bail if m_isPaintingSuspended is true.
     44
    1452011-01-19  Andreas Kling  <kling@webkit.org>
    246
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h

    r76143 r76157  
    6666
    6767    virtual void sizeDidChange() = 0;
     68
     69    // FIXME: visibilityDidChange() should be pure virtual.
     70    virtual void visibilityDidChange() { }
     71
    6872    virtual void setPageIsVisible(bool isVisible) = 0;
    6973   
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp

    r76143 r76157  
    8383}
    8484
    85 void DrawingAreaProxyImpl::setPageIsVisible(bool pageIsVisible)
     85void DrawingAreaProxyImpl::visibilityDidChange()
    8686{
    87     // FIXME: Implement.
     87    if (!m_webPageProxy->isViewVisible()) {
     88        // Suspend painting.
     89        m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
     90        return;
     91    }
     92
     93    // Resume painting.
     94    m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
     95}
     96
     97void DrawingAreaProxyImpl::setPageIsVisible(bool)
     98{
    8899}
    89100
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h

    r76143 r76157  
    4747    virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
    4848    virtual void sizeDidChange();
     49    virtual void visibilityDidChange();
    4950    virtual void setPageIsVisible(bool);
    5051    virtual void attachCompositingContext(uint32_t contextID);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r76092 r76157  
    498498        if (isVisible != m_isVisible) {
    499499            m_isVisible = isVisible;
     500            m_drawingArea->visibilityDidChange();
    500501            m_drawingArea->setPageIsVisible(isVisible);
    501502        }
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r76087 r76157  
    186186
    187187    WebCore::IntSize viewSize() const;
     188    bool isViewVisible() const { return m_isVisible; }
    188189
    189190    void executeEditCommand(const String& commandName);
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r76135 r76157  
    8383    virtual void setSize(const WebCore::IntSize&) { }
    8484    virtual void didUpdate() { }
     85    virtual void suspendPainting() { }
     86    virtual void resumePainting() { }
    8587};
    8688
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in

    r75630 r76157  
    2323messages -> DrawingArea {
    2424    SetSize(WebCore::IntSize size)
    25     DidUpdate()   
     25    DidUpdate()
     26    SuspendPainting()
     27    ResumePainting()
    2628}
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp

    r76143 r76157  
    5454    : DrawingArea(DrawingAreaInfo::Impl, parameters.drawingAreaInfo.identifier, webPage)
    5555    , m_isWaitingForDidUpdate(false)
     56    , m_isPaintingSuspended(!parameters.isVisible)
    5657    , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display)
    5758{
     
    157158}
    158159
     160void DrawingAreaImpl::suspendPainting()
     161{
     162    ASSERT(!m_isPaintingSuspended);
     163
     164    m_isPaintingSuspended = true;
     165    m_displayTimer.stop();
     166}
     167
     168void DrawingAreaImpl::resumePainting()
     169{
     170    ASSERT(m_isPaintingSuspended);
     171
     172    m_isPaintingSuspended = false;
     173
     174    // FIXME: Repaint if needed.
     175}
     176
    159177void DrawingAreaImpl::scheduleDisplay()
    160178{
     
    162180        return;
    163181
     182    if (m_isPaintingSuspended)
     183        return;
     184
    164185    if (m_dirtyRegion.isEmpty())
    165186        return;
     
    173194void DrawingAreaImpl::display()
    174195{
     196    ASSERT(!m_isWaitingForDidUpdate);
     197
     198    if (m_isPaintingSuspended)
     199        return;
     200
    175201    if (m_dirtyRegion.isEmpty())
    176202        return;
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h

    r76135 r76157  
    5656    virtual void setSize(const WebCore::IntSize&);
    5757    virtual void didUpdate();
     58    virtual void suspendPainting();
     59    virtual void resumePainting();
    5860
    5961    void scheduleDisplay();
     
    6870    // web process won't paint more frequent than the UI process can handle.
    6971    bool m_isWaitingForDidUpdate;
    70    
     72
     73    // Whether painting is suspended. We'll still keep track of the dirty region but we
     74    // won't paint until painting has resumed again.
     75    bool m_isPaintingSuspended;
     76
    7177    RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
    7278};
Note: See TracChangeset for help on using the changeset viewer.