[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

cmarrin at apple.com cmarrin at apple.com
Thu Apr 8 02:11:33 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit fd026f03d46e968572e51a8b948261448100d2fd
Author: cmarrin at apple.com <cmarrin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Mar 5 21:04:44 2010 +0000

    Fixed crash due to infinite recursion when viewing composited video on Windows
    https://bugs.webkit.org/show_bug.cgi?id=35798
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55592 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3ed2e9e..d069840 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,63 @@
+2010-03-05  Chris Marrin  <cmarrin at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Fixed infinite recursion of composited video on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=35798
+        
+        Due to a change in the way we get the platformLayer (WKCACFLayer)
+        for video, the mediaplayer was in an infinite loop with WKCACFLayer
+        bouncing notifySyncRequired calls back and forth. After discussion
+        we decided it would be better to avoid notifySyncRequired entirely,
+        which would walk up through WebCore calls and back down through
+        WebKit calls to tell the WKCACFLayerRenderer to kick off a render cycle.
+        
+        I subclassed WKCACFLayer into a WKCACFRootLayer which has a pointer to
+        the WKCACFLayerRenderer. When something changes, we get the rootLayer()
+        by walking up the layers and make a virtual call which WKCACFRootLayer
+        implements to tell WKCACFLayerRenderer to render.
+        
+        I also got rid of GraphicsLayer knowledge from WKCACFLayer. GraphicsLayerCACF
+        now makes a WebLayer subclass which implements the drawInContext()
+        virtual method.
+        
+        I also had to add protection to the platformLayer() call in 
+        MediaPlayerPrivateQuickTimeWin because it gets called earlier than before
+        when the layer is still null.
+
+        * platform/graphics/win/GraphicsLayerCACF.cpp:Implement WebLayer
+        (WebCore::WebLayer::create):
+        (WebCore::WebLayer::drawInContext):
+        (WebCore::WebLayer::WebLayer):
+        (WebCore::GraphicsLayerCACF::GraphicsLayerCACF):
+        (WebCore::GraphicsLayerCACF::setNeedsDisplayInRect):
+        (WebCore::GraphicsLayerCACF::updateLayerPreserves3D):
+        (WebCore::GraphicsLayerCACF::updateContentsImage):
+        * platform/graphics/win/GraphicsLayerCACF.h:
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp:Protect platformLayer from a null qtLayer
+        (WebCore::MediaPlayerPrivate::platformLayer):
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h:Got rid of no longer needed method
+        (WebCore::MediaPlayerPrivate::notifyAnimationStarted):
+        * platform/graphics/win/WKCACFLayer.cpp:Got rid of GraphicsLayer dependency. Made virtual.
+        (WebCore::displayCallback):
+        (WebCore::WKCACFLayer::create):
+        (WebCore::WKCACFLayer::WKCACFLayer):
+        (WebCore::WKCACFLayer::setNeedsCommit):
+        (WebCore::WKCACFLayer::setNeedsDisplay):
+        * platform/graphics/win/WKCACFLayer.h:
+        (WebCore::WKCACFLayer::setNeedsRender):
+        (WebCore::WKCACFLayer::drawInContext):
+        * platform/graphics/win/WKCACFLayerRenderer.cpp:Create WKCACFRootLayer which tells WKCACFLayerRenderer to render
+        (WebCore::WKCACFRootLayer::WKCACFRootLayer):
+        (WebCore::WKCACFRootLayer::create):
+        (WebCore::WKCACFRootLayer::setNeedsRender):
+        (WebCore::WKCACFRootLayer::setNeedsDisplay):
+        (WebCore::WKCACFLayerRenderer::rootLayer):
+        (WebCore::WKCACFLayerRenderer::setRootChildLayer):
+        (WebCore::WKCACFLayerRenderer::setNeedsDisplay):
+        (WebCore::WKCACFLayerRenderer::createRenderer):
+        * platform/graphics/win/WKCACFLayerRenderer.h:
+
 2010-03-05  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
index 49b5af3..87c0589 100644
--- a/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
+++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.cpp
@@ -44,6 +44,82 @@ using namespace std;
 
 namespace WebCore {
 
+class WebLayer : public WKCACFLayer {
+public:
+    static PassRefPtr<WKCACFLayer> create(LayerType layerType, GraphicsLayerCACF* owner)
+    {
+        return adoptRef(new WebLayer(layerType, owner));
+    }
+
+    virtual void drawInContext(PlatformGraphicsContext* context)
+    {
+        if (!m_owner)
+            return;
+
+        CGContextSaveGState(context);
+
+        CGRect layerBounds = bounds();
+        if (m_owner->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+            CGContextScaleCTM(context, 1, -1);
+            CGContextTranslateCTM(context, 0, -layerBounds.size.height);
+        }
+
+        if (m_owner->client()) {
+            GraphicsContext graphicsContext(context);
+
+            // It's important to get the clip from the context, because it may be significantly
+            // smaller than the layer bounds (e.g. tiled layers)
+            CGRect clipBounds = CGContextGetClipBoundingBox(context);
+            IntRect clip(enclosingIntRect(clipBounds));
+            m_owner->paintGraphicsLayerContents(graphicsContext, clip);
+        }
+#ifndef NDEBUG
+        else {
+            ASSERT_NOT_REACHED();
+
+            // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
+            // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
+            CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
+            CGContextFillRect(context, layerBounds);
+        }
+#endif
+
+        if (m_owner->showRepaintCounter()) {
+            char text[16]; // that's a lot of repaints
+            _snprintf(text, sizeof(text), "%d", m_owner->incrementRepaintCount());
+
+            CGContextSaveGState(context);
+            CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);
+            
+            CGRect aBounds = layerBounds;
+
+            aBounds.size.width = 10 + 12 * strlen(text);
+            aBounds.size.height = 25;
+            CGContextFillRect(context, aBounds);
+            
+            CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
+
+            CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0f, -1.0f));
+            CGContextSelectFont(context, "Helvetica", 25, kCGEncodingMacRoman);
+            CGContextShowTextAtPoint(context, aBounds.origin.x + 3.0f, aBounds.origin.y + 20.0f, text, strlen(text));
+            
+            CGContextRestoreGState(context);        
+        }
+
+        CGContextRestoreGState(context);
+    }
+
+protected:
+    WebLayer(LayerType layerType, GraphicsLayerCACF* owner)
+     : WKCACFLayer(layerType)
+     , m_owner(owner)
+    {
+    }
+
+private:
+    GraphicsLayer* m_owner;
+};
+
 static inline void copyTransform(CATransform3D& toT3D, const TransformationMatrix& t)
 {
     toT3D.m11 = narrowPrecisionToFloat(t.m11());
@@ -124,7 +200,7 @@ GraphicsLayerCACF::GraphicsLayerCACF(GraphicsLayerClient* client)
     , m_contentsLayerPurpose(NoContentsLayer)
     , m_contentsLayerHasBackgroundColor(false)
 {
-    m_layer = WKCACFLayer::create(WKCACFLayer::Layer, this);
+    m_layer = WebLayer::create(WKCACFLayer::Layer, this);
     
     updateDebugIndicators();
 }
@@ -331,8 +407,10 @@ void GraphicsLayerCACF::setNeedsDisplay()
 
 void GraphicsLayerCACF::setNeedsDisplayInRect(const FloatRect& rect)
 {
-    if (drawsContent())
-        m_layer->setNeedsDisplay(rect);
+    if (drawsContent()) {
+        CGRect cgRect = rect;
+        m_layer->setNeedsDisplay(&cgRect);
+    }
 }
 
 void GraphicsLayerCACF::setContentsRect(const IntRect& rect)
@@ -537,7 +615,7 @@ void GraphicsLayerCACF::updateLayerPreserves3D()
 {
     if (m_preserves3D && !m_transformLayer) {
         // Create the transform layer.
-        m_transformLayer = WKCACFLayer::create(WKCACFLayer::TransformLayer, this);
+        m_transformLayer = WebLayer::create(WKCACFLayer::TransformLayer, this);
 
 #ifndef NDEBUG
         m_transformLayer->setName(String().format("Transform Layer CATransformLayer(%p) GraphicsLayer(%p)", m_transformLayer.get(), this));
@@ -610,7 +688,7 @@ void GraphicsLayerCACF::updateContentsImage()
 {
     if (m_pendingContentsImage) {
         if (!m_contentsLayer.get()) {
-            RefPtr<WKCACFLayer> imageLayer = WKCACFLayer::create(WKCACFLayer::Layer, this);
+            RefPtr<WKCACFLayer> imageLayer = WebLayer::create(WKCACFLayer::Layer, this);
 #ifndef NDEBUG
             imageLayer->setName("Image Layer");
 #endif
diff --git a/WebCore/platform/graphics/win/GraphicsLayerCACF.h b/WebCore/platform/graphics/win/GraphicsLayerCACF.h
index 0a52764..8c3f848 100644
--- a/WebCore/platform/graphics/win/GraphicsLayerCACF.h
+++ b/WebCore/platform/graphics/win/GraphicsLayerCACF.h
@@ -91,8 +91,6 @@ public:
 
     virtual void setGeometryOrientation(CompositingCoordinatesOrientation);
 
-    void notifySyncRequired() { if (m_client) m_client->notifySyncRequired(this); }
-
 private:
     void updateOpacityOnLayer();
 
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
index 1df73a7..5d836a9 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
@@ -111,7 +111,7 @@ PlatformMedia MediaPlayerPrivate::platformMedia() const
 #if USE(ACCELERATED_COMPOSITING)
 PlatformLayer* MediaPlayerPrivate::platformLayer() const
 {
-    return m_qtVideoLayer->platformLayer();
+    return m_qtVideoLayer ? m_qtVideoLayer->platformLayer() : 0;
 }
 #endif
 
@@ -861,14 +861,6 @@ void MediaPlayerPrivate::acceleratedRenderingStateChanged()
     setUpVideoRendering();
 }
 
-void MediaPlayerPrivate::notifySyncRequired(const GraphicsLayer*)
-{
-    GraphicsLayerCACF* videoGraphicsLayer = static_cast<GraphicsLayerCACF*>(m_qtVideoLayer.get());
-    if (videoGraphicsLayer)
-        videoGraphicsLayer->notifySyncRequired();
- }
-
-
 #endif
 
 
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
index 029a520..a0c638e 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
@@ -67,7 +67,7 @@ private:
     // GraphicsLayerClient methods
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
     virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
-    virtual void notifySyncRequired(const GraphicsLayer*);
+    virtual void notifySyncRequired(const GraphicsLayer*) { }
     virtual bool showDebugBorders() const { return false; }
     virtual bool showRepaintCounter() const { return false; }
 #endif 
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp
index e5b184d..a790254 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp
@@ -54,10 +54,10 @@ namespace WebCore {
 
 using namespace std;
 
-static void displayInContext(CACFLayerRef layer, CGContextRef context)
+static void displayCallback(CACFLayerRef layer, CGContextRef context)
 {
     ASSERT_ARG(layer, WKCACFLayer::layer(layer));
-    WKCACFLayer::layer(layer)->display(context);
+    WKCACFLayer::layer(layer)->drawInContext(context);
 }
 
 #define STATIC_CACF_STRING(name) \
@@ -177,23 +177,22 @@ static WKCACFLayer::FilterType fromCACFFilterType(CFStringRef string)
     return WKCACFLayer::Linear;
 }
 
-PassRefPtr<WKCACFLayer> WKCACFLayer::create(LayerType type, GraphicsLayerCACF* owner)
+PassRefPtr<WKCACFLayer> WKCACFLayer::create(LayerType type)
 {
     if (!WKCACFLayerRenderer::acceleratedCompositingAvailable())
         return 0;
-    return adoptRef(new WKCACFLayer(type, owner));
+    return adoptRef(new WKCACFLayer(type));
 }
 
 // FIXME: It might be good to have a way of ensuring that all WKCACFLayers eventually
 // get destroyed in debug builds. A static counter could accomplish this pretty easily.
 
-WKCACFLayer::WKCACFLayer(LayerType type, GraphicsLayerCACF* owner)
+WKCACFLayer::WKCACFLayer(LayerType type)
     : m_layer(AdoptCF, CACFLayerCreate(toCACFLayerType(type)))
     , m_needsDisplayOnBoundsChange(false)
-    , m_owner(owner)
 {
     CACFLayerSetUserData(layer(), this);
-    CACFLayerSetDisplayCallback(layer(), displayInContext);
+    CACFLayerSetDisplayCallback(layer(), displayCallback);
 }
 
 WKCACFLayer::~WKCACFLayer()
@@ -205,64 +204,6 @@ WKCACFLayer::~WKCACFLayer()
     CACFLayerSetDisplayCallback(layer(), 0);
 }
 
-void WKCACFLayer::display(PlatformGraphicsContext* context)
-{
-    if (!m_owner)
-        return;
-
-    CGContextSaveGState(context);
-
-    CGRect layerBounds = bounds();
-    if (m_owner->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
-        CGContextScaleCTM(context, 1, -1);
-        CGContextTranslateCTM(context, 0, -layerBounds.size.height);
-    }
-
-    if (m_owner->client()) {
-        GraphicsContext graphicsContext(context);
-
-        // It's important to get the clip from the context, because it may be significantly
-        // smaller than the layer bounds (e.g. tiled layers)
-        CGRect clipBounds = CGContextGetClipBoundingBox(context);
-        IntRect clip(enclosingIntRect(clipBounds));
-        m_owner->paintGraphicsLayerContents(graphicsContext, clip);
-    }
-#ifndef NDEBUG
-    else {
-        ASSERT_NOT_REACHED();
-
-        // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
-        // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
-        CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
-        CGContextFillRect(context, layerBounds);
-    }
-#endif
-
-    if (m_owner->showRepaintCounter()) {
-        char text[16]; // that's a lot of repaints
-        _snprintf(text, sizeof(text), "%d", m_owner->incrementRepaintCount());
-
-        CGContextSaveGState(context);
-        CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);
-        
-        CGRect aBounds = layerBounds;
-
-        aBounds.size.width = 10 + 12 * strlen(text);
-        aBounds.size.height = 25;
-        CGContextFillRect(context, aBounds);
-        
-        CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
-
-        CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0f, -1.0f));
-        CGContextSelectFont(context, "Helvetica", 25, kCGEncodingMacRoman);
-        CGContextShowTextAtPoint(context, aBounds.origin.x + 3.0f, aBounds.origin.y + 20.0f, text, strlen(text));
-        
-        CGContextRestoreGState(context);        
-    }
-
-    CGContextRestoreGState(context);
-}
-
 void WKCACFLayer::becomeRootLayerForContext(CACFContextRef context)
 {
     CACFContextSetLayer(context, layer());
@@ -271,7 +212,9 @@ void WKCACFLayer::becomeRootLayerForContext(CACFContextRef context)
 
 void WKCACFLayer::setNeedsCommit()
 {
-    CACFContextRef context = CACFLayerGetContext(rootLayer()->layer());
+    WKCACFLayer* root = rootLayer();
+
+    CACFContextRef context = CACFLayerGetContext(root->layer());
 
     // The context might now be set yet. This happens if a property gets set
     // before placing the layer in the tree. In this case we don't need to 
@@ -280,11 +223,9 @@ void WKCACFLayer::setNeedsCommit()
     if (context)
         WKCACFContextFlusher::shared().addContext(context);
 
-    // Call notifySyncRequired(), which in this implementation plumbs through to
-    // call setRootLayerNeedsDisplay() on the WebView, which causes the CACFRenderer
-    // to render a frame.
-    if (m_owner)
-        m_owner->notifySyncRequired();
+    // Call setNeedsRender on the root layer, which will cause a render to 
+    // happen in WKCACFLayerRenderer
+    root->setNeedsRender();
 }
 
 bool WKCACFLayer::isTransformLayer() const
@@ -523,18 +464,15 @@ WKCACFLayer* WKCACFLayer::superlayer() const
     return WKCACFLayer::layer(super);
 }
 
-void WKCACFLayer::setNeedsDisplay(const CGRect& dirtyRect)
+void WKCACFLayer::setNeedsDisplay(const CGRect* dirtyRect)
 {
-    if (m_owner)
-        CACFLayerSetNeedsDisplay(layer(), &dirtyRect);
+    CACFLayerSetNeedsDisplay(layer(), dirtyRect);
     setNeedsCommit();
 }
 
 void WKCACFLayer::setNeedsDisplay()
 {
-    if (m_owner)
-        CACFLayerSetNeedsDisplay(layer(), 0);
-    setNeedsCommit();
+    setNeedsDisplay(0);
 }
 
 #ifndef NDEBUG
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h
index e5568c9..fcaf110 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayer.h
@@ -39,7 +39,6 @@
 #include <wtf/Vector.h>
 
 #include "GraphicsContext.h"
-#include "GraphicsLayerCACF.h"
 #include "PlatformString.h"
 #include "TransformationMatrix.h"
 
@@ -55,10 +54,15 @@ public:
     enum ContentsGravityType { Center, Top, Bottom, Left, Right, TopLeft, TopRight, 
                                BottomLeft, BottomRight, Resize, ResizeAspect, ResizeAspectFill };
 
-    static PassRefPtr<WKCACFLayer> create(LayerType, GraphicsLayerCACF* owner = 0);
+    static PassRefPtr<WKCACFLayer> create(LayerType);
     static WKCACFLayer* layer(CACFLayerRef layer) { return static_cast<WKCACFLayer*>(CACFLayerGetUserData(layer)); }
 
-    ~WKCACFLayer();
+    virtual ~WKCACFLayer();
+
+    virtual void setNeedsRender() { }
+    virtual void drawInContext(PlatformGraphicsContext*) { }
+    virtual void setNeedsDisplay(const CGRect* dirtyRect);
+    void setNeedsDisplay();
 
     // Makes this layer the root when the passed context is rendered
     void becomeRootLayerForContext(CACFContextRef);
@@ -106,8 +110,6 @@ public:
         return RetainPtr<CFTypeRef>(AdoptCF, CGColorCreateGenericRGB(color.red(), color.green(), color.blue(), color.alpha()));
     }
 
