Changeset 75139 in webkit
- Timestamp:
- Jan 5, 2011 10:11:02 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r75137 r75139 1 2011-01-05 Helder Correia <helder@sencha.com> 2 3 Reviewed by Simon Fraser. 4 5 Shadows are not drawn when filling a rect with a gradient fillStyle on Mac and Chromium-Mac 6 https://bugs.webkit.org/show_bug.cgi?id=51869 7 8 GraphicsContext::fillRect(const FloatRect&) is clipping to the rect. 9 The shadow is being drawn, but getting clipped to the rect being filled. 10 The solution is to draw the gradient into a CGLayer (when a shadow is 11 required), then render the layer to the GraphicsContext. 12 13 This patch also fixes: 14 canvas/philip/tests/2d.shadow.gradient.alpha.html 15 canvas/philip/tests/2d.shadow.gradient.basic.html 16 canvas/philip/tests/2d.shadow.gradient.transparent.2.html 17 18 New test to ensure that shadows are drawn when fillStyle is a gradient, 19 possibly with some transparency and blur, and specifically using 20 fillRect. 21 22 * fast/canvas/canvas-fillRect-gradient-shadow-expected.txt: Added. 23 * fast/canvas/canvas-fillRect-gradient-shadow.html: Added. 24 * fast/canvas/script-tests/canvas-fillRect-gradient-shadow.js: Added. 25 1 26 2011-01-05 Simon Fraser <simon.fraser@apple.com> 2 27 -
trunk/WebCore/ChangeLog
r75138 r75139 1 2011-01-05 Helder Correia <helder@sencha.com> 2 3 Reviewed by Simon Fraser. 4 5 Shadows are not drawn when filling a rect with a gradient fillStyle on Mac and Chromium-Mac 6 https://bugs.webkit.org/show_bug.cgi?id=51869 7 8 GraphicsContext::fillRect(const FloatRect&) is clipping to the rect. 9 The shadow is being drawn, but getting clipped to the rect being filled. 10 The solution is to draw the gradient into a CGLayer (when a shadow is 11 required), then render the layer to the GraphicsContext. 12 13 This patch also fixes: 14 canvas/philip/tests/2d.shadow.gradient.alpha.html 15 canvas/philip/tests/2d.shadow.gradient.basic.html 16 canvas/philip/tests/2d.shadow.gradient.transparent.2.html 17 18 Test: fast/canvas/canvas-fillRect-gradient-shadow.html 19 20 * platform/graphics/Gradient.h: 21 * platform/graphics/cg/GradientCG.cpp: 22 (WebCore::Gradient::paint): 23 * platform/graphics/cg/GraphicsContextCG.cpp: 24 (WebCore::GraphicsContext::fillRect): 25 1 26 2011-01-05 Steve Falkenburg <sfalken@apple.com> 2 27 -
trunk/WebCore/platform/graphics/Gradient.h
r74915 r75139 35 35 #include <wtf/PassRefPtr.h> 36 36 #include <wtf/Vector.h> 37 38 #if PLATFORM(WIN) 39 #include <CoreGraphics/CoreGraphics.h> 40 #endif 37 41 38 42 #if PLATFORM(CG) … … 137 141 138 142 #if PLATFORM(CG) 143 void paint(CGContextRef); 139 144 void paint(GraphicsContext*); 140 145 #endif -
trunk/WebCore/platform/graphics/GraphicsContext.cpp
r74662 r75139 149 149 } 150 150 151 bool GraphicsContext::hasShadow() const 152 { 153 return m_state.shadowColor.isValid() && m_state.shadowColor.alpha() 154 && (m_state.shadowBlur || m_state.shadowOffset.width() || m_state.shadowOffset.height()); 155 } 156 151 157 bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color, ColorSpace& colorSpace) const 152 158 { … … 156 162 colorSpace = m_state.shadowColorSpace; 157 163 158 return color.isValid() && color.alpha() && (blur || offset.width() || offset.height());164 return hasShadow(); 159 165 } 160 166 -
trunk/WebCore/platform/graphics/GraphicsContext.h
r74662 r75139 347 347 void endTransparencyLayer(); 348 348 349 bool hasShadow() const; 349 350 void setShadow(const FloatSize&, float blur, const Color&, ColorSpace); 350 351 bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const; -
trunk/WebCore/platform/graphics/cg/GradientCG.cpp
r75097 r75139 113 113 { 114 114 CGContextRef ctx = context->platformContext(); 115 paint(ctx); 116 } 117 118 void Gradient::paint(CGContextRef context) 119 { 115 120 #if USE_CG_SHADING 116 CGContextDrawShading(c tx, platformGradient());121 CGContextDrawShading(context, platformGradient()); 117 122 #else 118 123 CGGradientDrawingOptions extendOptions = kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation; … … 120 125 bool needScaling = aspectRatio() != 1; 121 126 if (needScaling) { 122 CGContextSaveGState(c tx);127 CGContextSaveGState(context); 123 128 // Scale from the center of the gradient. We only ever scale non-deprecated gradients, 124 129 // for which m_p0 == m_p1. 125 130 ASSERT(m_p0 == m_p1); 126 CGContextTranslateCTM(c tx, m_p0.x(), m_p0.y());127 CGContextScaleCTM(c tx, 1, 1 / aspectRatio());128 CGContextTranslateCTM(c tx, -m_p0.x(), -m_p0.y());131 CGContextTranslateCTM(context, m_p0.x(), m_p0.y()); 132 CGContextScaleCTM(context, 1, 1 / aspectRatio()); 133 CGContextTranslateCTM(context, -m_p0.x(), -m_p0.y()); 129 134 } 130 135 131 CGContextDrawRadialGradient(c tx, platformGradient(), m_p0, m_r0, m_p1, m_r1, extendOptions);132 136 CGContextDrawRadialGradient(context, platformGradient(), m_p0, m_r0, m_p1, m_r1, extendOptions); 137 133 138 if (needScaling) 134 CGContextRestoreGState(c tx);139 CGContextRestoreGState(context); 135 140 } else 136 CGContextDrawLinearGradient(c tx, platformGradient(), m_p0, m_p1, extendOptions);141 CGContextDrawLinearGradient(context, platformGradient(), m_p0, m_p1, extendOptions); 137 142 #endif 138 143 } -
trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r74151 r75139 602 602 if (m_state.fillGradient) { 603 603 CGContextSaveGState(context); 604 CGContextClipToRect(context, rect);605 604 CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); 606 m_state.fillGradient->paint(this); 605 if (hasShadow()) { 606 CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0); 607 CGContextRef layerContext = CGLayerGetContext(layer); 608 m_state.fillGradient->paint(layerContext); 609 CGContextDrawLayerAtPoint(context, CGPointMake(rect.left(), rect.top()), layer); 610 CGLayerRelease(layer); 611 } else { 612 CGContextClipToRect(context, rect); 613 m_state.fillGradient->paint(this); 614 } 607 615 CGContextRestoreGState(context); 608 616 return;
Note: See TracChangeset
for help on using the changeset viewer.