[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 11:35:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4ed7647f61793db2fe10a1529085ddfa6837d614
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 29 23:17:46 2010 +0000

    2010-07-29  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Dirk Schulze.
    
            [Cairo] Bring behavior of paths on the Cairo GraphicsContext into line with the CoreGraphics port
            https://bugs.webkit.org/show_bug.cgi?id=41732
    
            Do not apply paths added to the Cairo GraphicsContext, until they are used.
            This prevents drawing routines such as fillRect from interacting with any
            path which callers are constructing on the GraphicsContext.
    
             This behavior is necessary to close bug https://bugs.webkit.org/show_bug.cgi?id=41308
             so tests for that issue will test this fix.
    
            * platform/graphics/cairo/GraphicsContextCairo.cpp:
            (WebCore::appendPathToCairoContext): Added. A helper method which adds a path
            to a native Cairo context.
            (WebCore::setPathOnCairoContext): Added. Like appendPathToCairoContext, but clears the
            existing path first.
            (WebCore::appendWebCorePathToCairoContext): Added. Like appendPathToCairoContext, but
            operates on a WebCore path.
            (WebCore::GraphicsContext::drawEllipse): Only clear the Cairo path if cairo_stroke
            was not called, because cairo_stroke implicitly clears the path.
            (WebCore::GraphicsContext::drawConvexPolygon): Ditto.
            (WebCore::GraphicsContext::fillPath): Copy the path from m_pendingPath to the context
            and clear m_pendingPath, instead of relying on the pre-existing context path.
            (WebCore::GraphicsContext::strokePath): Ditto.
            (WebCore::GraphicsContext::drawPath): Ditto.
            (WebCore::GraphicsContext::drawFocusRing): Use the new appendWebCorePathToCairoContext helper instead
            of addPath (which will blow away any path callers are building).
            (WebCore::GraphicsContext::addInnerRoundedRectClip): Use the new appendWebCorePathToCairoContext helper instead
            of addPath (which will blow away any path callers are building).
            (WebCore::GraphicsContext::beginPath): Clear out m_pendingPath here instead of the main native context.
            (WebCore::GraphicsContext::addPath): Add the path to m_pendingPath instead of the main native context.
            Also ensure that the transformation matrix of the m_pendingPath is equal to that of the main
            cairo context.
            (WebCore::GraphicsContext::clipOut): Use the appendWebCorePathToCairoContext helper here.
            (WebCore::GraphicsContext::fillRoundedRect): Ditto and remove an unnecessary beginPath call.
            * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Add a new m_pendingPath member.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64318 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7655f8a..8a14e5c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,46 @@
 
         Reviewed by Dirk Schulze.
 
+        [Cairo] Bring behavior of paths on the Cairo GraphicsContext into line with the CoreGraphics port
+        https://bugs.webkit.org/show_bug.cgi?id=41732
+
+        Do not apply paths added to the Cairo GraphicsContext, until they are used.
+        This prevents drawing routines such as fillRect from interacting with any
+        path which callers are constructing on the GraphicsContext.
+
+         This behavior is necessary to close bug https://bugs.webkit.org/show_bug.cgi?id=41308
+         so tests for that issue will test this fix.
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::appendPathToCairoContext): Added. A helper method which adds a path
+        to a native Cairo context.
+        (WebCore::setPathOnCairoContext): Added. Like appendPathToCairoContext, but clears the
+        existing path first.
+        (WebCore::appendWebCorePathToCairoContext): Added. Like appendPathToCairoContext, but
+        operates on a WebCore path.
+        (WebCore::GraphicsContext::drawEllipse): Only clear the Cairo path if cairo_stroke
+        was not called, because cairo_stroke implicitly clears the path.
+        (WebCore::GraphicsContext::drawConvexPolygon): Ditto.
+        (WebCore::GraphicsContext::fillPath): Copy the path from m_pendingPath to the context
+        and clear m_pendingPath, instead of relying on the pre-existing context path.
+        (WebCore::GraphicsContext::strokePath): Ditto.
+        (WebCore::GraphicsContext::drawPath): Ditto.
+        (WebCore::GraphicsContext::drawFocusRing): Use the new appendWebCorePathToCairoContext helper instead
+        of addPath (which will blow away any path callers are building).
+        (WebCore::GraphicsContext::addInnerRoundedRectClip): Use the new appendWebCorePathToCairoContext helper instead
+        of addPath (which will blow away any path callers are building).
+        (WebCore::GraphicsContext::beginPath): Clear out m_pendingPath here instead of the main native context.
+        (WebCore::GraphicsContext::addPath): Add the path to m_pendingPath instead of the main native context.
+        Also ensure that the transformation matrix of the m_pendingPath is equal to that of the main
+        cairo context.
+        (WebCore::GraphicsContext::clipOut): Use the appendWebCorePathToCairoContext helper here.
+        (WebCore::GraphicsContext::fillRoundedRect): Ditto and remove an unnecessary beginPath call.
+        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Add a new m_pendingPath member.
+
+2010-07-29  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Dirk Schulze.
+
         [Cairo] Remove setStrokeStyle workaround for InlineTextBoxes
         https://bugs.webkit.org/show_bug.cgi?id=43136
 
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index 79431f0..e0aa551 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -4,6 +4,7 @@
  * Copyright (C) 2008, 2009 Dirk Schulze <krit at webkit.org>
  * Copyright (C) 2008 Nuanti Ltd.
  * Copyright (C) 2009 Brent Fulgham <bfulgham at webkit.org>
