TiledCoreAnimationDrawingArea should handle visibility changes
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 18:30:58 +0000 (18:30 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 18:30:58 +0000 (18:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85645
<rdar://problem/11247192>

Reviewed by Oliver Hunt.

Replicate the visibility handling logic from DrawingAreaImpl and LayerTreeHostCAMac.

* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
(TiledCoreAnimationDrawingAreaProxy):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::visibilityDidChange):
(WebKit):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
(TiledCoreAnimationDrawingArea):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::suspendPainting):
(WebKit):
(WebKit::TiledCoreAnimationDrawingArea::resumePainting):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116130 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 8fcb8c8..4fff2ea 100644 (file)
@@ -1,3 +1,26 @@
+2012-05-04  Anders Carlsson  <andersca@apple.com>
+
+        TiledCoreAnimationDrawingArea should handle visibility changes
+        https://bugs.webkit.org/show_bug.cgi?id=85645
+        <rdar://problem/11247192>
+
+        Reviewed by Oliver Hunt.
+
+        Replicate the visibility handling logic from DrawingAreaImpl and LayerTreeHostCAMac.
+
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+        (TiledCoreAnimationDrawingAreaProxy):
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::visibilityDidChange):
+        (WebKit):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        (TiledCoreAnimationDrawingArea):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::suspendPainting):
+        (WebKit):
+        (WebKit::TiledCoreAnimationDrawingArea::resumePainting):
+
 2012-05-04  Nate Chapin  <japhet@chromium.org>
 
         Don't require FrameLoaderClient to manufacture a commitData() call for empty documents.
index b17ecc9..c5b6f0e 100644 (file)
@@ -44,6 +44,7 @@ private:
     // DrawingAreaProxy
     virtual void deviceScaleFactorDidChange() OVERRIDE;
     virtual void layerHostingModeDidChange() OVERRIDE;
+    virtual void visibilityDidChange() OVERRIDE;
     virtual void sizeDidChange() OVERRIDE;
     virtual void waitForPossibleGeometryUpdate() OVERRIDE;
 
index fc9545c..747ed11 100644 (file)
@@ -58,6 +58,14 @@ void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
     m_webPageProxy->process()->send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy->deviceScaleFactor()), m_webPageProxy->pageID());
 }
 
+void TiledCoreAnimationDrawingAreaProxy::visibilityDidChange()
+{
+    if (!m_webPageProxy->isViewVisible())
+        m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
+    else
+        m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
+}
+
 void TiledCoreAnimationDrawingAreaProxy::layerHostingModeDidChange()
 {
     m_webPageProxy->process()->send(Messages::DrawingArea::SetLayerHostingMode(m_webPageProxy->layerHostingMode()), m_webPageProxy->pageID());
index 198f8a1..8608f07 100644 (file)
@@ -80,6 +80,8 @@ private:
     virtual bool flushLayers() OVERRIDE;
 
     // Message handlers.
+    virtual void suspendPainting() OVERRIDE;
+    virtual void resumePainting() OVERRIDE;
     virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
     virtual void setDeviceScaleFactor(float) OVERRIDE;
     virtual void setLayerHostingMode(uint32_t) OVERRIDE;
@@ -101,7 +103,8 @@ private:
     RetainPtr<CALayer> m_debugInfoLayer;
 
     OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
-    WebCore::FloatPoint m_mainFrameScrollLayerPosition;
+
+    bool m_isPaintingSuspended;
 };
 
 } // namespace WebKit
index cdd9840..9a7ccdf 100644 (file)
@@ -33,6 +33,7 @@
 #import "LayerHostingContext.h"
 #import "LayerTreeContext.h"
 #import "WebPage.h"
+#import "WebPageCreationParameters.h"
 #import "WebPageProxyMessages.h"
 #import "WebProcess.h"
 #import <QuartzCore/QuartzCore.h>
@@ -65,6 +66,7 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c
     : DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage)
     , m_layerTreeStateIsFrozen(false)
     , m_layerFlushScheduler(this)
+    , m_isPaintingSuspended(!parameters.isVisible)
 {
     Page* page = webPage->corePage();
 
@@ -285,6 +287,33 @@ bool TiledCoreAnimationDrawingArea::flushLayers()
     return returnValue;
 }
 
+void TiledCoreAnimationDrawingArea::suspendPainting()
+{
+    ASSERT(!m_isPaintingSuspended);
+    m_isPaintingSuspended = true;
+
+    [m_rootLayer.get() setValue:(id)kCFBooleanTrue forKey:@"NSCAViewRenderPaused"];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_rootLayer.get() forKey:@"layer"]];
+
+    m_webPage->corePage()->suspendScriptedAnimations();
+}
+
+void TiledCoreAnimationDrawingArea::resumePainting()
+{
+    if (!m_isPaintingSuspended) {
+        // FIXME: We can get a call to resumePainting when painting is not suspended.
+        // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
+        return;
+    }
+    m_isPaintingSuspended = false;
+
+    [m_rootLayer.get() setValue:(id)kCFBooleanFalse forKey:@"NSCAViewRenderPaused"];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_rootLayer.get() forKey:@"layer"]];
+
+    if (m_webPage->windowIsVisible())
+        m_webPage->corePage()->resumeScriptedAnimations();
+}
+
 void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize)
 {
     m_webPage->setSize(viewSize);