-    void display(PlatformGraphicsContext*);
-
     bool isTransformLayer() const;
 
     void addSublayer(PassRefPtr<WKCACFLayer> sublayer);
@@ -180,9 +182,6 @@ public:
     void setName(const String& name) { CACFLayerSetName(layer(), RetainPtr<CFStringRef>(AdoptCF, name.createCFString()).get()); }
     String name() const { return CACFLayerGetName(layer()); }
 
-    void setNeedsDisplay(const CGRect& dirtyRect);
-    void setNeedsDisplay();
-    
     void setNeedsDisplayOnBoundsChange(bool needsDisplay) { m_needsDisplayOnBoundsChange = needsDisplay; }
 
     void setOpacity(float opacity) { CACFLayerSetOpacity(layer(), opacity); setNeedsCommit(); }
@@ -228,10 +227,12 @@ public:
     void printTree() const;
 #endif
 
-private:
-    WKCACFLayer(LayerType, GraphicsLayerCACF* owner);
+protected:
+    WKCACFLayer(LayerType);
 
     void setNeedsCommit();
+
+private:
     CACFLayerRef layer() const { return m_layer.get(); }
     size_t numSublayers() const
     {
@@ -255,7 +256,6 @@ private:
 
     RetainPtr<CACFLayerRef> m_layer;
     bool m_needsDisplayOnBoundsChange;
-    GraphicsLayerCACF* m_owner;
 };
 
 }
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
index 382c117..9e43eab 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
@@ -38,6 +38,8 @@
 #include <QuartzCoreInterface/QuartzCoreInterface.h>
 #include <wtf/HashMap.h>
 #include <wtf/OwnArrayPtr.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/StdLibExtras.h>
 #include <d3d9.h>
 #include <d3dx9.h>
