Changeset 103091 in webkit


Ignore:
Timestamp:
Dec 16, 2011 12:20:34 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] svg/clip-path/clip-in-mask.svg fails on Windows and Linux
https://bugs.webkit.org/show_bug.cgi?id=53378

Patch by Branimir Lambov <blambov@google.com> on 2011-12-16
Reviewed by Tony Chang.

Source/WebCore:

Fixes a problem in Skia's clipping layer code's handling of coordinate
transformations that was causing all complex clipping (including text
and/or masks) to fail.

The method beginLayerClippedToImage was taking rectangle coordinates
in one local coordinate space, but it was applying them in a different
one because of the delay between the time it is called and the actual
application occurs in applyClipFromImage. The fix translates the
coordinates passed to beginLayerClippedToImage to absolute ones, so
that they are not affected by any change in the transform matrix, and
makes sure that applyClipFromImage clears the matrix before drawing
the clip layer to correctly apply the absolute coordinates.

  • platform/graphics/skia/PlatformContextSkia.cpp:

(WebCore::PlatformContextSkia::beginLayerClippedToImage):
(WebCore::PlatformContextSkia::applyClipFromImage):

  • platform/graphics/skia/PlatformContextSkia.h:

LayoutTests:

Fixes a problem in Skia's clipping layer code's handling of coordinate
transformations that was causing all complex clipping (including text
and/or masks) to fail.

The method beginLayerClippedToImage was taking rectangle coordinates
in one local coordinate space, but it was applying them in a different
one because of the delay between the time it is called and the actual
application occurs in applyClipFromImage. The fix translates the
coordinates passed to beginLayerClippedToImage to absolute ones, so
that they are not affected by any change in the transform matrix, and
makes sure that applyClipFromImage clears the matrix before drawing
the clip layer to correctly apply the absolute coordinates.

  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
