[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

cmarrin at apple.com cmarrin at apple.com
Fri Feb 26 22:17:19 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 1a522c6bd88cc90a57b26e6584f13b8cd9ffb656
Author: cmarrin at apple.com <cmarrin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 11 00:11:24 2010 +0000

            Added CA_PRINT_TREE functionality to WKCACFLayer implementation
            https://bugs.webkit.org/show_bug.cgi?id=34779
    
            I've tried to duplicate the look of the output on Mac, but
            it's not quite the same. It shows all the useful information though.
            It is enabled by setting the environment variable CA_PRINT_TREE=1
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54630 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bf43300..eb74b48 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-02-10  Chris Marrin  <cmarrin at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Added CA_PRINT_TREE functionality to WKCACFLayer implementation
+        https://bugs.webkit.org/show_bug.cgi?id=34779
+        
+        I've tried to duplicate the look of the output on Mac, but
+        it's not quite the same. It shows all the useful information though.
+        It is enabled by setting the environment variable CA_PRINT_TREE=1
+        
+        * platform/graphics/win/WKCACFLayer.cpp:Implementation of printTree
+        (WebCore::WKCACFLayer::isTransformLayer):
+            Moved function to cpp file because it needs to use the function form
+            of kCACFTransformLayer because the DLL is delay loaded, and that function
+            can only be called from the cpp file.
+        (WebCore::WKCACFLayer::sublayerAtIndex):
+        (WebCore::printIndent):
+        (WebCore::printTransform):
+        (WebCore::WKCACFLayer::printTree):Prints from this layer down
+        (WebCore::WKCACFLayer::printLayer):Prints this layer and recursively calls sublayers
+        * platform/graphics/win/WKCACFLayer.h:
+        * platform/graphics/win/WKCACFLayerRenderer.cpp:
+        (WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer):
+        (WebCore::WKCACFLayerRenderer::createRenderer):Adds a name to the root layers
+        (WebCore::WKCACFLayerRenderer::render):Calls printTree when CA_PRINT_TREE is 1
+        * platform/graphics/win/WKCACFLayerRenderer.h:
+        
 2010-02-10  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp
index e97fac9..e5b184d 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp
@@ -29,6 +29,7 @@
 
 #include "WKCACFLayer.h"
 
+#include "CString.h"
 #include "WKCACFContextFlusher.h"
 #include "WKCACFLayerRenderer.h"
 
@@ -37,6 +38,10 @@
 #include <QuartzCore/CARender.h>
 #include <QuartzCoreInterface/QuartzCoreInterface.h>
 
+#ifndef NDEBUG
+#include <wtf/CurrentTime.h>
+#endif
+
 #ifdef DEBUG_ALL
 #pragma comment(lib, "QuartzCore_debug")
 #pragma comment(lib, "QuartzCoreInterface_debug")
@@ -282,6 +287,11 @@ void WKCACFLayer::setNeedsCommit()
         m_owner->notifySyncRequired();
 }
 
+bool WKCACFLayer::isTransformLayer() const
+{
+    return CACFLayerGetClass(layer()) == kCACFTransformLayer();
+}
+
 void WKCACFLayer::addSublayer(PassRefPtr<WKCACFLayer> sublayer)
 {
     insertSublayer(sublayer, numSublayers());
@@ -372,6 +382,15 @@ void WKCACFLayer::removeSublayer(const WKCACFLayer* sublayer)
     setNeedsCommit();
 }
 
+const WKCACFLayer* WKCACFLayer::sublayerAtIndex(int index) const
+{
+    CFArrayRef sublayers = CACFLayerGetSublayers(layer());
+    if (index < 0 || CFArrayGetCount(sublayers) <= index)
+        return 0;
+    
+    return layer(static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, index))));
+}
+
 int WKCACFLayer::indexOfSublayer(const WKCACFLayer* reference)
 {
     CACFLayerRef ref = reference->layer();
@@ -518,7 +537,108 @@ void WKCACFLayer::setNeedsDisplay()
     setNeedsCommit();
 }
 
