RESOLVED FIXED 140812
Apply feTurbulence spec change to fix zero length vector generation
https://bugs.webkit.org/show_bug.cgi?id=140812
Summary Apply feTurbulence spec change to fix zero length vector generation
Nikos Andronikos
Reported 2015-01-22 19:31:21 PST
A bug in the Filter Effects feTurbulence algorithm has recently been fixed in the spec. Discussion: https://lists.w3.org/Archives/Public/www-svg/2015Jan/0003.html http://www.w3.org/2015/01/15-svg-minutes.html#item06 Updated spec: http://dev.w3.org/fxtf/filters/#elementdef-feturbulence Change is the addition of do while loop on these lines: do { for (j = 0; j < 2; j++) fGradient[k][i][j] = (double)(((lSeed = random(lSeed)) % (BSize + BSize)) - BSize) / BSize; } while(fGradient[k][i][0] == 0 && fGradient[k][i][1] == 0); Test: http://jsfiddle.net/dodgeyhack/mo7x85zw/ This change is already landed in Chrome Canary and FireFox nightly.
Attachments
Patch (2.45 KB, patch)
2015-01-22 21:02 PST, Nikos Andronikos
no flags
Patch (7.49 KB, patch)
2015-01-26 17:17 PST, Nikos Andronikos
no flags
Nikos Andronikos
Comment 1 2015-01-22 21:02:26 PST
Dirk Schulze
Comment 2 2015-01-26 03:22:48 PST
Comment on attachment 245202 [details] Patch Looks good to me. I am not happy to submit it without a test. IIRC there were some test cases on public-fx or www-svg. Could you add one of these please? r- because of missing test.
Nikos Andronikos
Comment 3 2015-01-26 17:17:33 PST
Nikos Andronikos
Comment 4 2015-01-26 17:54:40 PST
(In reply to comment #2) > Comment on attachment 245202 [details] > Patch > > Looks good to me. I am not happy to submit it without a test. IIRC there > were some test cases on public-fx or www-svg. Could you add one of these > please? r- because of missing test. Ok, done. I was a bit worried about adding a pixel test but managed to come up with a way to use a reftest for this.
Darin Adler
Comment 5 2015-01-26 21:46:43 PST
Comment on attachment 245393 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=245393&action=review > Source/WebCore/platform/graphics/filters/FETurbulence.cpp:186 > + do { > + gradient[0] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; > + gradient[1] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; > + } while (!gradient[0] && !gradient[1]); Is a loop really the best way to avoid zeroes here?
Darin Adler
Comment 6 2015-01-26 21:47:27 PST
Comment on attachment 245393 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=245393&action=review >> Source/WebCore/platform/graphics/filters/FETurbulence.cpp:186 >> + } while (!gradient[0] && !gradient[1]); > > Is a loop really the best way to avoid zeroes here? I guess that’s what the specification calls for.
Nikos Andronikos
Comment 7 2015-01-26 21:58:28 PST
(In reply to comment #6) > Comment on attachment 245393 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=245393&action=review > > >> Source/WebCore/platform/graphics/filters/FETurbulence.cpp:186 > >> + } while (!gradient[0] && !gradient[1]); > > > > Is a loop really the best way to avoid zeroes here? > > I guess that’s what the specification calls for. It does =) The idea is that the random distribution is maintained. Falling back to some known value would skew the result (but only very slightly in this case). Discussion was here: https://lists.w3.org/Archives/Public/www-svg/2015Jan/0005.html Thanks for the review.
WebKit Commit Bot
Comment 8 2015-01-26 22:32:05 PST
Comment on attachment 245393 [details] Patch Clearing flags on attachment: 245393 Committed r179171: <http://trac.webkit.org/changeset/179171>
WebKit Commit Bot
Comment 9 2015-01-26 22:32:09 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.