10 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103088 r103091  
     12011-12-16  Branimir Lambov  <blambov@google.com>
     2
     3        [chromium] svg/clip-path/clip-in-mask.svg fails on Windows and Linux
     4        https://bugs.webkit.org/show_bug.cgi?id=53378
     5
     6        Reviewed by Tony Chang.
     7
     8        Fixes a problem in Skia's clipping layer code's handling of coordinate
     9        transformations that was causing all complex clipping (including text
     10        and/or masks) to fail.
     11
     12        The method beginLayerClippedToImage was taking rectangle coordinates
     13        in one local coordinate space, but it was applying them in a different
     14        one because of the delay between the time it is called and the actual
     15        application occurs in applyClipFromImage. The fix translates the
     16        coordinates passed to beginLayerClippedToImage to absolute ones, so
     17        that they are not affected by any change in the transform matrix, and
     18        makes sure that applyClipFromImage clears the matrix before drawing
     19        the clip layer to correctly apply the absolute coordinates.
     20
     21        * platform/chromium/test_expectations.txt:
     22
    1232011-12-16  Adrienne Walker  <enne@google.com>
    224
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r103088 r103091  
    870870BUGCR52692 LINUX WIN : svg/W3C-SVG-1.1/animate-elem-80-t.svg = IMAGE+TEXT
    871871
    872 // New in WK r65880, some probably just need rebaselining, others have real diffs
    873 BUGWK53378 LINUX WIN : svg/clip-path/clip-in-mask.svg = IMAGE
    874 BUGWK53378 LINUX WIN : svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg = IMAGE+TEXT
    875 BUGWK53378 LINUX WIN : svg/clip-path/deep-nested-clip-in-mask-panning.svg = IMAGE+TEXT
    876 BUGWK53378 LINUX WIN : svg/clip-path/deep-nested-clip-in-mask.svg = IMAGE+TEXT
    877 BUGWK53378 LINUX WIN : svg/clip-path/nested-clip-in-mask-image-based-clipping.svg = IMAGE
    878 BUGWK53378 LINUX WIN : svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg = IMAGE
    879 BUGWK53378 LINUX WIN : svg/clip-path/nested-clip-in-mask-path-based-clipping.svg = IMAGE
    880 // Rebaselined in WK r65874, Linux has missing lines
     872// Windows needs rebaselining after 53378 patch.
     873BUGWK53378 WIN : svg/W3C-SVG-1.1/filters-example-01-b.svg = IMAGE
     874BUGWK53378 WIN : svg/batik/text/textProperties.svg = IMAGE
     875BUGWK53378 WIN : svg/clip-path/clip-in-mask.svg = IMAGE
     876BUGWK53378 WIN : svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg = IMAGE+TEXT
     877BUGWK53378 WIN : svg/clip-path/deep-nested-clip-in-mask-panning.svg = IMAGE+TEXT
     878BUGWK53378 WIN : svg/clip-path/deep-nested-clip-in-mask.svg = IMAGE+TEXT
     879BUGWK53378 WIN : svg/clip-path/nested-clip-in-mask-image-based-clipping.svg = IMAGE
     880BUGWK53378 WIN : svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg = IMAGE
     881BUGWK53378 WIN : svg/clip-path/nested-clip-in-mask-path-based-clipping.svg = IMAGE
    881882
    882883// Since r89233. May need a new baseline.
  • trunk/Source/WebCore/ChangeLog

    r103083 r103091  
     12011-12-16  Branimir Lambov  <blambov@google.com>
     2
     3        [chromium] svg/clip-path/clip-in-mask.svg fails on Windows and Linux
     4        https://bugs.webkit.org/show_bug.cgi?id=53378
     5
     6        Reviewed by Tony Chang.
     7
     8        Fixes a problem in Skia's clipping layer code's handling of coordinate
     9        transformations that was causing all complex clipping (including text
     10        and/or masks) to fail.
     11
     12        The method beginLayerClippedToImage was taking rectangle coordinates
     13        in one local coordinate space, but it was applying them in a different 
     14        one because of the delay between the time it is called and the actual
     15        application occurs in applyClipFromImage. The fix translates the
     16        coordinates passed to beginLayerClippedToImage to absolute ones, so
     17        that they are not affected by any change in the transform matrix, and
     18        makes sure that applyClipFromImage clears the matrix before drawing
     19        the clip layer to correctly apply the absolute coordinates.
     20
     21        * platform/graphics/skia/PlatformContextSkia.cpp:
     22        (WebCore::PlatformContextSkia::beginLayerClippedToImage):
     23        (WebCore::PlatformContextSkia::applyClipFromImage):
     24        * platform/graphics/skia/PlatformContextSkia.h:
     25
    1262011-12-16  Mark Hahnenberg  <mhahnenberg@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r101325 r103091  
    9797    SkBitmap m_imageBufferClip;
    9898    // If m_imageBufferClip is non-empty, this is the region the image is clipped to.
    99     FloatRect m_clip;
     99    SkRect m_clip;
    100100
    101101    InterpolationQuality m_interpolationQuality;
     
    232232    // time restore is invoked the layer and |imageBuffer| are combined to
    233233    // create the resulting image.
    234     m_state->m_clip = rect;
    235234    SkRect bounds = { SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()),
    236235                      SkFloatToScalar(rect.maxX()), SkFloatToScalar(rect.maxY()) };
     236    m_state->m_clip = bounds;
     237    // Get the absolute coordinates of the stored clipping rectangle to make it
     238    // independent of any transform changes.
     239    canvas()->getTotalMatrix().mapRect(&m_state->m_clip);
    237240
    238241    canvas()->clipRect(bounds);
     242
    239243    if (imageBuffer->size().isEmpty())
    240244        return;
     
    577581}
    578582
    579 void PlatformContextSkia::applyClipFromImage(const FloatRect& rect, const SkBitmap& imageBuffer)
     583void PlatformContextSkia::applyClipFromImage(const SkRect& rect, const SkBitmap& imageBuffer)
    580584{
    581585    // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we
     
    583587    SkPaint paint;
    584588    paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
    585     m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()), &paint);
     589    m_canvas->save(SkCanvas::kMatrix_SaveFlag);
     590    m_canvas->resetMatrix();
     591    m_canvas->drawBitmapRect(imageBuffer, 0, rect, &paint);
     592    m_canvas->restore();
    586593}
    587594
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h

    r101325 r103091  
    191191    // Used when restoring and the state has an image clip. Only shows the pixels in
    192192    // m_canvas that are also in imageBuffer.
    193     void applyClipFromImage(const FloatRect&, const SkBitmap&);
     193    // The clipping rectangle is given in absolute coordinates.
     194    void applyClipFromImage(const SkRect&, const SkBitmap&);
    194195
    195196    // common code between setupPaintFor[Filling,Stroking]
Note: See TracChangeset for help on using the changeset viewer.