Changeset 120755 in webkit


Ignore:
Timestamp:
Jun 19, 2012 2:33:56 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Dominik Röttsches <dominik.rottsches@intel.com> 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:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120754 r120755  
     12012-06-19  Dominik Röttsches  <dominik.rottsches@intel.com>
     2
     3        [cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
     4        https://bugs.webkit.org/show_bug.cgi?id=53085
     5
     6        Reviewed by Martin Robinson.
     7
     8        canvas/philip/tests/2d.pattern.paint.repeat* tests now passing.
     9
     10        * platform/efl/Skipped:
     11        * platform/gtk/TestExpectations:
     12
    1132012-06-19  Hayato Ito  <hayato@chromium.org>
    214
  • trunk/LayoutTests/platform/efl/Skipped

    r120692 r120755  
    386386# rectangle has zero height.
    387387canvas/philip/tests/2d.path.rect.zero.6.html
    388 
    389 # Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
    390 # https://bugs.webkit.org/show_bug.cgi?id=53085
    391 canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html
    392 canvas/philip/tests/2d.pattern.paint.repeatx.outside.html
    393 canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html
    394 canvas/philip/tests/2d.pattern.paint.repeaty.outside.html
    395388
    396389# BUG: Bug in the test itself, as the input box can be big enough for the given coordinates to be inside it.
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r120706 r120755  
    818818BUGWKGTK : canvas/philip/tests/2d.path.rect.zero.6.html = TEXT
    819819
    820 // Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
    821 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html = TEXT
    822 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.outside.html = TEXT
    823 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html = TEXT
    824 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.outside.html = TEXT
    825 
    826820// Tests that user modal dialogs fail in the DRT for some reason.
    827821BUGWK53600 : fast/animation/request-animation-frame-during-modal.html = TEXT
  • trunk/Source/WebCore/ChangeLog

    r120754 r120755  
     12012-06-19  Dominik Röttsches  <dominik.rottsches@intel.com>
     2
     3        [cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
     4        https://bugs.webkit.org/show_bug.cgi?id=53085
     5
     6        Reviewed by Martin Robinson.
     7
     8        Clipping previously unlimited vertical and horizontal pattern repeats with
     9        a clip rectangle similar to the Qt Graphics Context.
     10
     11        No new tests, this patch fixes
     12        canvas/philip/tests/2d.pattern.paint.repeat* tests.
     13
     14        * platform/graphics/Pattern.h:
     15        (WebCore::Pattern::getPatternSpaceTransform): Adding constant getter method to be able to map to pattern space externally, needed by PlatformContextCairo::clipForPatternFilling.
     16        * platform/graphics/cairo/PlatformContextCairo.cpp:
     17        (WebCore::PlatformContextCairo::prepareForFilling):
     18        (WebCore::PlatformContextCairo::clipForPatternFilling): Clip pattern repeats if needed.
     19        * platform/graphics/cairo/PlatformContextCairo.h:
     20
    1212012-06-19  Hayato Ito  <hayato@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/Pattern.h

    r120607 r120755  
    8383#endif
    8484    void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
     85    const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTransformation; };
    8586    void setPlatformPatternSpaceTransform();
    8687
  • trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp

    r120607 r120755  
    3232#include "Gradient.h"
    3333#include "GraphicsContext.h"
     34#include "OwnPtrCairo.h"
    3435#include "Pattern.h"
    3536#include <cairo.h>
     
    252253                              state.fillColor,
    253254                              patternAdjustment == AdjustPatternForGlobalAlpha ? globalAlpha() : 1);
     255
     256    if (state.fillPattern)
     257        clipForPatternFilling(state);
    254258}
    255259
     
    263267}
    264268
     269void PlatformContextCairo::clipForPatternFilling(const GraphicsContextState& state)
     270{
     271    ASSERT(state.fillPattern);
     272
     273    // Hold current cairo path in a variable for restoring it after configuring the pattern clip rectangle.
     274    OwnPtr<cairo_path_t> currentPath = adoptPtr(cairo_copy_path(m_cr.get()));
     275    cairo_new_path(m_cr.get());
     276
     277    // Initialize clipping extent from current cairo clip extents, then shrink if needed according to pattern.
     278    // Inspired by GraphicsContextQt::drawRepeatPattern.
     279    double x1, y1, x2, y2;
     280    cairo_clip_extents(m_cr.get(), &x1, &y1, &x2, &y2);
     281    FloatRect clipRect(x1, y1, x2 - x1, y2 - y1);
     282
     283    Image* patternImage = state.fillPattern->tileImage();
     284    ASSERT(patternImage);
     285    const AffineTransform& patternTransform = state.fillPattern->getPatternSpaceTransform();
     286    FloatRect patternRect = patternTransform.mapRect(FloatRect(0, 0, patternImage->width(), patternImage->height()));
     287
     288    bool repeatX = state.fillPattern->repeatX();
     289    bool repeatY = state.fillPattern->repeatY();
     290
     291    if (!repeatX) {
     292        clipRect.setX(patternRect.x());
     293        clipRect.setWidth(patternRect.width());
     294    }
     295    if (!repeatY) {
     296        clipRect.setY(patternRect.y());
     297        clipRect.setHeight(patternRect.height());
     298    }
     299    if (!repeatX || !repeatY) {
     300        cairo_rectangle(m_cr.get(), clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
     301        cairo_clip(m_cr.get());
     302    }
     303
     304    // Restoring cairo path.
     305    cairo_append_path(m_cr.get(), currentPath.get());
     306}
     307
    265308} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h

    r120607 r120755  
    6969
    7070private:
     71    void clipForPatternFilling(const GraphicsContextState&);
     72
    7173    RefPtr<cairo_t> m_cr;
    7274
Note: See TracChangeset for help on using the changeset viewer.