Title: [120755] trunk
Revision
120755
Author
[email protected]
Date
2012-06-19 14:33:56 -0700 (Tue, 19 Jun 2012)

Log Message

[cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
https://bugs.webkit.org/show_bug.cgi?id=53085

Patch by Dominik Röttsches <[email protected]> on 2012-06-19
Reviewed by Martin Robinson.

Source/WebCore:

Clipping previously unlimited vertical and horizontal pattern repeats with
a clip rectangle similar to the Qt Graphics Context.

No new tests, this patch fixes
canvas/philip/tests/2d.pattern.paint.repeat* tests.

* platform/graphics/Pattern.h:
(WebCore::Pattern::getPatternSpaceTransform): Adding constant getter method to be able to map to pattern space externally, needed by PlatformContextCairo::clipForPatternFilling.
* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::prepareForFilling):
(WebCore::PlatformContextCairo::clipForPatternFilling): Clip pattern repeats if needed.
* platform/graphics/cairo/PlatformContextCairo.h:

LayoutTests:

canvas/philip/tests/2d.pattern.paint.repeat* tests now passing.

* platform/efl/Skipped:
* platform/gtk/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120754 => 120755)


--- trunk/LayoutTests/ChangeLog	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/LayoutTests/ChangeLog	2012-06-19 21:33:56 UTC (rev 120755)
@@ -1,3 +1,15 @@
+2012-06-19  Dominik Röttsches  <[email protected]>
+
+        [cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
+        https://bugs.webkit.org/show_bug.cgi?id=53085
+
+        Reviewed by Martin Robinson.
+
+        canvas/philip/tests/2d.pattern.paint.repeat* tests now passing.
+
+        * platform/efl/Skipped:
+        * platform/gtk/TestExpectations:
+
 2012-06-19  Hayato Ito  <[email protected]>
 
         [Shadow DOM] An upper boundary breaks if a child node of an insertion point is clicked.

Modified: trunk/LayoutTests/platform/efl/Skipped (120754 => 120755)


--- trunk/LayoutTests/platform/efl/Skipped	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-06-19 21:33:56 UTC (rev 120755)
@@ -386,13 +386,6 @@
 # rectangle has zero height.
 canvas/philip/tests/2d.path.rect.zero.6.html
 
-# Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
-# https://bugs.webkit.org/show_bug.cgi?id=53085
-canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html
-canvas/philip/tests/2d.pattern.paint.repeatx.outside.html
-canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html
-canvas/philip/tests/2d.pattern.paint.repeaty.outside.html
-
 # BUG: Bug in the test itself, as the input box can be big enough for the given coordinates to be inside it.
 fast/forms/input-text-click-outside.html
 

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (120754 => 120755)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-19 21:33:56 UTC (rev 120755)
@@ -817,12 +817,6 @@
 // rectangle has zero height.
 BUGWKGTK : canvas/philip/tests/2d.path.rect.zero.6.html = TEXT
 
-// Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
-BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html = TEXT
-BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.outside.html = TEXT
-BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html = TEXT
-BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.outside.html = TEXT
-
 // Tests that user modal dialogs fail in the DRT for some reason.
 BUGWK53600 : fast/animation/request-animation-frame-during-modal.html = TEXT
 BUGWK53600 : fast/events/show-modal-dialog-onblur-onfocus.html = TEXT

Modified: trunk/Source/WebCore/ChangeLog (120754 => 120755)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 21:33:56 UTC (rev 120755)
@@ -1,3 +1,23 @@
+2012-06-19  Dominik Röttsches  <[email protected]>
+
+        [cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
+        https://bugs.webkit.org/show_bug.cgi?id=53085
+
+        Reviewed by Martin Robinson.
+
+        Clipping previously unlimited vertical and horizontal pattern repeats with
+        a clip rectangle similar to the Qt Graphics Context.
+
+        No new tests, this patch fixes
+        canvas/philip/tests/2d.pattern.paint.repeat* tests.
+
+        * platform/graphics/Pattern.h:
+        (WebCore::Pattern::getPatternSpaceTransform): Adding constant getter method to be able to map to pattern space externally, needed by PlatformContextCairo::clipForPatternFilling.
+        * platform/graphics/cairo/PlatformContextCairo.cpp:
+        (WebCore::PlatformContextCairo::prepareForFilling):
+        (WebCore::PlatformContextCairo::clipForPatternFilling): Clip pattern repeats if needed.
+        * platform/graphics/cairo/PlatformContextCairo.h:
+
 2012-06-19  Hayato Ito  <[email protected]>
 
         [Shadow DOM] An upper boundary breaks if a child node of an insertion point is clicked.

Modified: trunk/Source/WebCore/platform/graphics/Pattern.h (120754 => 120755)


--- trunk/Source/WebCore/platform/graphics/Pattern.h	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/Source/WebCore/platform/graphics/Pattern.h	2012-06-19 21:33:56 UTC (rev 120755)
@@ -82,6 +82,7 @@
     PlatformPatternPtr createPlatformPattern(const AffineTransform& userSpaceTransformation) const;
 #endif
     void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
+    const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTransformation; };
     void setPlatformPatternSpaceTransform();
 
     bool repeatX() const { return m_repeatX; }

Modified: trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp (120754 => 120755)


--- trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp	2012-06-19 21:33:56 UTC (rev 120755)
@@ -31,6 +31,7 @@
 #include "CairoUtilities.h"
 #include "Gradient.h"
 #include "GraphicsContext.h"
+#include "OwnPtrCairo.h"
 #include "Pattern.h"
 #include <cairo.h>
 
@@ -251,6 +252,9 @@
                               state.fillGradient.get(),
                               state.fillColor,
                               patternAdjustment == AdjustPatternForGlobalAlpha ? globalAlpha() : 1);
