Changeset 80515 in webkit


Ignore:
Timestamp:
Mar 7, 2011 5:49:52 PM (13 years ago)
Author:
helder@sencha.com
Message:

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

Reviewed by Simon Fraser.

Shadow is not shown when using strokeRect with a gradient strokeStyle
https://bugs.webkit.org/show_bug.cgi?id=52509

This happens in CG and is related to bug 51869, this time to be fixed
in GraphicsContext::strokeRect(const FloatRect& r, float lineWidth).
We need to draw the gradient clipped to the stroke on a CGLayer first,
and then draw the layer on the GraphicsContext.

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

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

Reviewed by Simon Fraser.

Shadow is not shown when using strokeRect with a gradient strokeStyle
https://bugs.webkit.org/show_bug.cgi?id=52509

This happens in CG and is related to bug 51869, this time to be fixed
in GraphicsContext::strokeRect(const FloatRect& r, float lineWidth).
We need to draw the gradient clipped to the stroke on a CGLayer first,
and then draw the layer on the GraphicsContext.

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

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

  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::strokeRect):
Location:
trunk
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80513 r80515  
     12011-03-07  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Shadow is not shown when using strokeRect with a gradient strokeStyle
     6        https://bugs.webkit.org/show_bug.cgi?id=52509
     7
     8        This happens in CG and is related to bug 51869, this time to be fixed
     9        in GraphicsContext::strokeRect(const FloatRect& r, float lineWidth).
     10        We need to draw the gradient clipped to the stroke on a CGLayer first,
     11        and then draw the layer on the GraphicsContext.
     12
     13        * fast/canvas/canvas-strokeRect-gradient-shadow-expected.txt: Added.
     14        * fast/canvas/canvas-strokeRect-gradient-shadow.html: Added.
     15        * fast/canvas/script-tests/canvas-strokeRect-gradient-shadow.js: Added.
     16        * platform/chromium/test_expectations.txt: Skip new test since it fails.
     17        * platform/mac/svg/css/rect-gradient-stroke-shadow-expected.checksum: Added.
     18        * platform/mac/svg/css/rect-gradient-stroke-shadow-expected.png: Added.
     19        * platform/qt/Skipped: Skip new test since it fails.
     20        * platform/qt/svg/css/rect-gradient-stroke-shadow-expected.checksum: Added.
     21        * platform/qt/svg/css/rect-gradient-stroke-shadow-expected.png: Added.
     22        * svg/css/rect-gradient-stroke-shadow-expected.txt: Added.
     23        * svg/css/rect-gradient-stroke-shadow.svg: Added.
     24
    1252011-03-07  Fumitoshi Ukai  <ukai@chromium.org>
    226
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r80513 r80515  
    26142614// New tests added with http://trac.webkit.org/changeset/72472 and further.
    26152615// See https://bugs.webkit.org/show_bug.cgi?id=51982 for more info.
     2616BUGWK52509 LINUX WIN : fast/canvas/canvas-strokeRect-gradient-shadow.html = TEXT
    26162617BUGCR63921 LINUX WIN : fast/canvas/canvas-fillPath-shadow.html = TEXT
    26172618BUGCR63921 CPU LINUX WIN : fast/canvas/canvas-fillPath-gradient-shadow.html = TEXT
  • trunk/LayoutTests/platform/qt/Skipped

    r80492 r80515  
    14721472fast/block/positioning/absolute-in-inline-rtl-4.html
    14731473fast/canvas/canvas-gradient-addStop-error.html
     1474fast/canvas/canvas-strokeRect-gradient-shadow.html
    14741475fast/css/zoom-body-scroll.html
    14751476fast/dom/Element/getBoundingClientRect.html
  • trunk/Source/WebCore/ChangeLog

    r80514 r80515  
     12011-03-07  Helder Correia  <helder@sencha.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Shadow is not shown when using strokeRect with a gradient strokeStyle
     6        https://bugs.webkit.org/show_bug.cgi?id=52509
     7
     8        This happens in CG and is related to bug 51869, this time to be fixed
     9        in GraphicsContext::strokeRect(const FloatRect& r, float lineWidth).
     10        We need to draw the gradient clipped to the stroke on a CGLayer first,
     11        and then draw the layer on the GraphicsContext.
     12
     13        Tests: fast/canvas/canvas-strokeRect-gradient-shadow.html
     14               svg/css/rect-gradient-stroke-shadow.svg
     15
     16        * platform/graphics/cg/GraphicsContextCG.cpp:
     17        (WebCore::GraphicsContext::strokeRect):
     18
    1192011-03-07  Justin Novosad  <junov@chromium.org>
    220
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r80049 r80515  
    988988}
    989989
    990 void GraphicsContext::strokeRect(const FloatRect& r, float lineWidth)
     990void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
    991991{
    992992    if (paintingDisabled())
     
    996996
    997997    if (m_state.strokeGradient) {
    998         CGContextSaveGState(context);
    999         setStrokeThickness(lineWidth);
    1000         CGContextAddRect(context, r);
    1001         CGContextReplacePathWithStrokedPath(context);
    1002         CGContextClip(context);
    1003         m_state.strokeGradient->paint(this);
    1004         CGContextRestoreGState(context);
     998        if (hasShadow()) {
     999            const float doubleLineWidth = lineWidth * 2;
     1000            const float layerWidth = ceilf(rect.width() + doubleLineWidth);
     1001            const float layerHeight = ceilf(rect.height() + doubleLineWidth);
     1002            CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(layerWidth, layerHeight), 0);
     1003
     1004            CGContextRef layerContext = CGLayerGetContext(layer);
     1005            m_state.strokeThickness = lineWidth;
     1006            CGContextSetLineWidth(layerContext, lineWidth);
     1007
     1008            // Compensate for the line width, otherwise the layer's top-left corner would be
     1009            // aligned with the rect's top-left corner. This would result in leaving pixels out of
     1010            // the layer on the left and top sides.
     1011            const float translationX = lineWidth - rect.x();
     1012            const float translationY = lineWidth - rect.y();
     1013            CGContextTranslateCTM(layerContext, translationX, translationY);
     1014
     1015            CGContextAddRect(layerContext, rect);
     1016            CGContextReplacePathWithStrokedPath(layerContext);
     1017            CGContextClip(layerContext);
     1018            CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
     1019            m_state.strokeGradient->paint(layerContext);
     1020
     1021            const float destinationX = roundf(rect.x() - lineWidth);
     1022            const float destinationY = roundf(rect.y() - lineWidth);
     1023            CGContextDrawLayerAtPoint(context, CGPointMake(destinationX, destinationY), layer);
     1024            CGLayerRelease(layer);
     1025        } else {
     1026            CGContextSaveGState(context);
     1027            setStrokeThickness(lineWidth);
     1028            CGContextAddRect(context, rect);
     1029            CGContextReplacePathWithStrokedPath(context);
     1030            CGContextClip(context);
     1031            CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
     1032            m_state.strokeGradient->paint(this);
     1033            CGContextRestoreGState(context);
     1034        }
    10051035        return;
    10061036    }
     
    10081038    if (m_state.strokePattern)
    10091039        applyStrokePattern();
    1010     CGContextStrokeRectWithWidth(context, r, lineWidth);
     1040    CGContextStrokeRectWithWidth(context, rect, lineWidth);
    10111041}
    10121042
Note: See TracChangeset for help on using the changeset viewer.