+ * Copyright (C) 2010 Igalia S.L.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -143,6 +144,27 @@ static inline void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
     cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr));
 }
 
+static void appendPathToCairoContext(cairo_t* to, cairo_t* from)
+{
+    cairo_path_t* cairoPath = cairo_copy_path(from);
+    cairo_append_path(to, cairoPath);
+    cairo_path_destroy(cairoPath);
+}
+
+// We apply the pending path built via addPath to the Cairo context
+// lazily. This prevents interaction between the path and other routines
+// such as fillRect.
+static void setPathOnCairoContext(cairo_t* to, cairo_t* from)
+{
+    cairo_new_path(to);
+    appendPathToCairoContext(to, from);
+}
+
+static void appendWebCorePathToCairoContext(cairo_t* context, const Path& path)
+{
+    appendPathToCairoContext(context, path.platformPath()->m_cr);
+}
+
 void GraphicsContext::calculateShadowBufferDimensions(IntSize& shadowBufferSize, FloatRect& shadowRect, float& kernelSize, const FloatRect& sourceRect, const FloatSize& shadowSize, float shadowBlur)
 {
 #if ENABLE(FILTERS)
@@ -380,9 +402,8 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
         setColor(cr, strokeColor());
         cairo_set_line_width(cr, strokeThickness());
         cairo_stroke(cr);
-    }
-
-    cairo_new_path(cr);
+    } else
+        cairo_new_path(cr);
 }
 
 void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
@@ -498,9 +519,9 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
         setColor(cr, strokeColor());
         cairo_set_line_width(cr, strokeThickness());
         cairo_stroke(cr);
-    }
+    } else
+        cairo_new_path(cr);
 
-    cairo_new_path(cr);
     cairo_restore(cr);
 }
 
@@ -522,6 +543,8 @@ void GraphicsContext::fillPath()
 
     cairo_t* cr = m_data->cr;
 
+    setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
+
     cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
     drawPathShadow(this, m_common, true, false);
 
@@ -535,6 +558,9 @@ void GraphicsContext::strokePath()
         return;
 
     cairo_t* cr = m_data->cr;
+
+    setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
+
     drawPathShadow(this, m_common, false, true);
 
     setPlatformStroke(this, cr, m_common);
@@ -549,6 +575,8 @@ void GraphicsContext::drawPath()
 
     cairo_t* cr = m_data->cr;
 
+    setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
+
     cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
     drawPathShadow(this, m_common, true, true);
 
@@ -673,7 +701,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
 #else
     int radius = (width - 1) / 2;
     for (unsigned i = 0; i < rectCount; i++)
-        addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
+        appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
 
     // Force the alpha to 50%.  This matches what the Mac does with outline rings.
     Color ringColor(color.red(), color.green(), color.blue(), 127);
@@ -840,6 +868,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
     if (paintingDisabled())
         return;
 
+    cairo_t* cr = m_data->cr;
     clip(rect);
 
     Path p;
@@ -849,9 +878,8 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
     // Add inner ellipse
     r.inflate(-thickness);
     p.addEllipse(r);
-    addPath(p);
+    appendWebCorePathToCairoContext(cr, p);
 
-    cairo_t* cr = m_data->cr;
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
     cairo_clip(cr);
@@ -1079,8 +1107,7 @@ void GraphicsContext::beginPath()
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->cr;
-    cairo_new_path(cr);
+    cairo_new_path(m_data->m_pendingPath.m_cr);
 }
 
 void GraphicsContext::addPath(const Path& path)
@@ -1088,10 +1115,10 @@ void GraphicsContext::addPath(const Path& path)
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->cr;
-    cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
-    cairo_append_path(cr, p);
-    cairo_path_destroy(p);
+    cairo_matrix_t currentMatrix;
+    cairo_get_matrix(m_data->cr, &currentMatrix);
+    cairo_set_matrix(m_data->m_pendingPath.m_cr, &currentMatrix);
+    appendWebCorePathToCairoContext(m_data->m_pendingPath.m_cr, path);
 }
 
 void GraphicsContext::clip(const Path& path)
@@ -1124,7 +1151,7 @@ void GraphicsContext::clipOut(const Path& path)
     double x1, y1, x2, y2;
     cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
     cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
-    addPath(path);
+    appendWebCorePathToCairoContext(cr, path);
 
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
@@ -1183,8 +1210,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft,
 
     cairo_t* cr = m_data->cr;
     cairo_save(cr);
-    beginPath();
-    addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
+    appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
     setColor(cr, color);
     drawPathShadow(this, m_common, true, false);
     cairo_fill(cr);
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
index 5e38832..97e7e07 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
+++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
@@ -95,6 +95,7 @@ public:
 
     cairo_t* cr;
     Vector<float> layers;
+    CairoPath m_pendingPath;
 
 #if PLATFORM(GTK)
     GdkEventExpose* expose;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list