2011-02-03 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2011 20:50:01 +0000 (20:50 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2011 20:50:01 +0000 (20:50 +0000)
        Reviewed by Darin Adler.

        Don't send enter/exit accelerated compositing mode messages when handling setSize
        https://bugs.webkit.org/show_bug.cgi?id=53706

        Don't send EnterAcceleratedCompositingMode/ExitAcceleratedCompositing mode when
        the mode changes happen as a result of relayout in setSize, since an updated state
        is going to be sent back in the DidSetSize message.

        * UIProcess/DrawingAreaProxyImpl.cpp:
        (WebKit::DrawingAreaProxyImpl::didSetSize):
        Add an assert.

        * WebProcess/WebPage/DrawingAreaImpl.cpp:
        (WebKit::DrawingAreaImpl::DrawingAreaImpl):
        Initialize m_inSetSize.

        (WebKit::DrawingAreaImpl::setRootCompositingLayer):
        Factor out code into enterAcceleratedCompositingMode and exitAcceleratedCompositingMode.

        (WebKit::DrawingAreaImpl::setSize):
        Set m_inSetSize to true while handling setSize.

        (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
        (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode):
        Take over the message sending responsibility from LayerTreeHostMac, and don't send messages
        if we're currently handling a SetSize message.

        * WebProcess/WebPage/DrawingAreaImpl.h:
        Add m_inSetSize.

        * WebProcess/WebPage/LayerTreeHost.h:
        Add layerTreeHost getter.

        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
        (WebKit::LayerTreeHostMac::LayerTreeHostMac):
        Don't send EnterAcceleratedCompositingMode messages.

        (WebKit::LayerTreeHostMac::layerTreeContext):
        Add getter for the current layer tree context.

        (WebKit::LayerTreeHostMac::invalidate):
        Don't send ExitAcceleratedCompositingMode messages.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm

index 3e53600..294e7fe 100644 (file)
@@ -1,5 +1,52 @@
 2011-02-03  Anders Carlsson  <andersca@apple.com>
 
+        Reviewed by Darin Adler.
+
+        Don't send enter/exit accelerated compositing mode messages when handling setSize
+        https://bugs.webkit.org/show_bug.cgi?id=53706
+
+        Don't send EnterAcceleratedCompositingMode/ExitAcceleratedCompositing mode when
+        the mode changes happen as a result of relayout in setSize, since an updated state
+        is going to be sent back in the DidSetSize message.
+        
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::didSetSize):
+        Add an assert.
+
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::DrawingAreaImpl):
+        Initialize m_inSetSize.
+
+        (WebKit::DrawingAreaImpl::setRootCompositingLayer):
+        Factor out code into enterAcceleratedCompositingMode and exitAcceleratedCompositingMode.
+
+        (WebKit::DrawingAreaImpl::setSize):
+        Set m_inSetSize to true while handling setSize.
+
+        (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode):
+        (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode):
+        Take over the message sending responsibility from LayerTreeHostMac, and don't send messages
+        if we're currently handling a SetSize message.
+
+        * WebProcess/WebPage/DrawingAreaImpl.h:
+        Add m_inSetSize.
+
+        * WebProcess/WebPage/LayerTreeHost.h:
+        Add layerTreeHost getter.
+
+        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
+        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
+        (WebKit::LayerTreeHostMac::LayerTreeHostMac):
+        Don't send EnterAcceleratedCompositingMode messages.
+
+        (WebKit::LayerTreeHostMac::layerTreeContext):
+        Add getter for the current layer tree context.
+
+        (WebKit::LayerTreeHostMac::invalidate):
+        Don't send ExitAcceleratedCompositingMode messages.
+
+2011-02-03  Anders Carlsson  <andersca@apple.com>
+
         Reviewed by Sam Weinig.
 
         Make the layer tree host keep track of the layer tree context
index e47de04..3b4f6fd 100644 (file)
@@ -145,8 +145,10 @@ void DrawingAreaProxyImpl::didSetSize(const UpdateInfo& updateInfo)
     if (m_size != updateInfo.viewSize)
         sendSetSize();
 
-    if (m_isInAcceleratedCompositingMode)
+    if (m_isInAcceleratedCompositingMode) {
+        ASSERT(!m_backingStore);
         return;
+    }
 
     m_backingStore = nullptr;
     incorporateUpdate(updateInfo);
index c4727de..e7309d9 100644 (file)
@@ -27,6 +27,7 @@
 #include "DrawingAreaImpl.h"
 
 #include "DrawingAreaProxyMessages.h"
+#include "LayerTreeContext.h"
 #include "ShareableBitmap.h"
 #include "UpdateInfo.h"
 #include "WebPage.h"
@@ -53,6 +54,7 @@ DrawingAreaImpl::~DrawingAreaImpl()
 
 DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters)
     : DrawingArea(DrawingAreaInfo::Impl, parameters.drawingAreaInfo.identifier, webPage)
+    , m_inSetSize(false)
     , m_isWaitingForDidUpdate(false)
     , m_isPaintingSuspended(!parameters.isVisible)
     , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display)