+
+    if (state.fillPattern)
+        clipForPatternFilling(state);
 }
 
 void PlatformContextCairo::prepareForStroking(const GraphicsContextState& state, AlphaPreservation alphaPreservation)
@@ -262,4 +266,43 @@
                               alphaPreservation == PreserveAlpha ? globalAlpha() : 1);
 }
 
+void PlatformContextCairo::clipForPatternFilling(const GraphicsContextState& state)
+{
+    ASSERT(state.fillPattern);
+
+    // Hold current cairo path in a variable for restoring it after configuring the pattern clip rectangle.
+    OwnPtr<cairo_path_t> currentPath = adoptPtr(cairo_copy_path(m_cr.get()));
+    cairo_new_path(m_cr.get());
+
+    // Initialize clipping extent from current cairo clip extents, then shrink if needed according to pattern.
+    // Inspired by GraphicsContextQt::drawRepeatPattern.
+    double x1, y1, x2, y2;
+    cairo_clip_extents(m_cr.get(), &x1, &y1, &x2, &y2);
+    FloatRect clipRect(x1, y1, x2 - x1, y2 - y1);
+
+    Image* patternImage = state.fillPattern->tileImage();
+    ASSERT(patternImage);
+    const AffineTransform& patternTransform = state.fillPattern->getPatternSpaceTransform();
+    FloatRect patternRect = patternTransform.mapRect(FloatRect(0, 0, patternImage->width(), patternImage->height()));
+
+    bool repeatX = state.fillPattern->repeatX();
+    bool repeatY = state.fillPattern->repeatY();
+
+    if (!repeatX) {
+        clipRect.setX(patternRect.x());
+        clipRect.setWidth(patternRect.width());
+    }
+    if (!repeatY) {
+        clipRect.setY(patternRect.y());
+        clipRect.setHeight(patternRect.height());
+    }
+    if (!repeatX || !repeatY) {
+        cairo_rectangle(m_cr.get(), clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+        cairo_clip(m_cr.get());
+    }
+
+    // Restoring cairo path.
+    cairo_append_path(m_cr.get(), currentPath.get());
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h (120754 => 120755)


--- trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h	2012-06-19 21:20:22 UTC (rev 120754)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h	2012-06-19 21:33:56 UTC (rev 120755)
@@ -68,6 +68,8 @@
     void prepareForStroking(const GraphicsContextState&, AlphaPreservation = PreserveAlpha);
 
 private:
+    void clipForPatternFilling(const GraphicsContextState&);
+
     RefPtr<cairo_t> m_cr;
 
     class State;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to