RESOLVED FIXED Bug 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 2011-01-15 01:41:40 PST
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 2011-01-15 02:11:02 PST
Simon Fraser (smfr)
Comment 2 2011-01-18 12:35:46 PST
Comment on attachment 79059 [details] Patch Why does this code do anything with m_state.fillGradient->gradientSpaceTransform() ?
Helder Correia
Comment 3 2011-01-23 20:46:41 PST
Created attachment 79887 [details] Concat CTM with strokeGradient->gradientSpaceTransform()
Helder Correia
Comment 4 2011-02-02 15:25:38 PST
Created attachment 80979 [details] Added svg/css/text-gradient-stroke-shadow.svg
Build Bot
Comment 5 2011-02-02 15:53:57 PST
Simon Fraser (smfr)
Comment 6 2011-02-02 16:11:08 PST
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 2011-02-03 15:13:24 PST
Created attachment 81121 [details] New rect-gradient-stroke-shadow.svg. Add comment for line width. Fix build.
Simon Fraser (smfr)
Comment 8 2011-02-03 16:27:44 PST
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 2011-02-03 18:20:10 PST
Created attachment 81165 [details] Ceil layer size and round blit destination.
Tor Arne Vestbø
Comment 10 2011-02-18 19:37:11 PST
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 2011-02-24 12:28:12 PST
Created attachment 83698 [details] Performance test
Helder Correia
Comment 12 2011-02-24 12:38:20 PST
Created attachment 83703 [details] Remove formatting hunks
Helder Correia
Comment 13 2011-02-25 18:19:19 PST
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 2011-03-07 17:51:00 PST
Stephen Chenney
Comment 15 2012-04-12 13:04:55 PDT
Note You need to log in before you can comment on or make changes to this bug.