RESOLVED FIXED 86666
Simplify TransformationMatrix rotation code to improve precision
https://bugs.webkit.org/show_bug.cgi?id=86666
Summary Simplify TransformationMatrix rotation code to improve precision
Shawn Singh
Reported 2012-05-16 13:09:46 PDT
TransformationMatrix rotate3d() (both overloaded versions) seem to use unnecessary indirect computations to initialize the rotation matrices. Specifically, instead of using cos(theta) and sin(theta) directly, this code computes cos(theta/2), sin(theta/2) and sin^2 (theta/2), and then uses trig identities to compute the same traditional rotation matrices. I did some quick and dirty fprintf experiment, which suggested that using traditional sin/cos we can gain 1-2 bits of precision in some cases, particularly for the sin^2 term, where the squaring compounds the error. Perhaps this code should be simplified to use just sin/cos to create the canonical rotation matrices. Two possible caveats of simplifying this code: - perhaps there was a good reason to compute theta/2 and then use those trig identities? I cannot think of why. - There is a chance this will require rebaselining a vast number of pixel tests, and I would need some suggestions how to minimize the risk and pain of breaking all pixel tests for a short while. Dean and Chris, do either of you feel that this code should stay the way it is now? Doing this is not high priority, but if you want it done, I think its a reasonable safe change to make except for the rebaselining. Thanks in advance.
Attachments
Patch (13.56 KB, patch)
2012-05-29 21:08 PDT, Shawn Singh
no flags
Shawn Singh
Comment 1 2012-05-29 21:08:52 PDT
Created attachment 144691 [details] Patch Tested with webkit_unit_tests and layout tests on mac; no obvious regressions. But I would prefer to run layout tests a few more times with/without this patch to double check that some of the flakiness was not the fault of this patch.
Shawn Singh
Comment 2 2012-05-29 21:09:25 PDT
+enne for the webkit_unit_tests parts of this patch.
Shawn Singh
Comment 3 2012-05-29 21:10:41 PDT
> - There is a chance this will require rebaselining a vast number of pixel tests, and I would need some suggestions how to minimize the risk and pain of breaking all pixel tests for a short while. last comment for now... I was completely wrong about this, nothing should need rebaselining. =)
Darin Adler
Comment 4 2012-05-30 12:20:09 PDT
Comment on attachment 144691 [details] Patch Why a Chromium-specific test for a cross-platform bug fix?
Adrienne Walker
Comment 5 2012-05-30 12:45:32 PDT
(In reply to comment #4) > (From update of attachment 144691 [details]) > Why a Chromium-specific test for a cross-platform bug fix? Looking at Shawn's test, it would be extremely awkward to try to expose that code into a cross-platform layout test. In my opinion, unit tests seem like the best way to test a change like this. If other ports had C++ unit tests, it certainly could be cross-platform.
Shawn Singh
Comment 6 2012-05-30 12:53:57 PDT
(In reply to comment #5) > (In reply to comment #4) > > (From update of attachment 144691 [details] [details]) > > Why a Chromium-specific test for a cross-platform bug fix? > > Looking at Shawn's test, it would be extremely awkward to try to expose that code into a cross-platform layout test. In my opinion, unit tests seem like the best way to test a change like this. > > If other ports had C++ unit tests, it certainly could be cross-platform. It's also worth pointing out that this change is already covered by existing layout tests, specifically transforms/cssmatrix-3d-interface.xhtml which did a great job catching a subtle mistake I had before submitting this patch.
Adrienne Walker
Comment 7 2012-05-30 17:16:28 PDT
Comment on attachment 144691 [details] Patch Increasing precision seems non-controversial and your math looks correct. R=me.
Shawn Singh
Comment 8 2012-05-30 17:17:34 PDT
Comment on attachment 144691 [details] Patch Thanks for reviewing!
WebKit Review Bot
Comment 9 2012-05-30 17:49:15 PDT
Comment on attachment 144691 [details] Patch Clearing flags on attachment: 144691 Committed r119008: <http://trac.webkit.org/changeset/119008>
WebKit Review Bot
Comment 10 2012-05-30 17:49:19 PDT
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.