Changeset 74328 in webkit
- Timestamp:
- Dec 19, 2010 5:02:20 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r74326 r74328 1 2010-12-19 Helder Correia <helder@sencha.com> 2 3 Reviewed by Ariya Hidayat. 4 5 [Qt] Blur distance should not be affected by transformations 6 https://bugs.webkit.org/show_bug.cgi?id=51161 7 8 From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur: 9 "The shadowBlur attribute specifies the level of the blurring effect. 10 (The units do not map to coordinate space units, and are not affected 11 by the current transformation matrix.)" 12 13 Add test to ensure that the blur radius is not affected by the CTM. 14 15 * fast/canvas/canvas-scale-shadowBlur-expected.txt: Added. 16 * fast/canvas/canvas-scale-shadowBlur.html: Added. 17 * fast/canvas/canvas-scale-strokePath-shadow-expected.txt: Increase 18 shadowBlur and test tolerance to ease testing and support the 19 different blurring algorithms. 20 * fast/canvas/script-tests/canvas-scale-shadowBlur.js: Added. 21 * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js: 22 1 23 2010-12-19 Dan Bernstein <mitz@apple.com> 2 24 -
trunk/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
r74317 r74328 31 31 PASS d[1] is 0 32 32 PASS d[2] is 0 33 PASS d[3] is around 14933 PASS d[3] is around 200 34 34 PASS d[0] is 255 35 35 PASS d[1] is 0 36 36 PASS d[2] is 0 37 PASS d[3] is around 11637 PASS d[3] is around 49 38 38 PASS d[0] is 255 39 39 PASS d[1] is 0 40 40 PASS d[2] is 0 41 PASS d[3] is around 1 1541 PASS d[3] is around 199 42 42 PASS d[0] is 255 43 43 PASS d[1] is 0 -
trunk/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
r74317 r74328 28 28 var canvas = document.createElement('canvas'); 29 29 document.body.appendChild(canvas); 30 canvas.setAttribute('width', ' 1000');31 canvas.setAttribute('height', ' 1000');30 canvas.setAttribute('width', '600'); 31 canvas.setAttribute('height', '600'); 32 32 var ctx = canvas.getContext('2d'); 33 33 … … 116 116 117 117 // Verify blurry shadow. 118 d = ctx.getImageData( 404, 210, 1, 1).data;118 d = ctx.getImageData(398, 210, 1, 1).data; 119 119 shouldBe('d[0]', '255'); 120 120 shouldBe('d[1]', '0'); 121 121 shouldBe('d[2]', '0'); 122 shouldBeAround('d[3]', ' 149');122 shouldBeAround('d[3]', '200'); 123 123 124 d = ctx.getImageData(50 5, 250, 1, 1).data;124 d = ctx.getImageData(508, 250, 1, 1).data; 125 125 shouldBe('d[0]', '255'); 126 126 shouldBe('d[1]', '0'); 127 127 shouldBe('d[2]', '0'); 128 shouldBeAround('d[3]', ' 116');128 shouldBeAround('d[3]', '49'); 129 129 130 d = ctx.getImageData(450, 205, 1, 1).data;130 d = ctx.getImageData(450, 198, 1, 1).data; 131 131 shouldBe('d[0]', '255'); 132 132 shouldBe('d[1]', '0'); 133 133 shouldBe('d[2]', '0'); 134 shouldBeAround('d[3]', '1 15');134 shouldBeAround('d[3]', '199'); 135 135 136 136 // Verify blurry alpha shadow. -
trunk/WebCore/ChangeLog
r74326 r74328 1 2010-12-19 Helder Correia <helder@sencha.com> 2 3 Reviewed by Ariya Hidayat. 4 5 [Qt] Blur distance should not be affected by transformations 6 https://bugs.webkit.org/show_bug.cgi?id=51161 7 8 From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur: 9 "The shadowBlur attribute specifies the level of the blurring effect. 10 (The units do not map to coordinate space units, and are not affected 11 by the current transformation matrix.)" 12 13 Test: fast/canvas/canvas-scale-shadowBlur.html 14 15 * platform/graphics/ContextShadow.cpp: 16 (WebCore::ContextShadow::adjustBlurDistance): 17 * platform/graphics/ContextShadow.h: 18 * platform/graphics/cairo/ContextShadowCairo.cpp: 19 (WebCore::ContextShadow::beginShadowLayer): 20 * platform/graphics/qt/ContextShadowQt.cpp: 21 (WebCore::ContextShadow::beginShadowLayer): 22 1 23 2010-12-19 Dan Bernstein <mitz@apple.com> 2 24 -
trunk/WebCore/platform/graphics/ContextShadow.cpp
r74317 r74328 31 31 32 32 #include "FloatQuad.h" 33 #include <cmath> 33 34 #include <wtf/MathExtras.h> 34 35 #include <wtf/Noncopyable.h> … … 170 171 } 171 172 173 void ContextShadow::adjustBlurDistance(const PlatformContext context) 174 { 175 // Adjust blur if we're scaling, since the radius must not be affected by transformations. 176 const TransformationMatrix transform(getTransformationMatrixFromContext(context)); 177 178 if (transform.isIdentity()) 179 return; 180 181 // Calculale transformed unit vectors. 182 const FloatQuad unitQuad(FloatPoint(0, 0), FloatPoint(1, 0), 183 FloatPoint(0, 1), FloatPoint(1, 1)); 184 const FloatQuad transformedUnitQuad = transform.mapQuad(unitQuad); 185 186 // Calculate X axis scale factor. 187 const FloatSize xUnitChange = transformedUnitQuad.p2() - transformedUnitQuad.p1(); 188 const float xAxisScale = sqrtf(xUnitChange.width() * xUnitChange.width() 189 + xUnitChange.height() * xUnitChange.height()); 190 191 // Calculate Y axis scale factor. 192 const FloatSize yUnitChange = transformedUnitQuad.p3() - transformedUnitQuad.p1(); 193 const float yAxisScale = sqrtf(yUnitChange.width() * yUnitChange.width() 194 + yUnitChange.height() * yUnitChange.height()); 195 196 // blurLayerImage() does not support per-axis blurring, so calculate a balanced scaling. 197 const float scale = sqrtf(xAxisScale * yAxisScale); 198 m_blurDistance = roundf(static_cast<float>(m_blurDistance) / scale); 199 } 200 172 201 IntRect ContextShadow::calculateLayerBoundingRect(const PlatformContext context, const FloatRect& layerArea, const IntRect& clipRect) 173 202 { -
trunk/WebCore/platform/graphics/ContextShadow.h
r74317 r74328 127 127 bool m_shadowsIgnoreTransforms; 128 128 129 void adjustBlurDistance(const PlatformContext); 129 130 void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); 130 131 IntRect calculateLayerBoundingRect(const PlatformContext, const FloatRect& layerArea, const IntRect& clipRect); -
trunk/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
r74317 r74328 93 93 PlatformContext ContextShadow::beginShadowLayer(PlatformContext context, const FloatRect& layerArea) 94 94 { 95 adjustBlurDistance(context); 96 95 97 double x1, x2, y1, y2; 96 98 cairo_clip_extents(context, &x1, &y1, &x2, &y2); -
trunk/WebCore/platform/graphics/qt/ContextShadowQt.cpp
r74317 r74328 112 112 PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRect& layerArea) 113 113 { 114 // Set m_blurDistance. 115 adjustBlurDistance(p); 116 114 117 QRect clipRect; 115 118 if (p->hasClipping())
Note: See TracChangeset
for help on using the changeset viewer.