@@ -76,6 +78,33 @@ inline static CGRect winRectToCGRect(RECT rc, RECT relativeToRect)
 
 namespace WebCore {
 
+// Subclass of WKCACFLayer to allow the root layer to have a back pointer to the layer renderer
+// to fire off a draw
+class WKCACFRootLayer : public WKCACFLayer {
+public:
+    WKCACFRootLayer(WKCACFLayerRenderer* renderer)
+        : WKCACFLayer(WKCACFLayer::Layer)
+    {
+        m_renderer = renderer;
+    }
+
+    static PassRefPtr<WKCACFRootLayer> create(WKCACFLayerRenderer* renderer)
+    {
+        if (!WKCACFLayerRenderer::acceleratedCompositingAvailable())
+            return 0;
+        return adoptRef(new WKCACFRootLayer(renderer));
+    }
+
+    virtual void setNeedsRender() { m_renderer->renderSoon(); }
+
+    // Overload this to avoid calling setNeedsDisplay on the layer, which would override the contents
+    // we have placed on the root layer.
+    virtual void setNeedsDisplay(const CGRect* dirtyRect) { setNeedsCommit(); }
+
+private:
+    WKCACFLayerRenderer* m_renderer;
+};
+
 typedef HashMap<CACFContextRef, WKCACFLayerRenderer*> ContextToWindowMap;
 
 static ContextToWindowMap& windowsForContexts()
@@ -205,6 +234,11 @@ WKCACFLayerRenderer::~WKCACFLayerRenderer()
     destroyRenderer();
 }
 
