Changeset 65138 in webkit
- Timestamp:
- Aug 11, 2010 1:43:13 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r65135 r65138 1 2010-08-11 Alejandro G. Castro <alex@igalia.com> 2 3 Reviewed by Dirk Schulze. 4 5 Fixes to the gaussian blur algorithm 6 https://bugs.webkit.org/show_bug.cgi?id=41605 7 8 Unskipped test and generated results. 9 10 * platform/gtk/Skipped: 11 * platform/gtk/svg/filters/feGaussianBlur-expected.txt: Added. 12 13 Updated pixel tests. 14 15 * platform/mac-leopard/svg/W3C-SVG-1.1/filters-gauss-01-b-expected.checksum: 16 * platform/mac-leopard/svg/W3C-SVG-1.1/filters-gauss-01-b-expected.png: 17 * platform/mac-leopard/svg/batik/text/textProperties-expected.checksum: 18 * platform/mac-leopard/svg/batik/text/textProperties-expected.png: 19 * platform/mac-leopard/svg/custom/mask-colorspace-expected.png: 20 * platform/mac-leopard/svg/filters/feGaussianBlur-expected.checksum: 21 * platform/mac-leopard/svg/filters/feGaussianBlur-expected.png: 22 * platform/mac-leopard/svg/filters/shadow-on-filter-expected.checksum: 23 * platform/mac-leopard/svg/filters/shadow-on-filter-expected.png: 24 * platform/mac-leopard/svg/filters/shadow-on-rect-with-filter-expected.checksum: 25 * platform/mac-leopard/svg/filters/shadow-on-rect-with-filter-expected.png: 26 * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.checksum: 27 * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.png: 28 * platform/mac/svg/batik/text/textEffect-expected.checksum: 29 * platform/mac/svg/batik/text/textEffect-expected.png: 30 * platform/mac/svg/batik/text/textEffect3-expected.checksum: 31 * platform/mac/svg/batik/text/textEffect3-expected.png: 32 * platform/mac/svg/batik/text/textFeatures-expected.checksum: 33 * platform/mac/svg/batik/text/textFeatures-expected.png: 34 * platform/mac/svg/custom/non-opaque-filters-expected.checksum: 35 * platform/mac/svg/custom/non-opaque-filters-expected.png: 36 * platform/mac/svg/custom/recursive-filter-expected.checksum: 37 * platform/mac/svg/custom/recursive-filter-expected.png: 38 * platform/mac/svg/custom/resource-invalidate-on-target-update-expected.checksum: 39 * platform/mac/svg/custom/resource-invalidate-on-target-update-expected.png: 40 * platform/mac/svg/custom/text-filter-expected.checksum: 41 * platform/mac/svg/custom/text-filter-expected.png: 42 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-diffuseConstant-attr-expected.checksum: 43 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-diffuseConstant-attr-expected.png: 44 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-in-attr-expected.checksum: 45 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-in-attr-expected.png: 46 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-lighting-color-attr-expected.checksum: 47 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-lighting-color-attr-expected.png: 48 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-surfaceScale-attr-expected.checksum: 49 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-surfaceScale-attr-expected.png: 50 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-lighting-color-css-prop-expected.checksum: 51 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-lighting-color-css-prop-expected.png: 52 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-diffuseConstant-prop-expected.checksum: 53 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-diffuseConstant-prop-expected.png: 54 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-in-prop-expected.checksum: 55 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-in-prop-expected.png: 56 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-surfaceScale-prop-expected.checksum: 57 * platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-surfaceScale-prop-expected.png: 58 * platform/mac/svg/filters/filter-on-filter-for-text-expected.checksum: 59 * platform/mac/svg/filters/filter-on-filter-for-text-expected.png: 60 1 61 2010-08-11 Fumitoshi Ukai <ukai@chromium.org> 2 62 -
trunk/LayoutTests/platform/gtk/Skipped
r65113 r65138 5146 5146 svg/custom/outer-svg-unknown-feature.svg 5147 5147 svg/filters/feComposite.svg 5148 svg/filters/feGaussianBlur.svg5149 5148 svg/filters/feMerge.svg 5150 5149 svg/filters/feMerge-wrong-input.svg -
trunk/LayoutTests/platform/mac-leopard/svg/W3C-SVG-1.1/filters-gauss-01-b-expected.checksum
r59987 r65138 1 34f79ef1fbb73a01e8aec8bb2e8455eb 1 dc3c93fea9c9f7c07f2e4bcd1aefe2b0 -
trunk/LayoutTests/platform/mac-leopard/svg/batik/text/textProperties-expected.checksum
r61393 r65138 1 7ac90845492b90c794aca5a6d005acd8 1 a3d8bc0cc8481bd140592dcb3fcaf420 -
trunk/LayoutTests/platform/mac-leopard/svg/filters/feGaussianBlur-expected.checksum
r59987 r65138 1 f3318b6d1298eda9ee6363189136f00b 1 7cb949d5ea30e101ea1d193398d7dfbf -
trunk/LayoutTests/platform/mac-leopard/svg/filters/shadow-on-filter-expected.checksum
r59987 r65138 1 0dd0bccfd1290c9d1361ee69593a4d6e 1 8e475e1e09357e8d50c695e6ca734b93 -
trunk/LayoutTests/platform/mac-leopard/svg/filters/shadow-on-rect-with-filter-expected.checksum
r53576 r65138 1 c2f1aa1ba34ce5d2a4217daa9002179e 1 19b5d78801f2d08d4249c8d238aded55 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.checksum
r52647 r65138 1 c0ccdff2628158da021f32ba7af1e47c1 f7717b50eeca605243da2930e64940ac -
trunk/LayoutTests/platform/mac/svg/batik/text/textEffect-expected.checksum
r61393 r65138 1 7651f6c33dceb07248402e7fb11c57f1 1 0e76f04b2984b3e4bfaa1779eedf7af6 -
trunk/LayoutTests/platform/mac/svg/batik/text/textEffect3-expected.checksum
r63721 r65138 1 d7f76e45d195413b296ca2deb3910c77 1 11ee970a315adb062f1c0c3960253ff5 -
trunk/LayoutTests/platform/mac/svg/batik/text/textFeatures-expected.checksum
r61393 r65138 1 c769d5472cf882e729c24a6bfde679df 1 6b2078e5c0d3486665431e4b40cb7b4c -
trunk/LayoutTests/platform/mac/svg/custom/non-opaque-filters-expected.checksum
r51800 r65138 1 41be27d1eb69c595bf1008c91e33986e 1 233fea7c5e41ee0ca468848c6eb3da7d -
trunk/LayoutTests/platform/mac/svg/custom/recursive-filter-expected.checksum
r64275 r65138 1 0e4859e3b02f2f48bba2c68cad4e0e7b 1 bf1540c2d63cfbe404253f1cead165f7 -
trunk/LayoutTests/platform/mac/svg/custom/resource-invalidate-on-target-update-expected.checksum
r52709 r65138 1 def3237c2a760761dec917e57f640cf2 1 81be80c359177d1c77f3118e94802bee -
trunk/LayoutTests/platform/mac/svg/custom/text-filter-expected.checksum
r51800 r65138 1 30be532effae934d62209ee6e73a4476 1 54c828205d2241acc305c3b40534794b -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-diffuseConstant-attr-expected.checksum
r64191 r65138 1 1 7f613f518fa96eaf04b5665376f21c61 133d41ed5215bc4e93601ec45682bec0 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-in-attr-expected.checksum
r64191 r65138 1 cb0a1ce11b98bb8f20caee21cc827537 1 fd5cc3a0a27955bf90c5558140012a9a -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-lighting-color-attr-expected.checksum
r64191 r65138 1 0a7d21c1b0e8f4cfaf45b63f545a9f66 1 9959235d96473029f2d29d73b9cc7112 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-dom-surfaceScale-attr-expected.checksum
r64191 r65138 1 867d80dd6ba1e356566c66bad2bdc739 1 d7f015d11a52c6b3a881be30f65ddd20 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-lighting-color-css-prop-expected.checksum
r64191 r65138 1 3ebe46f74da6ce45855377513b293ba7 1 d53a2e4153d3748984be458e53e813f2 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-diffuseConstant-prop-expected.checksum
r64191 r65138 1 a25087cfe3b4741de25f13c273bbd06e 1 256adccb5136d5345d480eb3ee067579 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-in-prop-expected.checksum
r64191 r65138 1 2061b100f62c1e13f737bfacf3b9a6d6 1 c43a3e81d71c9fb60a1ae1c7525a5f71 -
trunk/LayoutTests/platform/mac/svg/dynamic-updates/SVGFEDiffuseLightingElement-svgdom-surfaceScale-prop-expected.checksum
r64191 r65138 1 4ba162b04759b146548003b5c1a17477 1 8a344e71484fcdd6b1cbd3bc4da22aa6 -
trunk/LayoutTests/platform/mac/svg/filters/filter-on-filter-for-text-expected.checksum
r60689 r65138 1 43ef38740a8ab2373ed5ee0df84f2699 1 b850bc401490e135c73688e0c90e760d -
trunk/WebCore/ChangeLog
r65137 r65138 1 2010-08-11 Alejandro G. Castro <alex@igalia.com> 2 3 Reviewed by Dirk Schulze. 4 5 Fixes to the gaussian blur algorithm 6 https://bugs.webkit.org/show_bug.cgi?id=41605 7 8 Added the recomendations of SVG regarding the kernel size 9 calculation for the approximation of the gaussian 10 blur. http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement. 11 Modified also some variable names to clarify algorithm, reviewed 12 the situation where both standard deviations are 0. 13 14 * platform/graphics/filters/FEGaussianBlur.cpp: 15 (WebCore::FEGaussianBlur::FEGaussianBlur): 16 (WebCore::FEGaussianBlur::stdDeviationX): 17 (WebCore::FEGaussianBlur::setStdDeviationX): 18 (WebCore::FEGaussianBlur::stdDeviationY): 19 (WebCore::FEGaussianBlur::setStdDeviationY): 20 (WebCore::boxBlur): 21 (WebCore::FEGaussianBlur::kernelPosition): Added the SVG kernel 22 position recomendation. 23 (WebCore::FEGaussianBlur::apply): 24 (WebCore::FEGaussianBlur::externalRepresentation): 25 * platform/graphics/filters/FEGaussianBlur.h: 26 1 27 2010-08-11 Kristian Monsen <kristianm@google.com> 2 28 -
trunk/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
r59069 r65138 4 4 2005 Eric Seidel <eric@webkit.org> 5 5 2009 Dirk Schulze <krit@webkit.org> 6 2010 Igalia, S.L. 6 7 7 8 This library is free software; you can redistribute it and/or … … 30 31 #include "GraphicsContext.h" 31 32 #include "ImageData.h" 32 #include <math.h>33 33 #include <wtf/MathExtras.h> 34 34 35 35 using std::max; 36 37 static const float gGaussianKernelFactor = (3 * sqrtf(2 * piFloat) / 4.f); 36 38 37 39 namespace WebCore { … … 40 42 : FilterEffect() 41 43 , m_in(in) 42 , m_ x(x)43 , m_ y(y)44 , m_stdX(x) 45 , m_stdY(y) 44 46 { 45 47 } … … 52 54 float FEGaussianBlur::stdDeviationX() const 53 55 { 54 return m_ x;56 return m_stdX; 55 57 } 56 58 57 59 void FEGaussianBlur::setStdDeviationX(float x) 58 60 { 59 m_ x= x;61 m_stdX = x; 60 62 } 61 63 62 64 float FEGaussianBlur::stdDeviationY() const 63 65 { 64 return m_ y;66 return m_stdY; 65 67 } 66 68 67 69 void FEGaussianBlur::setStdDeviationY(float y) 68 70 { 69 m_ y= y;71 m_stdY = y; 70 72 } 71 73 72 74 static void boxBlur(CanvasPixelArray*& srcPixelArray, CanvasPixelArray*& dstPixelArray, 73 unsigned dx, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage) 74 { 75 int dxLeft = dx / 2; 76 int dxRight = dx - dxLeft; 77 75 unsigned dx, int dxLeft, int dxRight, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage) 76 { 78 77 for (int y = 0; y < effectHeight; ++y) { 79 78 int line = y * strideLine; … … 100 99 } 101 100 101 void FEGaussianBlur::kernelPosition(int boxBlur, unsigned& std, int& dLeft, int& dRight) 102 { 103 // check http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement for details 104 switch (boxBlur) { 105 case 0: 106 if (!(std % 2)) { 107 dLeft = std / 2 - 1; 108 dRight = std - dLeft; 109 } else { 110 dLeft = std / 2; 111 dRight = std - dLeft; 112 } 113 break; 114 case 1: 115 if (!(std % 2)) { 116 dLeft++; 117 dRight--; 118 } 119 break; 120 case 2: 121 if (!(std % 2)) { 122 dRight++; 123 std++; 124 } 125 break; 126 } 127 } 128 102 129 void FEGaussianBlur::apply(Filter* filter) 103 130 { … … 111 138 setIsAlphaImage(m_in->isAlphaImage()); 112 139 113 if (m_x == 0 || m_y == 0)114 return;115 116 unsigned sdx = static_cast<unsigned>(floor(m_x * filter->filterResolution().width() * 3 * sqrt(2 * piDouble) / 4.f + 0.5f));117 unsigned sdy = static_cast<unsigned>(floor(m_y * filter->filterResolution().height() * 3 * sqrt(2 * piDouble) / 4.f + 0.5f));118 sdx = max(sdx, static_cast<unsigned>(1));119 sdy = max(sdy, static_cast<unsigned>(1));120 121 140 IntRect effectDrawingRect = calculateDrawingIntRect(m_in->scaledSubRegion()); 122 141 RefPtr<ImageData> srcImageData(m_in->resultImage()->getPremultipliedImageData(effectDrawingRect)); 142 IntRect imageRect(IntPoint(), resultImage()->size()); 143 144 if (!m_stdX && !m_stdY) { 145 resultImage()->putPremultipliedImageData(srcImageData.get(), imageRect, IntPoint()); 146 return; 147 } 148 149 unsigned kernelSizeX = 0; 150 if (m_stdX) 151 kernelSizeX = max(2U, static_cast<unsigned>(floor(m_stdX * filter->filterResolution().width() * gGaussianKernelFactor + 0.5f))); 152 153 unsigned kernelSizeY = 0; 154 if (m_stdY) 155 kernelSizeY = max(2U, static_cast<unsigned>(floor(m_stdY * filter->filterResolution().height() * gGaussianKernelFactor + 0.5f))); 156 123 157 CanvasPixelArray* srcPixelArray(srcImageData->data()); 124 125 IntRect imageRect(IntPoint(), resultImage()->size());126 158 RefPtr<ImageData> tmpImageData = ImageData::create(imageRect.width(), imageRect.height()); 127 159 CanvasPixelArray* tmpPixelArray(tmpImageData->data()); 128 160 129 161 int stride = 4 * imageRect.width(); 162 int dxLeft, dxRight, dyLeft, dyRight; 130 163 for (int i = 0; i < 3; ++i) { 131 boxBlur(srcPixelArray, tmpPixelArray, sdx, 4, stride, imageRect.width(), imageRect.height(), isAlphaImage()); 132 boxBlur(tmpPixelArray, srcPixelArray, sdy, stride, 4, imageRect.height(), imageRect.width(), isAlphaImage()); 164 if (kernelSizeX) { 165 kernelPosition(i, kernelSizeX, dxLeft, dxRight); 166 boxBlur(srcPixelArray, tmpPixelArray, kernelSizeX, dxLeft, dxRight, 4, stride, imageRect.width(), imageRect.height(), isAlphaImage()); 167 } else { 168 CanvasPixelArray* auxPixelArray = tmpPixelArray; 169 tmpPixelArray = srcPixelArray; 170 srcPixelArray = auxPixelArray; 171 } 172 173 if (kernelSizeY) { 174 kernelPosition(i, kernelSizeY, dyLeft, dyRight); 175 boxBlur(tmpPixelArray, srcPixelArray, kernelSizeY, dyLeft, dyRight, stride, 4, imageRect.height(), imageRect.width(), isAlphaImage()); 176 } else { 177 CanvasPixelArray* auxPixelArray = tmpPixelArray; 178 tmpPixelArray = srcPixelArray; 179 srcPixelArray = auxPixelArray; 180 } 133 181 } 134 182 … … 145 193 ts << "[feGaussianBlur"; 146 194 FilterEffect::externalRepresentation(ts); 147 ts << " stdDeviation=\"" << m_ x << ", " << m_y<< "\"]\n";195 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\"]\n"; 148 196 m_in->externalRepresentation(ts, indent + 1); 149 197 return ts; -
trunk/WebCore/platform/graphics/filters/FEGaussianBlur.h
r59069 r65138 46 46 private: 47 47 FEGaussianBlur(FilterEffect*, const float&, const float&); 48 static void kernelPosition(int boxBlur, unsigned& std, int& dLeft, int& dRight); 48 49 49 50 RefPtr<FilterEffect> m_in; 50 float m_ x;51 float m_ y;51 float m_stdX; 52 float m_stdY; 52 53 }; 53 54
Note: See TracChangeset
for help on using the changeset viewer.