Changeset 120598 in webkit


Ignore:
Timestamp:
Jun 18, 2012 8:41:05 AM (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-18
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

    r120595 r120598  
     12012-06-18  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-18  Zan Dobersek  <zandobersek@gmail.com>
    214
  • trunk/LayoutTests/platform/efl/Skipped

    r120593 r120598  
    389389# rectangle has zero height.
    390390canvas/philip/tests/2d.path.rect.zero.6.html
    391 
    392 # Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
    393 # https://bugs.webkit.org/show_bug.cgi?id=53085
    394 canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html
    395 canvas/philip/tests/2d.pattern.paint.repeatx.outside.html
    396 canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html
    397 canvas/philip/tests/2d.pattern.paint.repeaty.outside.html
    398391
    399392# 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

    r120593 r120598  
    821821BUGWKGTK : canvas/philip/tests/2d.path.rect.zero.6.html = TEXT
    822822
    823 // Repeat-x/-y doesn't work - not supported in Cairo, workaround needed
    824 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html = TEXT
    825 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeatx.outside.html = TEXT
    826 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html = TEXT
    827 BUGWK53085 : canvas/philip/tests/2d.pattern.paint.repeaty.outside.html = TEXT
    828 
    829823// Tests that user modal dialogs fail in the DRT for some reason.
    830824BUGWK53600 : fast/animation/request-animation-frame-during-modal.html = TEXT
  • trunk/Source/WebCore/ChangeLog

    r120597 r120598  
     12012-06-18  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-18  Robert Kroeger  <rjkroege@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/Pattern.h

    r113830 r120598  
    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

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

    r119392 r120598  
    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.