Changeset 80049 in webkit


Ignore:
Timestamp:
Mar 1, 2011 3:24:33 PM (13 years ago)
Author:
helder@sencha.com
Message:

2011-03-01 Helder Correia <helder@sencha.com>

Reviewed by Simon Fraser.

No shadow when stroking a path with a gradient
https://bugs.webkit.org/show_bug.cgi?id=55436

This happens in CG and is related to bug 52509, this time to be fixed
in GraphicsContext::strokePath(). The gradient needs to be drawn
clipped to the stroke on a CGLayer first, then the layer drawn on the
GraphicsContext.

  • fast/canvas/canvas-strokePath-gradient-shadow-expected.txt: Added.
  • fast/canvas/canvas-strokePath-gradient-shadow.html: Added.
  • fast/canvas/script-tests/canvas-strokePath-gradient-shadow.js: Added.
  • platform/chromium/test_expectations.txt: Skip new test since it fails.
  • platform/mac/svg/css/path-gradient-stroke-shadow-expected.checksum: Added.
  • platform/mac/svg/css/path-gradient-stroke-shadow-expected.png: Added.
  • platform/mac/svg/css/path-gradient-stroke-shadow-expected.txt: Added.
  • platform/qt/Skipped: Skip new test since it fails.
  • platform/qt/svg/css/path-gradient-stroke-shadow-expected.checksum: Added.
  • platform/qt/svg/css/path-gradient-stroke-shadow-expected.png: Added.
  • platform/qt/svg/css/path-gradient-stroke-shadow-expected.txt: Added.
  • svg/css/path-gradient-stroke-shadow.svg: Added.

2011-03-01 Helder Correia <helder@sencha.com>

Reviewed by Simon Fraser.

No shadow when stroking a path with a gradient
https://bugs.webkit.org/show_bug.cgi?id=55436

This happens in CG and is related to bug 52509, this time to be fixed
in GraphicsContext::strokePath(). The gradient needs to be drawn
clipped to the stroke on a CGLayer first, then the layer drawn on the
GraphicsContext.

Tests: fast/canvas/canvas-strokePath-gradient-shadow.html

svg/css/path-gradient-stroke-shadow.svg

  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::strokePath):
Location:
trunk
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80044 r80049  
     12011-03-01  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        No shadow when stroking a path with a gradient
     6        https://bugs.webkit.org/show_bug.cgi?id=55436
     7
     8        This happens in CG and is related to bug 52509, this time to be fixed
     9        in GraphicsContext::strokePath(). The gradient needs to be drawn
     10        clipped to the stroke on a CGLayer first, then the layer drawn on the
     11        GraphicsContext.
     12
     13        * fast/canvas/canvas-strokePath-gradient-shadow-expected.txt: Added.
     14        * fast/canvas/canvas-strokePath-gradient-shadow.html: Added.
     15        * fast/canvas/script-tests/canvas-strokePath-gradient-shadow.js: Added.
     16        * platform/chromium/test_expectations.txt: Skip new test since it fails.
     17        * platform/mac/svg/css/path-gradient-stroke-shadow-expected.checksum: Added.
     18        * platform/mac/svg/css/path-gradient-stroke-shadow-expected.png: Added.
     19        * platform/mac/svg/css/path-gradient-stroke-shadow-expected.txt: Added.
     20        * platform/qt/Skipped: Skip new test since it fails.
     21        * platform/qt/svg/css/path-gradient-stroke-shadow-expected.checksum: Added.
     22        * platform/qt/svg/css/path-gradient-stroke-shadow-expected.png: Added.
     23        * platform/qt/svg/css/path-gradient-stroke-shadow-expected.txt: Added.
     24        * svg/css/path-gradient-stroke-shadow.svg: Added.
     25
    1262011-03-01  Tony Gentilcore  <tonyg@chromium.org>
    227
  • trunk/Source/WebCore/ChangeLog

    r80047 r80049  
     12011-03-01  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        No shadow when stroking a path with a gradient
     6        https://bugs.webkit.org/show_bug.cgi?id=55436
     7
     8        This happens in CG and is related to bug 52509, this time to be fixed
     9        in GraphicsContext::strokePath(). The gradient needs to be drawn
     10        clipped to the stroke on a CGLayer first, then the layer drawn on the
     11        GraphicsContext.
     12
     13        Tests: fast/canvas/canvas-strokePath-gradient-shadow.html
     14               svg/css/path-gradient-stroke-shadow.svg
     15
     16        * platform/graphics/cg/GraphicsContextCG.cpp:
     17        (WebCore::GraphicsContext::strokePath):
     18
    1192011-03-01  David Hyatt  <hyatt@apple.com>
    220
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r78846 r80049  
    609609
    610610    if (m_state.strokeGradient) {
    611         CGContextSaveGState(context);
    612         CGContextReplacePathWithStrokedPath(context);
    613         CGContextClip(context);
    614         CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
    615         m_state.strokeGradient->paint(this);
    616         CGContextRestoreGState(context);
     611        if (hasShadow()) {
     612            FloatRect rect = path.boundingRect();
     613            float lineWidth = strokeThickness();
     614            float doubleLineWidth = lineWidth * 2;
     615            float layerWidth = ceilf(rect.width() + doubleLineWidth);
     616            float layerHeight = ceilf(rect.height() + doubleLineWidth);
     617
     618            CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(layerWidth, layerHeight), 0);
     619            CGContextRef layerContext = CGLayerGetContext(layer);
     620            CGContextSetLineWidth(layerContext, lineWidth);
     621
     622            // Compensate for the line width, otherwise the layer's top-left corner would be
     623            // aligned with the rect's top-left corner. This would result in leaving pixels out of
     624            // the layer on the left and top sides.
     625            float translationX = lineWidth - rect.x();
     626            float translationY = lineWidth - rect.y();
     627            CGContextTranslateCTM(layerContext, translationX, translationY);
     628
     629            CGContextAddPath(layerContext, path.platformPath());
     630            CGContextReplacePathWithStrokedPath(layerContext);
     631            CGContextClip(layerContext);
     632            CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
     633            m_state.strokeGradient->paint(layerContext);
     634
     635            float destinationX = roundf(rect.x() - lineWidth);
     636            float destinationY = roundf(rect.y() - lineWidth);
     637            CGContextDrawLayerAtPoint(context, CGPointMake(destinationX, destinationY), layer);
     638            CGLayerRelease(layer);
     639        } else {
     640            CGContextSaveGState(context);
     641            CGContextReplacePathWithStrokedPath(context);
     642            CGContextClip(context);
     643            CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
     644            m_state.strokeGradient->paint(this);
     645            CGContextRestoreGState(context);
     646        }
    617647        return;
    618648    }
Note: See TracChangeset for help on using the changeset viewer.