+WKCACFLayer* WKCACFLayerRenderer::rootLayer() const
+{
+    return m_rootLayer.get();
+}
+
 void WKCACFLayerRenderer::setScrollFrame(const IntRect& scrollFrame)
 {
     m_scrollFrame = scrollFrame;
@@ -223,7 +257,7 @@ void WKCACFLayerRenderer::setRootContents(CGImageRef image)
     renderSoon();
 }
 
-void WKCACFLayerRenderer::setRootChildLayer(WebCore::PlatformLayer* layer)
+void WKCACFLayerRenderer::setRootChildLayer(WKCACFLayer* layer)
 {
     if (!m_scrollLayer)
         return;
@@ -242,7 +276,7 @@ void WKCACFLayerRenderer::setRootChildLayer(WebCore::PlatformLayer* layer)
 void WKCACFLayerRenderer::setNeedsDisplay()
 {
     ASSERT(m_rootLayer);
-    m_rootLayer->setNeedsDisplay();
+    m_rootLayer->setNeedsDisplay(0);
     renderSoon();
 }
 
@@ -298,7 +332,7 @@ bool WKCACFLayerRenderer::createRenderer()
     m_renderer = CARenderOGLNew(wkqcCARenderOGLCallbacks(wkqckCARenderDX9Callbacks), m_d3dDevice.get(), 0);
 
     // Create the root hierarchy
-    m_rootLayer = WKCACFLayer::create(WKCACFLayer::Layer);
+    m_rootLayer = WKCACFRootLayer::create(this);
     m_rootLayer->setName("WKCACFLayerRenderer rootLayer");
     m_scrollLayer = WKCACFLayer::create(WKCACFLayer::Layer);
     m_scrollLayer->setName("WKCACFLayerRenderer scrollLayer");
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
index 851c30e..f24f3e7 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
@@ -47,6 +47,8 @@ typedef struct _CARenderOGLContext CARenderOGLContext;
 
 namespace WebCore {
 
+class WKCACFRootLayer;
+
 // FIXME: Currently there is a WKCACFLayerRenderer for each WebView and each
 // has its own CARenderOGLContext and Direct3DDevice9, which is inefficient.
 // (https://bugs.webkit.org/show_bug.cgi?id=31855)
@@ -60,7 +62,7 @@ public:
 
     void setScrollFrame(const IntRect&);
     void setRootContents(CGImageRef);
-    void setRootChildLayer(WebCore::PlatformLayer* layer);
+    void setRootChildLayer(WKCACFLayer* layer);
     void setNeedsDisplay();
     void setHostWindow(HWND window) { m_hostWindow = window; }
 
@@ -70,7 +72,7 @@ public:
     void renderSoon();
 
 protected:
-    WKCACFLayer* rootLayer() const { return m_rootLayer.get(); }
+    WKCACFLayer* rootLayer() const;
 
 private:
     WKCACFLayerRenderer();
@@ -87,7 +89,7 @@ private:
 
     bool m_triedToCreateD3DRenderer;
     COMPtr<IDirect3DDevice9> m_d3dDevice;
-    RefPtr<WKCACFLayer> m_rootLayer;
+    RefPtr<WKCACFRootLayer> m_rootLayer;
     RefPtr<WKCACFLayer> m_viewLayer;
     RefPtr<WKCACFLayer> m_scrollLayer;
     RefPtr<WKCACFLayer> m_rootChildLayer;
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 68133ff..ab4a28b 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,20 @@
+2010-03-05  Chris Marrin  <cmarrin at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Got rid of platformLayer use in WebView.
+        https://bugs.webkit.org/show_bug.cgi?id=35798
+        
+        WKCACFLayer no longer depends on GraphicsLayer, so I got rid of
+        that dependency on WebView. Now WebChromeClient casts platformLayer
+        to WKCACFLayer which will always be the case on Windows.
+
+        * WebCoreSupport/WebChromeClient.cpp:
+        (WebChromeClient::attachRootGraphicsLayer):
+        * WebView.cpp:
+        (WebView::setRootChildLayer):
+        * WebView.h:
+
 2010-03-04  Beth Dakin  <bdakin at apple.com>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
index 45f7662..d32b6ce 100644
--- a/WebKit/win/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
@@ -46,6 +46,9 @@
 #include <WebCore/FrameLoadRequest.h>
 #include <WebCore/FrameView.h>
 #include <WebCore/Geolocation.h>
+#if USE(ACCELERATED_COMPOSITING)
+#include <WebCore/GraphicsLayer.h>
+#endif
 #include <WebCore/HTMLNames.h>
 #include <WebCore/LocalizedStrings.h>
 #include <WebCore/NotImplemented.h>
@@ -783,7 +786,7 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geoloca
 #if USE(ACCELERATED_COMPOSITING)
 void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 {
-    m_webView->setRootChildLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
+    m_webView->setRootChildLayer(graphicsLayer ? static_cast<WKCACFLayer*>(graphicsLayer->platformLayer()) : 0);
 }
 
 void WebChromeClient::scheduleCompositingLayerSync()
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index 480d20c..08f625e 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -6053,7 +6053,7 @@ void WebView::downloadURL(const KURL& url)
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-void WebView::setRootChildLayer(WebCore::PlatformLayer* layer)
+void WebView::setRootChildLayer(WebCore::WKCACFLayer* layer)
 {
     setAcceleratedCompositing(layer ? true : false);
     if (m_layerRenderer)
diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h
index dcf0bcd..a99df3a 100644
--- a/WebKit/win/WebView.h
+++ b/WebKit/win/WebView.h
@@ -876,7 +876,7 @@ public:
 
 #if USE(ACCELERATED_COMPOSITING)
     void setRootLayerNeedsDisplay() { if (m_layerRenderer) m_layerRenderer->setNeedsDisplay(); }
-    void setRootChildLayer(WebCore::PlatformLayer* layer);
+    void setRootChildLayer(WebCore::WKCACFLayer* layer);
 #endif
 
     void enterFullscreenForNode(WebCore::Node*);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list