@@ -142,19 +144,10 @@ void DrawingAreaImpl::detachCompositingContext()
 
 void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
 {
-    if (graphicsLayer) {
-        m_layerTreeHost = LayerTreeHost::create(m_webPage, graphicsLayer);
-
-        // Non-composited content will now be handled exclusively by the layer tree host.
-        m_dirtyRegion = Region();
-        m_scrollRect = IntRect();
-        m_scrollOffset = IntSize();
-        m_displayTimer.stop();
-        m_isWaitingForDidUpdate = false;
-    } else {
-        m_layerTreeHost->invalidate();
-        m_layerTreeHost = nullptr;
-    }
+    if (graphicsLayer)
+        enterAcceleratedCompositingMode(graphicsLayer);
+    else
+        exitAcceleratedCompositingMode();
 }
 
 void DrawingAreaImpl::scheduleCompositingLayerSync()
@@ -174,6 +167,9 @@ void DrawingAreaImpl::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID
 
 void DrawingAreaImpl::setSize(const IntSize& size)
 {
+    ASSERT(!m_inSetSize);
+    m_inSetSize = true;
+
     // Set this to false since we're about to call display().
     m_isWaitingForDidUpdate = false;
 
@@ -189,6 +185,8 @@ void DrawingAreaImpl::setSize(const IntSize& size)
         display(updateInfo);
 
     m_webPage->send(Messages::DrawingAreaProxy::DidSetSize(updateInfo));
+
+    m_inSetSize = false;
 }
 
 void DrawingAreaImpl::didUpdate()
@@ -221,6 +219,32 @@ void DrawingAreaImpl::resumePainting()
     // FIXME: Repaint if needed.
 }
 
+void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
+{
+    ASSERT(!m_layerTreeHost);
+
+    m_layerTreeHost = LayerTreeHost::create(m_webPage, graphicsLayer);
+    
+    // Non-composited content will now be handled exclusively by the layer tree host.
+    m_dirtyRegion = Region();
+    m_scrollRect = IntRect();
+    m_scrollOffset = IntSize();
+    m_displayTimer.stop();
+    m_isWaitingForDidUpdate = false;
+
+    if (!m_inSetSize)
+        m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_layerTreeHost->layerTreeContext()));
+}
+
+void DrawingAreaImpl::exitAcceleratedCompositingMode()
+{
+    m_layerTreeHost->invalidate();
+    m_layerTreeHost = nullptr;
+    
+    if (!m_inSetSize)
+        m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode());
+}
+
 void DrawingAreaImpl::scheduleDisplay()
 {
     if (m_isWaitingForDidUpdate)
index 2bd5562..5074eac 100644 (file)
@@ -60,6 +60,9 @@ private:
     virtual void suspendPainting();
     virtual void resumePainting();
 
+    void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
+    void exitAcceleratedCompositingMode();
+
     void scheduleDisplay();
     void display();
     void display(UpdateInfo&);
@@ -67,7 +70,10 @@ private:
     Region m_dirtyRegion;
     WebCore::IntRect m_scrollRect;
     WebCore::IntSize m_scrollOffset;
-    
+
+    // Whether we're currently processing a setSize message.
+    bool m_inSetSize;
+
     // 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;
index f410f87..0f743ed 100644 (file)
@@ -35,6 +35,7 @@ namespace WebCore {
 
 namespace WebKit {
 
+class LayerTreeContext;
 class WebPage;
 
 class LayerTreeHost : public RefCounted<LayerTreeHost> {
@@ -42,6 +43,7 @@ public:
     static PassRefPtr<LayerTreeHost> create(WebPage*, WebCore::GraphicsLayer*);
     virtual ~LayerTreeHost();
 
+    virtual const LayerTreeContext& layerTreeContext() = 0;
     virtual void scheduleLayerFlush() = 0;
     virtual void invalidate() = 0;
 
index 68f9d19..cb926af 100644 (file)
@@ -45,6 +45,7 @@ private:
     explicit LayerTreeHostMac(WebPage*, WebCore::GraphicsLayer*);
 
     // LayerTreeHost.
+    virtual const LayerTreeContext& layerTreeContext();
     virtual void scheduleLayerFlush();
     virtual void invalidate();
 
index f8fdde4..afce617 100644 (file)
@@ -26,7 +26,6 @@
 #import "config.h"
 #import "LayerTreeHostMac.h"
 
-#import "DrawingAreaProxyMessages.h"
 #import "WebPage.h"
 #import "WebProcess.h"
 #import <WebCore/Frame.h>
@@ -68,9 +67,6 @@ LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage, GraphicsLayer* graphicsLaye
     scheduleLayerFlush();
 
     m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get());
-
-    // FIXME: Don't send this if we enter accelerated compositing as a result of setSize.
-    m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_layerTreeContext));
 }
 
 LayerTreeHostMac::~LayerTreeHostMac()
@@ -81,6 +77,11 @@ LayerTreeHostMac::~LayerTreeHostMac()
     ASSERT(!m_rootLayer);
 }
 
+const LayerTreeContext& LayerTreeHostMac::layerTreeContext()
+{
+    return m_layerTreeContext;
+}
+
 void LayerTreeHostMac::scheduleLayerFlush()
 {
     CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
@@ -112,9 +113,6 @@ void LayerTreeHostMac::invalidate()
     m_remoteLayerClient = nullptr;
     m_rootLayer = nullptr;
     m_isValid = false;
-
-    // FIXME: Don't send this if we enter accelerated compositing as a result of setSize.
-    m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode());
 }
 
 void LayerTreeHostMac::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time)