|
|
Created:
12 years, 9 months ago by guanqun Modified:
12 years, 8 months ago CC:
skia-review_googlegroups.com Base URL:
http://skia.googlecode.com/svn/trunk Visibility:
Public. |
Descriptionadd isSimilarityTransform() and some tests
As discussed, this function is separated from the big CL (circle drawing:
http://codereview.appspot.com/5696086/).
The tests are run successfully both in SK_SCALAR_IS_FLOAT and SK_SCALAR_IS_FIXED configuration.
BUG=
TEST=
Patch Set 1 #
Total comments: 3
Patch Set 2 : don't add interface in SkMatrix, but use a static function in SkGpuDevice.cpp #Patch Set 3 : go back to tol. #Patch Set 4 : remove the SkGpuDevice.cpp, it'll be added in circle drawing patch. #Patch Set 5 : add tol^2 #Patch Set 6 : relax the tolerance for SK_SCALAR_IS_FIXED #Patch Set 7 : one comparison use tol while another use tol^2 #Patch Set 8 : cast to float and then calculate #Patch Set 9 : bypass some tests for fixed build #
Total comments: 2
MessagesTotal messages: 20
1. Use Brian's algorithm to save a few operations when setting up 'vec'. 2. Add check for all zero case. Please review!
Sign in to reply to this message.
http://codereview.appspot.com/5999050/diff/1/include/core/SkMatrix.h File include/core/SkMatrix.h (right): http://codereview.appspot.com/5999050/diff/1/include/core/SkMatrix.h#newcode89 include/core/SkMatrix.h:89: * if the matrix doesn't have skew and it doesn't contains perspective and its scale is square (i.e. scaleX == scaleY). Put another way: the matrix only includes square-scale, rotation, translation. http://codereview.appspot.com/5999050/diff/1/src/core/SkMatrix.cpp File src/core/SkMatrix.cpp (right): http://codereview.appspot.com/5999050/diff/1/src/core/SkMatrix.cpp#newcode1154 src/core/SkMatrix.cpp:1154: Do we want tol^2 for both of these?
Sign in to reply to this message.
http://codereview.appspot.com/5999050/diff/1/src/core/SkMatrix.cpp File src/core/SkMatrix.cpp (right): http://codereview.appspot.com/5999050/diff/1/src/core/SkMatrix.cpp#newcode1154 src/core/SkMatrix.cpp:1154: On 2012/04/11 13:00:38, reed1 wrote: > Do we want tol^2 for both of these? I suppose they are both checking length squared values so maybe.
Sign in to reply to this message.
I'm removing the interface in SkMatrix, because as we don't track rotated circles, it's used once once in SkGpuDevice.cpp file. If I'm using tol^2, then that fails on SK_FLOAT_IS_FIXED, on fixed platform, SK_ScalarNearlyZero squared would give back zero and then it fails in SkASSERT(tolerance > 0) check. From the comments: 308 /* <= is slower than < for floats, so we use < for our tolerance test 309 */ So is it a good time to add back "<=" or we agree to use "tol" for comparison here? Thanks!
Sign in to reply to this message.
I think that "< is faster than <=" is dumb. I've changed it to <= Does that resolve your issue?
Sign in to reply to this message.
On 2012/04/12 12:52:21, reed1 wrote: > I think that "< is faster than <=" is dumb. I've changed it to <= > Does that resolve your issue? Yes, it can resolve the SK_SCALAR_IS_FIXED issue. Please review again. Thanks.
Sign in to reply to this message.
I wonder if there is a way to use tables of data to reduce the amount of copy/paste of code in all of these tests. If not, LGTM
Sign in to reply to this message.
On 2012/04/13 12:14:28, reed1 wrote: > I wonder if there is a way to use tables of data to reduce the amount of > copy/paste of code in all of these tests. > > If not, LGTM There's a way to use tables of data. e.g. add the structure struct data { skscalar a, b, c, d, e, f, g, h, i; bool expectedresult; } arrays[] = { ...... }; then, for each one in arrays: construct matrix from a, b, c, d, e, f, g, h, i; test the function with expected result. I'm relunctant to change to this style because: 1) I have to precalculate the result for each elements in skmatrix. however, in the current way, I can use postTranslate() etc. 2) If some test fails, the failure would only output the file line. It would be much easier to track which test case fails in the current expanded style than using a for loop.
Sign in to reply to this message.
On 2012/04/14 13:13:07, guanqun wrote: > On 2012/04/13 12:14:28, reed1 wrote: > > I wonder if there is a way to use tables of data to reduce the amount of > > copy/paste of code in all of these tests. > > > > If not, LGTM > > There's a way to use tables of data. e.g. add the structure > struct data { > skscalar a, b, c, d, e, f, g, h, i; > bool expectedresult; > } arrays[] = { > ...... > }; > then, > for each one in arrays: > construct matrix from a, b, c, d, e, f, g, h, i; > test the function with expected result. > > I'm relunctant to change to this style because: > 1) I have to precalculate the result for each elements in skmatrix. however, in > the current way, I can use postTranslate() etc. > 2) If some test fails, the failure would only output the file line. It would be > much easier to track which test case fails in the current expanded style than > using a for loop. Committed at r3681
Sign in to reply to this message.
On 2012/04/16 14:07:05, bsalomon wrote: > On 2012/04/14 13:13:07, guanqun wrote: > > On 2012/04/13 12:14:28, reed1 wrote: > > > I wonder if there is a way to use tables of data to reduce the amount of > > > copy/paste of code in all of these tests. > > > > > > If not, LGTM > > > > There's a way to use tables of data. e.g. add the structure > > struct data { > > skscalar a, b, c, d, e, f, g, h, i; > > bool expectedresult; > > } arrays[] = { > > ...... > > }; > > then, > > for each one in arrays: > > construct matrix from a, b, c, d, e, f, g, h, i; > > test the function with expected result. > > > > I'm relunctant to change to this style because: > > 1) I have to precalculate the result for each elements in skmatrix. however, > in > > the current way, I can use postTranslate() etc. > > 2) If some test fails, the failure would only output the file line. It would > be > > much easier to track which test case fails in the current expanded style than > > using a for loop. > > Committed at r3681 I reverted this at r3684 because the fixed point build fails MatrixTest.
Sign in to reply to this message.
oops, which platform is seeing this failure? I've tested it with fixed point on x86_64 and both debug and release build pass the matrix test. On Mon, Apr 16, 2012 at 10:41 PM, <bsalomon@google.com> wrote: > > I reverted this at r3684 because the fixed point build fails MatrixTest. > > > > http://codereview.appspot.com/5999050/ -- Guanqun
Sign in to reply to this message.
Actually looking back on the bot runs it appears to only have failed on the Mac. On Mon, Apr 16, 2012 at 11:39 AM, Lu Guanqun <guanqun.lu@gmail.com> wrote: > oops, which platform is seeing this failure? I've tested it with fixed > point on x86_64 and both debug and release build pass the matrix test. > > On Mon, Apr 16, 2012 at 10:41 PM, <bsalomon@google.com> wrote: > > > > I reverted this at r3684 because the fixed point build fails MatrixTest. > > > > > > > > http://codereview.appspot.com/5999050/ > > > > -- > Guanqun >
Sign in to reply to this message.
Tolerance is too tight for fixed build. So relax it. I've tested it on an IMac machine(Lion), it works OK for both float and fixed build. Please try to re-land this CL and see if it would break your build again...
Sign in to reply to this message.
1/64 is a pretty loose tolerance. Do we need to look at how we compute is-similar in the fixed case? Can we do it and keep more precision?
Sign in to reply to this message.
In the latest patchset, I propose to casting SkScalar to float and do the calculation. Therefore, all the problems are set. Do you think this is good way to go? (I've tested this on both Linux and iMac with both float and fixed build). Otherwise, there are several possible workarounds: 1. make fix build's tolerance to be 1/2^8. 2. compare dot result with tol while compare lengthSqd with tol^2.
Sign in to reply to this message.
I think the use of the tolerance parameter in the function is incorrect, but I don't know what the correct usage is. e.g. if the matrix has a very large, or very small scale applied, the computed error terms grow big or small, but our tolerance values do not. That seems like a problem (but I'm not sure). If we are already using this function, I would rather have some tests then none, so I'm going to suggest that we just suppress the fixed-point tests that fail at the moment (with some big comment) rather than tweak the tolerance or some other workaround, since doing so might suggest that we think that is a "correct" fix.
Sign in to reply to this message.
Hi Mike, In latest patchset, I bypass the failed tests on Mac platform and added some comments to it. And I use a previous implementation of isSimilarityTransform() without converting fixed value to float etc. Please review. thanks! Tested both on linux and mac platform and both for fixed build and float build.
Sign in to reply to this message.
lgtm, w/ a question about the test for 4 zeros in the middle of the function. http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp File tests/MatrixTest.cpp (right): http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp#newcode206 tests/MatrixTest.cpp:206: What does this test do that isn't done by the tests below?
Sign in to reply to this message.
Question answered. And please help land this CL if it's OK. http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp File tests/MatrixTest.cpp (right): http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp#newcode206 tests/MatrixTest.cpp:206: On 2012/04/24 16:10:30, reed1 wrote: > What does this test do that isn't done by the tests below? No. The tests below would return true when all numbers are zero, which should return false. So we have to check it explicitly.
Sign in to reply to this message.
On 2012/04/25 07:53:39, guanqun wrote: > Question answered. And please help land this CL if it's OK. > > http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp > File tests/MatrixTest.cpp (right): > > http://codereview.appspot.com/5999050/diff/28001/tests/MatrixTest.cpp#newcode206 > tests/MatrixTest.cpp:206: > On 2012/04/24 16:10:30, reed1 wrote: > > What does this test do that isn't done by the tests below? > > No. The tests below would return true when all numbers are zero, which should > return false. So we have to check it explicitly. Landed at r3762
Sign in to reply to this message.
|