RESOLVED FIXED 52509
Shadow is not shown when using strokeRect with a gradient strokeStyle
https://bugs.webkit.org/show_bug.cgi?id=52509
Summary Shadow is not shown when using strokeRect with a gradient strokeStyle
Helder Correia
Reported Saturday, January 15, 2011 9:41:40 AM UTC
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.
Attachments
Patch (16.45 KB, patch)
2011-01-15 02:11 PST, Helder Correia
no flags
Concat CTM with strokeGradient->gradientSpaceTransform() (16.74 KB, patch)
2011-01-23 20:46 PST, Helder Correia
no flags
Added svg/css/text-gradient-stroke-shadow.svg (400.64 KB, patch)
2011-02-02 15:25 PST, Helder Correia
no flags
New rect-gradient-stroke-shadow.svg. Add comment for line width. Fix build. (131.32 KB, patch)
2011-02-03 15:13 PST, Helder Correia
no flags
Ceil layer size and round blit destination. (131.35 KB, patch)
2011-02-03 18:20 PST, Helder Correia
no flags
Performance test (3.24 KB, text/html)
2011-02-24 12:28 PST, Helder Correia
no flags
Remove formatting hunks (128.81 KB, patch)
2011-02-24 12:38 PST, Helder Correia
no flags
Otherwise the layer size will not be suficient to contain all pixels because of smoothing when we're scaling. (128.76 KB, patch)
2011-02-25 18:19 PST, Helder Correia
simon.fraser: review+
Helder Correia
Comment 1 Saturday, January 15, 2011 10:11:02 AM UTC
Simon Fraser (smfr)
Comment 2 Tuesday, January 18, 2011 8:35:46 PM UTC
Comment on attachment 79059 [details] Patch Why does this code do anything with m_state.fillGradient->gradientSpaceTransform() ?
Helder Correia
Comment 3 Monday, January 24, 2011 4:46:41 AM UTC
Created attachment 79887 [details] Concat CTM with strokeGradient->gradientSpaceTransform()
Helder Correia
Comment 4 Wednesday, February 2, 2011 11:25:38 PM UTC
Created attachment 80979 [details] Added svg/css/text-gradient-stroke-shadow.svg
Build Bot
Comment 5 Wednesday, February 2, 2011 11:53:57 PM UTC
Simon Fraser (smfr)
Comment 6 Thursday, February 3, 2011 12:11:08 AM UTC
Comment on attachment 80979 [details] Added svg/css/text-gradient-stroke-shadow.svg View in context: https://bugs.webkit.org/attachment.cgi?id=80979&action=review > LayoutTests/svg/css/text-gradient-stroke-shadow.svg:8 > +<text x="100" y="300" style="font-size: 300px; text-shadow: #000 20px 20px 20px;" stroke-width="10" stroke="url(#gradient)">SVG</text> Maybe just use a rect in these tests to avoid font differences between platforms. Why does Mac render hollow characters, but the other platforms render solid black ones? > Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:972 > + const float halfLineWidth = lineWidth / 2; Can you add a comment explaining the lineWidth/2 offset? Why do it here, and not in the non-shadow path? > Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:1000 > > + New blank line here.
Helder Correia
Comment 7 Thursday, February 3, 2011 11:13:24 PM UTC
Created attachment 81121 [details] New rect-gradient-stroke-shadow.svg. Add comment for line width. Fix build.
Simon Fraser (smfr)
Comment 8 Friday, February 4, 2011 12:27:44 AM UTC
Comment on attachment 81121 [details] New rect-gradient-stroke-shadow.svg. Add comment for line width. Fix build. View in context: https://bugs.webkit.org/attachment.cgi?id=81121&action=review > Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:988 > + // Compensate for half of the line width, otherwise the layer's top-left corner would > + // be aligned with the rect's top-left corner, not considering the line width. This > + // would result in leaving half of the line out of the layer on the left and top sides. > + const float translationX = halfLineWidth - rect.x(); > + const float translationY = halfLineWidth - rect.y(); > + CGContextTranslateCTM(layerContext, translationX, translationY); > + > + CGContextAddRect(layerContext, rect); > + CGContextReplacePathWithStrokedPath(layerContext); > + CGContextClip(layerContext); > + CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform()); > + m_state.strokeGradient->paint(layerContext); > + > + const float destinationX = rect.x() - halfLineWidth; > + const float destinationY = rect.y() - halfLineWidth; > + CGContextDrawLayerAtPoint(context, CGPointMake(destinationX, destinationY), layer); I think you want to avoid drawing the layer at half-pixel offsets. Why not just round out the layer size to a whole pixel?
Helder Correia
Comment 9 Friday, February 4, 2011 2:20:10 AM UTC
Created attachment 81165 [details] Ceil layer size and round blit destination.
Tor Arne Vestbø
Comment 10 Saturday, February 19, 2011 3:37:11 AM UTC
Comment on attachment 81165 [details] Ceil layer size and round blit destination. View in context: https://bugs.webkit.org/attachment.cgi?id=81165&action=review > Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:193 > - > + Please leave out these formatting hunks
Helder Correia
Comment 11 Thursday, February 24, 2011 8:28:12 PM UTC
Created attachment 83698 [details] Performance test
Helder Correia
Comment 12 Thursday, February 24, 2011 8:38:20 PM UTC
Created attachment 83703 [details] Remove formatting hunks
Helder Correia
Comment 13 Saturday, February 26, 2011 2:19:19 AM UTC
Created attachment 83912 [details] Otherwise the layer size will not be suficient to contain all pixels because of smoothing when we're scaling.
Helder Correia
Comment 14 Tuesday, March 8, 2011 1:51:00 AM UTC
Stephen Chenney
Comment 15 Thursday, April 12, 2012 9:04:55 PM UTC
Note You need to log in before you can comment on or make changes to this bug.