2011-02-03 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2011 19:52:52 +0000 (19:52 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Feb 2011 19:52:52 +0000 (19:52 +0000)
        Reviewed by Sam Weinig.

        Make the layer tree host keep track of the layer tree context
        https://bugs.webkit.org/show_bug.cgi?id=53698

        Add a LayerTreeContext member variable to the LayerTreeHost object,
        and also add a seed count to the LayerTreeContext so we can keep track of
        how layer tree contexts relate to each other.

        * Shared/LayerTreeContext.h:
        * Shared/mac/LayerTreeContextMac.mm:
        (WebKit::LayerTreeContext::LayerTreeContext):
        (WebKit::LayerTreeContext::makeWithSeed):
        (WebKit::LayerTreeContext::encode):
        (WebKit::LayerTreeContext::decode):

        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
        Add the layer tree context as a member variable.

        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
        (WebKit::LayerTreeHostMac::LayerTreeHostMac):
        Initialize the layer tree context.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/LayerTreeContext.h
Source/WebKit2/Shared/mac/LayerTreeContextMac.mm
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm

index 949ae04..3e53600 100644 (file)
@@ -1,3 +1,28 @@
+2011-02-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Make the layer tree host keep track of the layer tree context
+        https://bugs.webkit.org/show_bug.cgi?id=53698
+
+        Add a LayerTreeContext member variable to the LayerTreeHost object,
+        and also add a seed count to the LayerTreeContext so we can keep track of 
+        how layer tree contexts relate to each other.
+
+        * Shared/LayerTreeContext.h:
+        * Shared/mac/LayerTreeContextMac.mm:
+        (WebKit::LayerTreeContext::LayerTreeContext):
+        (WebKit::LayerTreeContext::makeWithSeed):
+        (WebKit::LayerTreeContext::encode):
+        (WebKit::LayerTreeContext::decode):
+
+        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
+        Add the layer tree context as a member variable.
+
+        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
+        (WebKit::LayerTreeHostMac::LayerTreeHostMac):
+        Initialize the layer tree context.
+
 2011-02-03  Sam Weinig  <sam@webkit.org>
 
         Fix Qt build.
index dab04f3..a739452 100644 (file)
@@ -40,12 +40,15 @@ public:
     LayerTreeContext();
     ~LayerTreeContext();
 
+    static LayerTreeContext makeWithSeed();
+
     void encode(CoreIPC::ArgumentEncoder*) const;
     static bool decode(CoreIPC::ArgumentDecoder*, LayerTreeContext&);
 
     bool isEmpty() const;
 
 #if PLATFORM(MAC)
+    uint64_t seed;
     uint32_t contextID;
 #endif
 };
index 8a9677e..a61708d 100644 (file)
@@ -32,7 +32,8 @@
 namespace WebKit {
 
 LayerTreeContext::LayerTreeContext()
-    : contextID(0)
+    : seed(0)
+    , contextID(0)
 {
 }
 
@@ -40,13 +41,28 @@ LayerTreeContext::~LayerTreeContext()
 {
 }
 
+LayerTreeContext LayerTreeContext::makeWithSeed()
+{
+    static uint64_t seed;
+
+    LayerTreeContext layerTreeContext;
+    layerTreeContext.seed = ++seed;
+    ASSERT(layerTreeContext.seed);
+
+    return layerTreeContext;
+}
+
 void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
+    encoder->encode(seed);
     encoder->encode(contextID);
 }
 
 bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& result)
 {
+    if (!decoder->decode(result.seed))
+        return false;
+
     return decoder->decode(result.contextID);
 }
 
index 8648aba..68f9d19 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef LayerTreeHostMac_h
 #define LayerTreeHostMac_h
 
+#include "LayerTreeContext.h"
 #include "LayerTreeHost.h"
 #include <WebCore/GraphicsLayerClient.h>
 #include <wtf/OwnPtr.h>
@@ -58,7 +59,11 @@ private:
     void flushPendingLayerChangesRunLoopObserverCallback();
     bool flushPendingLayerChanges();
 
-    bool m_isValid;
+    // The context for this layer tree.
+    LayerTreeContext m_layerTreeContext;
+
+    // Whether the layer tree host is valid or not.
+    bool m_isValid;    
 
     // The root layer.
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
index f40abac..f8fdde4 100644 (file)
@@ -27,7 +27,6 @@
 #import "LayerTreeHostMac.h"
 
 #import "DrawingAreaProxyMessages.h"
-#import "LayerTreeContext.h"
 #import "WebPage.h"
 #import "WebProcess.h"
 #import <WebCore/Frame.h>
@@ -47,6 +46,7 @@ PassRefPtr<LayerTreeHostMac> LayerTreeHostMac::create(WebPage* webPage, Graphics
 
 LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage, GraphicsLayer* graphicsLayer)
     : LayerTreeHost(webPage)
+    , m_layerTreeContext(LayerTreeContext::makeWithSeed())
     , m_isValid(true)
 {
     mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort();
@@ -67,11 +67,10 @@ LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage, GraphicsLayer* graphicsLaye
 
     scheduleLayerFlush();
 
-    LayerTreeContext layerTreeContext;
-    layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get());
+    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(layerTreeContext));
+    m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_layerTreeContext));
 }
 
 LayerTreeHostMac::~LayerTreeHostMac()