Changeset 83994 in webkit


Ignore:
Timestamp:
Apr 15, 2011 11:07:01 AM (13 years ago)
Author:
jer.noble@apple.com
Message:

2011-04-14 Jer Noble <jer.noble@apple.com>

Reviewed by Eric Carlson.

REGRESSION: Rendering in <video> element appears to render quickly to catch up if it has been playing in a background tab
https://bugs.webkit.org/show_bug.cgi?id=58637

Notify AVFoundation that no one will be rendering when the view or window moves off screen.

  • UIProcess/API/mac/PageClientImpl.mm: (WebKit::PageClientImpl::isViewVisible): Return false if the view's window is not visible.
  • UIProcess/API/mac/WKView.mm: (-[WKView addWindowObserversForWindow:]): Observe orderOut and orderIn events. (-[WKView removeWindowObservers]): Ditto. (-[WKView _windowDidOrderOffScreen:]): Added. (-[WKView _windowDidOrderOnScreen:]): Added.
  • WebProcess/WebPage/DrawingAreaImpl.cpp: (WebKit::DrawingAreaImpl::suspendPainting): Call LayerTreeHost::pauseRendering. (WebKit::DrawingAreaImpl::resumePainting): Call LayerTreeHost::resumeRendering.
  • WebProcess/WebPage/LayerTreeHost.h: (WebKit::LayerTreeHost::pauseRendering): Added stub. (WebKit::LayerTreeHost::resumeRendering): Added stub.
  • WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h:
  • WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm: (WebKit::LayerTreeHostCAMac::pauseRendering): Added. Post a notification with our

intention to stop rendering.

(WebKit::LayerTreeHostCAMac::resumeRendering): Added. Post a notification with our

intention to start rendering.

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r83988 r83994  
     12011-04-14  Jer Noble  <jer.noble@apple.com>
     2
     3        Reviewed by Eric Carlson.
     4
     5        REGRESSION: Rendering in <video> element appears to render quickly to catch up if it has been playing in a background tab
     6        https://bugs.webkit.org/show_bug.cgi?id=58637
     7
     8        Notify AVFoundation that no one will be rendering when the view or window moves off screen.
     9
     10        * UIProcess/API/mac/PageClientImpl.mm:
     11        (WebKit::PageClientImpl::isViewVisible): Return false if the view's window is not visible.
     12        * UIProcess/API/mac/WKView.mm:
     13        (-[WKView addWindowObserversForWindow:]): Observe orderOut and orderIn events.
     14        (-[WKView removeWindowObservers]): Ditto.
     15        (-[WKView _windowDidOrderOffScreen:]): Added.
     16        (-[WKView _windowDidOrderOnScreen:]): Added.
     17        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     18        (WebKit::DrawingAreaImpl::suspendPainting): Call LayerTreeHost::pauseRendering.
     19        (WebKit::DrawingAreaImpl::resumePainting): Call LayerTreeHost::resumeRendering.
     20        * WebProcess/WebPage/LayerTreeHost.h:
     21        (WebKit::LayerTreeHost::pauseRendering): Added stub.
     22        (WebKit::LayerTreeHost::resumeRendering): Added stub.
     23        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h:
     24        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm:
     25        (WebKit::LayerTreeHostCAMac::pauseRendering): Added. Post a notification with our
     26            intention to stop rendering.
     27        (WebKit::LayerTreeHostCAMac::resumeRendering): Added. Post a notification with our
     28            intention to start rendering.
     29
    1302011-04-15  Jessie Berlin  <jberlin@apple.com>
    231
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r83919 r83994  
    166166{
    167167    if (![m_wkView window])
     168        return false;
     169
     170    if (![[m_wkView window] isVisible])
    168171        return false;
    169172
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r83812 r83994  
    16411641        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:)
    16421642                                                     name:NSWindowDidResizeNotification object:window];
     1643        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:)
     1644                                                     name:@"NSWindowDidOrderOffScreenNotification" object:window];
     1645        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:)
     1646                                                     name:@"_NSWindowDidBecomeVisible" object:window];
    16431647    }
    16441648}
     
    16561660    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMoveNotification object:window];
    16571661    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:window];
     1662    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window];
     1663    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window];
    16581664}
    16591665
     
    17361742}
    17371743
     1744- (void)_windowDidOrderOffScreen:(NSNotification *)notification
     1745{
     1746    _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
     1747}
     1748
     1749- (void)_windowDidOrderOnScreen:(NSNotification *)notification
     1750{
     1751    _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
     1752}
     1753
    17381754static void drawPageBackground(CGContextRef context, WebPageProxy* page, const IntRect& rect)
    17391755{
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp

    r83647 r83994  
    357357    ASSERT(!m_isPaintingSuspended);
    358358
     359    if (m_layerTreeHost)
     360        m_layerTreeHost->pauseRendering();
     361
    359362    m_isPaintingSuspended = true;
    360363    m_displayTimer.stop();
     
    368371        return;
    369372    }
     373   
     374    if (m_layerTreeHost)
     375        m_layerTreeHost->resumeRendering();
    370376       
    371377    m_isPaintingSuspended = false;
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h

    r82966 r83994  
    6464    virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0;
    6565
     66    virtual void pauseRendering() { }
     67    virtual void resumeRendering() { }
     68
    6669    // If a derived class overrides this function to return true, the derived class must also
    6770    // override the functions beneath it.
  • trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h

    r82675 r83994  
    4747    virtual void sizeDidChange(const WebCore::IntSize& newSize);
    4848    virtual void forceRepaint();
     49    virtual void pauseRendering();
     50    virtual void resumeRendering();
    4951
    5052    // LayerTreeHostCA
  • trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm

    r82854 r83994  
    111111    [CATransaction flush];
    112112    [CATransaction synchronize];
    113 }   
     113}
     114
     115void LayerTreeHostCAMac::pauseRendering()
     116{
     117    CALayer* root = rootLayer()->platformLayer();
     118    [root setValue:(id)kCFBooleanTrue forKey:@"NSCAViewRenderPaused"];
     119    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]];
     120}
     121
     122void LayerTreeHostCAMac::resumeRendering()
     123{
     124    CALayer* root = rootLayer()->platformLayer();
     125    [root setValue:(id)kCFBooleanFalse forKey:@"NSCAViewRenderPaused"];
     126    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]];
     127}
    114128
    115129void LayerTreeHostCAMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
Note: See TracChangeset for help on using the changeset viewer.