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

Side by Side Diff: src/core/SkStroke.cpp

Issue 22947005: fine-tune tolerance for pinchy quads in stroker (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/aaclip.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkStrokerPriv.h" 8 #include "SkStrokerPriv.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 12 matching lines...) Expand all
23 static const SkScalar kFlatEnoughNormalDotProd = 23 static const SkScalar kFlatEnoughNormalDotProd =
24 SK_ScalarSqrt2/2 + SK_Scalar1/10; 24 SK_ScalarSqrt2/2 + SK_Scalar1/10;
25 25
26 SkASSERT(kFlatEnoughNormalDotProd > 0 && 26 SkASSERT(kFlatEnoughNormalDotProd > 0 &&
27 kFlatEnoughNormalDotProd < SK_Scalar1); 27 kFlatEnoughNormalDotProd < SK_Scalar1);
28 28
29 return SkPoint::DotProduct(norm0, norm1) <= kFlatEnoughNormalDotProd; 29 return SkPoint::DotProduct(norm0, norm1) <= kFlatEnoughNormalDotProd;
30 } 30 }
31 31
32 static inline bool normals_too_pinchy(const SkVector& norm0, SkVector& norm1) { 32 static inline bool normals_too_pinchy(const SkVector& norm0, SkVector& norm1) {
33 static const SkScalar kTooPinchyNormalDotProd = -SK_Scalar1 * 999 / 1000; 33 // if the dot-product is -1, then we are definitely too pinchy. We tweak
34 // that by an epsilon to ensure we have significant bits in our test
35 static const int kMinSigBitsForDot = 8;
36 static const SkScalar kDotEpsilon = FLT_EPSILON * (1 << kMinSigBitsForDot);
37 static const SkScalar kTooPinchyNormalDotProd = kDotEpsilon - 1;
38
39 // just some sanity asserts to help document the expected range
40 SkASSERT(kTooPinchyNormalDotProd >= -1);
41 SkASSERT(kTooPinchyNormalDotProd < SkDoubleToScalar(-0.999));
34 42
35 return SkPoint::DotProduct(norm0, norm1) <= kTooPinchyNormalDotProd; 43 SkScalar dot = SkPoint::DotProduct(norm0, norm1);
44 return dot <= kTooPinchyNormalDotProd;
36 } 45 }
37 46
38 static bool set_normal_unitnormal(const SkPoint& before, const SkPoint& after, 47 static bool set_normal_unitnormal(const SkPoint& before, const SkPoint& after,
39 SkScalar radius, 48 SkScalar radius,
40 SkVector* normal, SkVector* unitNormal) { 49 SkVector* normal, SkVector* unitNormal) {
41 if (!unitNormal->setNormalize(after.fX - before.fX, after.fY - before.fY)) { 50 if (!unitNormal->setNormalize(after.fX - before.fX, after.fY - before.fY)) {
42 return false; 51 return false;
43 } 52 }
44 unitNormal->rotateCCW(); 53 unitNormal->rotateCCW();
45 unitNormal->scale(radius, normal); 54 unitNormal->scale(radius, normal);
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 default: 725 default:
717 break; 726 break;
718 } 727 }
719 728
720 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { 729 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) {
721 r = rect; 730 r = rect;
722 r.inset(radius, radius); 731 r.inset(radius, radius);
723 dst->addRect(r, reverse_direction(dir)); 732 dst->addRect(r, reverse_direction(dir));
724 } 733 }
725 } 734 }
OLDNEW
« no previous file with comments | « gm/aaclip.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698