The 1-character fix is taken from Erik's https://critique.corp.google.com/#review/29047930 The test was adapted from an email ...
12 years, 7 months ago
(2012-04-09 17:41:52 UTC)
#1
The 1-character fix is taken from Erik's
https://critique.corp.google.com/#review/29047930
The test was adapted from an email from Justin
I have confirmed that I get a segfault in the new test without the fix, and the
fix makes the segfault go away.
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp File src/core/SkPoint.cpp (right): https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp#newcode114 src/core/SkPoint.cpp:114: if (mag2 >= SK_ScalarNearlyZero * SK_ScalarNearlyZero) { My bad ...
12 years, 7 months ago
(2012-04-09 18:10:30 UTC)
#4
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp
File src/core/SkPoint.cpp (right):
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp#newcode114
src/core/SkPoint.cpp:114: if (mag2 >= SK_ScalarNearlyZero * SK_ScalarNearlyZero)
{
My bad -- I thought the change also replaced one nearlyzero with nearlyzero^2,
but I see that it was already squared.
This seems an awfully fragile fix. Can we tweak the new test to make it fail, by
just slightly changing the input values?
On 2012/04/09 18:02:42, reed1 wrote:
> Can we change it to > instead of >= ? It seems it might be reasonable
(possible)
> for nearlyzero to be set to zero, in which case we would divide-by-zero here.
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp File src/core/SkPoint.cpp (right): https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp#newcode114 src/core/SkPoint.cpp:114: if (mag2 >= SK_ScalarNearlyZero * SK_ScalarNearlyZero) { On 2012/04/09 ...
12 years, 7 months ago
(2012-04-09 18:28:28 UTC)
#5
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp
File src/core/SkPoint.cpp (right):
https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp#newcode114
src/core/SkPoint.cpp:114: if (mag2 >= SK_ScalarNearlyZero * SK_ScalarNearlyZero)
{
On 2012/04/09 18:10:31, reed1 wrote:
> My bad -- I thought the change also replaced one nearlyzero with nearlyzero^2,
> but I see that it was already squared.
>
> This seems an awfully fragile fix. Can we tweak the new test to make it fail,
by
> just slightly changing the input values?
>
> On 2012/04/09 18:02:42, reed1 wrote:
> > Can we change it to > instead of >= ? It seems it might be reasonable
> (possible)
> > for nearlyzero to be set to zero, in which case we would divide-by-zero
here.
>
My understanding from Erik's change in
https://critique.corp.google.com/#review/29047930 is that there is currently
some bad interaction between this check and IsLineDegenerate() in
http://code.google.com/p/skia/source/browse/trunk/include/core/SkPath.h . Like,
if they have different border conditions (> vs. >=) then we get bad results in
certain cases...
Erik, is that right?
On Mon, Apr 9, 2012 at 11:28 AM, <epoger@google.com> wrote: > > https://codereview.appspot.**com/5992077/diff/5001/src/**core/SkPoint.cpp<https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp> > File ...
12 years, 7 months ago
(2012-04-09 18:52:15 UTC)
#6
On Mon, Apr 9, 2012 at 11:28 AM, <epoger@google.com> wrote:
>
>
https://codereview.appspot.**com/5992077/diff/5001/src/**core/SkPoint.cpp<htt...
> File src/core/SkPoint.cpp (right):
>
> https://codereview.appspot.**com/5992077/diff/5001/src/**
>
core/SkPoint.cpp#newcode114<https://codereview.appspot.com/5992077/diff/5001/src/core/SkPoint.cpp#newcode114>
> src/core/SkPoint.cpp:114: if (mag2 >= SK_ScalarNearlyZero *
> SK_ScalarNearlyZero) {
> On 2012/04/09 18:10:31, reed1 wrote:
>
>> My bad -- I thought the change also replaced one nearlyzero with
>>
> nearlyzero^2,
>
>> but I see that it was already squared.
>>
>
> This seems an awfully fragile fix. Can we tweak the new test to make
>>
> it fail, by
>
>> just slightly changing the input values?
>>
>
> On 2012/04/09 18:02:42, reed1 wrote:
>> > Can we change it to > instead of >= ? It seems it might be
>>
> reasonable
>
>> (possible)
>> > for nearlyzero to be set to zero, in which case we would
>>
> divide-by-zero here.
>
>
> My understanding from Erik's change in
>
https://critique.corp.google.**com/#review/29047930<https://critique.corp.goo...
that there is
> currently some bad interaction between this check and IsLineDegenerate()
> in
> http://code.google.com/p/skia/**source/browse/trunk/include/**
>
core/SkPath.h<http://code.google.com/p/skia/source/browse/trunk/include/core/SkPath.h>
> . Like, if they have different border conditions (> vs. >=) then we get
> bad results in certain cases...
>
> Erik, is that right?
>
Yeah... IsDegenerateLine checks that the length is >= the threshold.
setLength checks that we are > the threshold.
Specifically we're seeing the assertion at
http://code.google.com/p/skia/source/browse/trunk/src/core/SkStroke.cpp#123fails
because we get past the IsDegenerateLine check at
http://code.google.com/p/skia/source/browse/trunk/src/core/SkStroke.cpp#216 but
not the check in setLength() reached via set_normal_unitnormal() ->
setNormalize().
I agree that the math looks fragile - esp if you're not looking at
horizontal or vertical lines. I think the IsDegenerateLine check should
become more stringent than the setLength in that case which should work out
ok. Of course, it'd be nice if there was only a single check or if the
check in preJoinTo could fail cleanly but I was looking for a non-invasive
solution.
- Erik
What if we change IsDegenerateLine to perform exactly the test done in setLength i.e. mag2 ...
12 years, 7 months ago
(2012-04-09 19:16:57 UTC)
#7
What if we change IsDegenerateLine to perform exactly the test done in setLength
i.e. mag2 < nearlyzero^2
This actually seems faster than two sets of fabs + compares. Do we think that
would fix this bug, and not make things worse?
I like the header changes, but I'm not sure about the rewrite of CanNormalize. Can ...
12 years, 7 months ago
(2012-04-10 17:22:10 UTC)
#10
I like the header changes, but I'm not sure about the rewrite of CanNormalize.
Can we disassemble it, and setLength, and confirm that each of these are still
leaf-functions (i.e. make no function calls out)?
On 2012/04/10 17:22:10, reed1 wrote: > I like the header changes, but I'm not sure ...
12 years, 7 months ago
(2012-04-10 19:34:06 UTC)
#11
On 2012/04/10 17:22:10, reed1 wrote:
> I like the header changes, but I'm not sure about the rewrite of CanNormalize.
> Can we disassemble it, and setLength, and confirm that each of these are still
> leaf-functions (i.e. make no function calls out)?
Mike and I looked at the disassembly and are satisfied that performance will not
be hurt (all appropriate code is inlined, etc.)
Mike, can I get an LG?
On 2012/04/10 20:27:06, reed1 wrote: > why yes you may > > lgtm Uh oh, ...
12 years, 7 months ago
(2012-04-10 20:32:46 UTC)
#13
On 2012/04/10 20:27:06, reed1 wrote:
> why yes you may
>
> lgtm
Uh oh, I found a new problem... this CL breaks PointTest for SK_SCALAR_IS_FIXED,
because that test requires SkPoint::Length() and SkPoint::Normalize() to return
exactly equal values... and with this change they are computed differently and
thus may be slightly off.
Mike/Brian, please see SkPoint.cpp as of patchset 10 : https://codereview.appspot.com/5992077/diff/9005/src/core/SkPoint.cpp (no other files have changed ...
12 years, 7 months ago
(2012-04-11 15:39:29 UTC)
#14
Mike/Brian, please see SkPoint.cpp as of patchset 10 :
https://codereview.appspot.com/5992077/diff/9005/src/core/SkPoint.cpp
(no other files have changed since Mike's previous LGTM)
With this change, all tests pass on both float and fixed. In fixed-point mode,
SkPoint::Normalize() now uses the same high-precision (Sk64) math that
CanNormalize() and Length() do.
https://codereview.appspot.com/5992077/diff/9005/src/core/SkPoint.cpp File src/core/SkPoint.cpp (right): https://codereview.appspot.com/5992077/diff/9005/src/core/SkPoint.cpp#newcode98 src/core/SkPoint.cpp:98: // in *result. Returns true if the distance is ...
12 years, 7 months ago
(2012-04-11 15:52:55 UTC)
#16
Hmmm, Now the comment has to read: // Return true if the length is nearly ...
12 years, 7 months ago
(2012-04-11 15:57:56 UTC)
#18
Hmmm,
Now the comment has to read:
// Return true if the length is nearly zero, but return the length squared.
Does the name need to not agree with its return-arg?
On 2012/04/11 15:57:56, reed1 wrote: > Hmmm, > > Now the comment has to read: ...
12 years, 7 months ago
(2012-04-11 16:30:40 UTC)
#19
On 2012/04/11 15:57:56, reed1 wrote:
> Hmmm,
>
> Now the comment has to read:
>
> // Return true if the length is nearly zero, but return the length squared.
>
> Does the name need to not agree with its return-arg?
Ok, fine, isLengthSqdNearlyZero
On 2012/04/11 16:30:40, bsalomon wrote: > On 2012/04/11 15:57:56, reed1 wrote: > > Hmmm, > ...
12 years, 7 months ago
(2012-04-11 16:31:12 UTC)
#20
On 2012/04/11 16:30:40, bsalomon wrote:
> On 2012/04/11 15:57:56, reed1 wrote:
> > Hmmm,
> >
> > Now the comment has to read:
> >
> > // Return true if the length is nearly zero, but return the length squared.
> >
> > Does the name need to not agree with its return-arg?
>
> Ok, fine, isLengthSqdNearlyZero
Or isLengthSqdNearlyZeroSqd :)
Brian/Mike, please see latest change to function names: https://codereview.appspot.com/5992077/diff2/9005:8009/src/core/SkPoint.cpp Looking for that crucial third LGTM...
12 years, 7 months ago
(2012-04-11 16:36:54 UTC)
#21
Issue 5992077: Fix SkPathStroker::lineTo() for line with length SK_ScalarNearlyZero
(Closed)
Created 12 years, 7 months ago by epoger
Modified 12 years, 7 months ago
Reviewers: reed1, bsalomon
Base URL: http://skia.googlecode.com/svn/trunk/
Comments: 6