+#ifndef NDEBUG
+static void printIndent(int indent)
+{
+    for ( ; indent > 0; --indent)
+        fprintf(stderr, "  ");
+}
+
+static void printTransform(const CATransform3D& transform)
+{
+    fprintf(stderr, "[%g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g]",
+                    transform.m11, transform.m12, transform.m13, transform.m14, 
+                    transform.m21, transform.m22, transform.m23, transform.m24, 
+                    transform.m31, transform.m32, transform.m33, transform.m34, 
+                    transform.m41, transform.m42, transform.m43, transform.m44);
+}
+
+void WKCACFLayer::printTree() const
+{
+    // Print heading info
+    CGRect rootBounds = bounds();
+    fprintf(stderr, "\n\n** Render tree at time %g (bounds %g, %g %gx%g) **\n\n", 
+        currentTime(), rootBounds.origin.x, rootBounds.origin.y, rootBounds.size.width, rootBounds.size.height);
+
+    // Print layer tree from the root
+    printLayer(0);
+}
+
+void WKCACFLayer::printLayer(int indent) const
+{
+    CGPoint layerPosition = position();
+    CGPoint layerAnchorPoint = anchorPoint();
+    CGRect layerBounds = bounds();
+    printIndent(indent);
+    fprintf(stderr, "(%s [%g %g %g] [%g %g %g %g] [%g %g %g]\n",
+        isTransformLayer() ? "transform-layer" : "layer",
+        layerPosition.x, layerPosition.y, zPosition(), 
+        layerBounds.origin.x, layerBounds.origin.y, layerBounds.size.width, layerBounds.size.height,
+        layerAnchorPoint.x, layerAnchorPoint.y, anchorPointZ());
+
+    // Print name if needed
+    String layerName = name();
+    if (!layerName.isEmpty()) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(name %s)\n", layerName.utf8().data());
+    }
+
+    // Print masksToBounds if needed
+    bool layerMasksToBounds = masksToBounds();
+    if (layerMasksToBounds) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(masksToBounds true)\n");
+    }
+
+    // Print opacity if needed
+    float layerOpacity = opacity();
+    if (layerOpacity != 1) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(opacity %hf)\n", layerOpacity);
+    }
+
+    // Print sublayerTransform if needed
+    CATransform3D layerTransform = sublayerTransform();
+    if (!CATransform3DIsIdentity(layerTransform)) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(sublayerTransform ");
+        printTransform(layerTransform);
+        fprintf(stderr, ")\n");
+    }
+
+    // Print transform if needed
+    layerTransform = transform();
+    if (!CATransform3DIsIdentity(layerTransform)) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(transform ");
+        printTransform(layerTransform);
+        fprintf(stderr, ")\n");
+    }
+
+    // Print contents if needed
+    CGImageRef layerContents = contents();
+    if (layerContents) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(contents (image [%d %d]))\n",
+            CGImageGetWidth(layerContents), CGImageGetHeight(layerContents));
+    }
+
+    // Print sublayers if needed
+    int n = numSublayers();
+    if (n > 0) {
+        printIndent(indent + 1);
+        fprintf(stderr, "(sublayers\n");
+        for (int i = 0; i < n; ++i)
+            sublayerAtIndex(i)->printLayer(indent + 2);
 
+        printIndent(indent + 1);
+        fprintf(stderr, ")\n");
+    }
+
+    printIndent(indent);
+    fprintf(stderr, ")\n");
+}
+#endif // #ifndef NDEBUG
 }
 
 #endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h
index 6892c6e..e5568c9 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayer.h
@@ -108,7 +108,7 @@ public:
 
     void display(PlatformGraphicsContext*);
 
-    bool isTransformLayer() const { return CACFLayerGetClass(layer()) == kCACFTransformLayer; }
+    bool isTransformLayer() const;
 
     void addSublayer(PassRefPtr<WKCACFLayer> sublayer);
     void insertSublayer(PassRefPtr<WKCACFLayer>, size_t index);
@@ -223,6 +223,11 @@ public:
     void setGeometryFlipped(bool flipped) { CACFLayerSetGeometryFlipped(layer(), flipped); setNeedsCommit(); }
     bool geometryFlipped() const { return CACFLayerIsGeometryFlipped(layer()); }
 
+#ifndef NDEBUG
+    // Print the tree from the root. Also does consistency checks
+    void printTree() const;
+#endif
+
 private:
     WKCACFLayer(LayerType, GraphicsLayerCACF* owner);
 
@@ -233,6 +238,8 @@ private:
         CFArrayRef sublayers = CACFLayerGetSublayers(layer());
         return sublayers ? CFArrayGetCount(sublayers) : 0;
     }
+
+    const WKCACFLayer* sublayerAtIndex(int) const;
     
     // Returns the index of the passed layer in this layer's sublayers list
     // or -1 if not found
@@ -241,6 +248,11 @@ private:
     // This should only be called from removeFromSuperlayer.
     void removeSublayer(const WKCACFLayer*);
 
+#ifndef NDEBUG
+    // Print this layer and its children to the console
+    void printLayer(int indent) const;
+#endif
+
     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 20983d8..78ebb9d 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
@@ -142,6 +142,10 @@ WKCACFLayerRenderer::WKCACFLayerRenderer()
     , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired)
     , m_scrollFrame(0, 0, 1, 1) // Default to 1 to avoid 0 size frames
 {
+#ifndef NDEBUG
+    char* printTreeFlag = getenv("CA_PRINT_TREE");
+    m_printTree = printTreeFlag && atoi(printTreeFlag);
+#endif
 }
 
 WKCACFLayerRenderer::~WKCACFLayerRenderer()
@@ -228,7 +232,9 @@ void WKCACFLayerRenderer::createRenderer()
 
     // Create the root hierarchy
     m_rootLayer = WKCACFLayer::create(WKCACFLayer::Layer);
+    m_rootLayer->setName("WKCACFLayerRenderer rootLayer");
     m_scrollLayer = WKCACFLayer::create(WKCACFLayer::Layer);
+    m_scrollLayer->setName("WKCACFLayerRenderer scrollLayer");
 
     m_rootLayer->addSublayer(m_scrollLayer);
     m_scrollLayer->setMasksToBounds(true);
@@ -398,6 +404,11 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)
     } while (err == D3DERR_DEVICELOST);
 
     CARenderUpdateFinish(u);
+
+#ifndef NDEBUG
+    if (m_printTree)
+        m_rootLayer->printTree();
+#endif
 }
 
 void WKCACFLayerRenderer::renderSoon()
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
index cb9f04f..4e76f55 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
@@ -97,6 +97,10 @@ private:
     HWND m_hostWindow;
     Timer<WKCACFLayerRenderer> m_renderTimer;
     IntRect m_scrollFrame;
+
+#ifndef NDEBUG
+    bool m_printTree;
+#endif
 };
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list