Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Issue 48783002: perpendicular round rects; fuzzy convexity (Closed)

Created:
7 years, 1 month ago by caryclark
Modified:
7 years, 1 month ago
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

Construct round rects with perpendicular tangents. The round rects are constructed as before out of quadratics, but without fudging the control points. Instead, the mid on- curve point is nudged slightly outward to prevent the convexity test from failing. The convexity test now includes an error term for sign inequality after computing the cross product of the control lines. When the control points are represented as vectors, the number of bits of precision may be greatly reduced. Account for this by passing the number of bits available from the original control point values into the equality check. Making round rect construction lines perpendicular improves the chances of success when path ops encounters clips. No new tests are needed -- this change is exercised by the convex Path unit tests and the gm tests arcofzorro and hairlines. Committed: http://code.google.com/p/skia/source/detail?r=12085

Patch Set 1 #

Patch Set 2 : use std skia types #

Total comments: 2

Patch Set 3 : comment magic numbers #

Patch Set 4 : fix release warning #

Total comments: 2

Patch Set 5 : fix epsilon for rr x y dir #

Patch Set 6 : remove test define #

Patch Set 7 : add suppression for gm tests #

Patch Set 8 : fix conflict #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+92 lines, -65 lines) Patch
M expectations/gm/ignored-tests.txt View 1 2 3 4 5 6 7 1 chunk +19 lines, -0 lines 0 comments Download
M src/core/SkGeometry.cpp View 1 2 1 chunk +27 lines, -36 lines 0 comments Download
M src/core/SkPath.cpp View 1 2 3 4 5 6 7 14 chunks +46 lines, -29 lines 1 comment Download

Messages

Total messages: 13 (0 generated)
caryclark
7 years, 1 month ago (2013-10-28 14:04:04 UTC) #1
robertphillips
lgtm + a comment suggestion https://codereview.chromium.org/48783002/diff/30001/src/core/SkGeometry.cpp File src/core/SkGeometry.cpp (right): https://codereview.chromium.org/48783002/diff/30001/src/core/SkGeometry.cpp#newcode1259 src/core/SkGeometry.cpp:1259: static const SkPoint gQuadCirclePts[kSkBuildQuadArcStorage] ...
7 years, 1 month ago (2013-10-28 14:16:54 UTC) #2
caryclark
https://codereview.chromium.org/48783002/diff/30001/src/core/SkGeometry.cpp File src/core/SkGeometry.cpp (right): https://codereview.chromium.org/48783002/diff/30001/src/core/SkGeometry.cpp#newcode1259 src/core/SkGeometry.cpp:1259: static const SkPoint gQuadCirclePts[kSkBuildQuadArcStorage] = { On 2013/10/28 14:16:55, ...
7 years, 1 month ago (2013-10-28 14:25:32 UTC) #3
reed1
https://codereview.chromium.org/48783002/diff/130001/src/core/SkGeometry.cpp File src/core/SkGeometry.cpp (right): https://codereview.chromium.org/48783002/diff/130001/src/core/SkGeometry.cpp#newcode1264 src/core/SkGeometry.cpp:1264: #define SK_MID_RRECT_OFFSET (SK_Scalar1 + SK_ScalarTanPIOver8 + FLT_EPSILON * 4) ...
7 years, 1 month ago (2013-10-29 20:50:06 UTC) #4
reed1
do we already have some test or gm that exercises the new AlmostEqual code?
7 years, 1 month ago (2013-10-29 20:50:37 UTC) #5
caryclark
On 2013/10/29 20:50:37, reed1 wrote: > do we already have some test or gm that ...
7 years, 1 month ago (2013-10-30 16:31:27 UTC) #6
reed1
lgtm
7 years, 1 month ago (2013-10-30 17:36:16 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/caryclark@google.com/48783002/250001
7 years, 1 month ago (2013-11-01 13:03:51 UTC) #8
commit-bot: I haz the power
Failed to apply patch for expectations/gm/ignored-tests.txt: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
7 years, 1 month ago (2013-11-01 13:03:54 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/caryclark@google.com/48783002/300001
7 years, 1 month ago (2013-11-01 13:22:12 UTC) #10
commit-bot: I haz the power
Change committed as 12085
7 years, 1 month ago (2013-11-01 15:24:58 UTC) #11
scroggo
https://codereview.chromium.org/48783002/diff/300001/src/core/SkPath.cpp File src/core/SkPath.cpp (right): https://codereview.chromium.org/48783002/diff/300001/src/core/SkPath.cpp#newcode2264 src/core/SkPath.cpp:2264: static bool AlmostEqual(SkScalar compA, SkScalar compB) { Is this ...
7 years, 1 month ago (2013-11-01 16:04:10 UTC) #12
caryclark
7 years, 1 month ago (2013-11-01 17:11:35 UTC) #13
Message was sent while issue was closed.
On 2013/11/01 16:04:10, scroggo wrote:
> https://codereview.chromium.org/48783002/diff/300001/src/core/SkPath.cpp
> File src/core/SkPath.cpp (right):
> 
>
https://codereview.chromium.org/48783002/diff/300001/src/core/SkPath.cpp#newc...
> src/core/SkPath.cpp:2264: static bool AlmostEqual(SkScalar compA, SkScalar
> compB) {
> Is this deliberately different from SkScalarNearlyEqual in SkScalar.h?
> 
> Also, should this function go in SkScalar.h?

Yes, it is deliberately different. 

SkScalarNearlyEqual does not consider the magnitude of the number, so it is not
useful for replacing == with a form that allows for computational error.

The error factor baked into AlmostEqual is the number of bits required to
satisfy the error produced by the cross product in the convexity test.

You'll find a host of similar routines in src/pathops/SkPathOpsTypes.h, with
different values for the baked in error, which varies depending on the
computation of the caller.

Eventually, it makes sense to extract AlmostEqual as a generally callable
function, but for now, I recommend leaving in SkPath.cpp.

As for SkScalarNearlyEqual, I have not looked at its use cases to understand if
its present form is best, or if it should consider magnitude.

Powered by Google App Engine
This is Rietveld 408576698