fine-tune tolerance for pinchy quads in stroker
BUG= R=jvanverth@google.com Review URL: https://codereview.chromium.org/22947005 git-svn-id: http://skia.googlecode.com/svn/trunk@10753 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
44d662b86a
commit
439df286c8
@ -9,6 +9,26 @@
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
|
||||
static void test_quadstroke(SkCanvas* canvas) {
|
||||
SkPath path;
|
||||
path.moveTo(6, 0);
|
||||
path.quadTo(150, 150, 0, 6);
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
canvas->translate(20, 20);
|
||||
|
||||
#if 1
|
||||
canvas->drawPath(path, paint);
|
||||
canvas->translate(100, 0);
|
||||
#endif
|
||||
|
||||
paint.setStrokeWidth(1.01f);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
|
||||
static void draw_conic(SkCanvas* canvas, SkScalar weight, const SkPaint& paint) {
|
||||
SkPath path;
|
||||
path.moveTo(100, 100);
|
||||
@ -253,6 +273,7 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
|
||||
if (false) { test_quadstroke(canvas); return; }
|
||||
if (false) { test_conic(canvas); return; }
|
||||
if (false) {
|
||||
SkRect bounds;
|
||||
|
@ -30,9 +30,18 @@ static inline bool normals_too_curvy(const SkVector& norm0, SkVector& norm1) {
|
||||
}
|
||||
|
||||
static inline bool normals_too_pinchy(const SkVector& norm0, SkVector& norm1) {
|
||||
static const SkScalar kTooPinchyNormalDotProd = -SK_Scalar1 * 999 / 1000;
|
||||
// if the dot-product is -1, then we are definitely too pinchy. We tweak
|
||||
// that by an epsilon to ensure we have significant bits in our test
|
||||
static const int kMinSigBitsForDot = 8;
|
||||
static const SkScalar kDotEpsilon = FLT_EPSILON * (1 << kMinSigBitsForDot);
|
||||
static const SkScalar kTooPinchyNormalDotProd = kDotEpsilon - 1;
|
||||
|
||||
// just some sanity asserts to help document the expected range
|
||||
SkASSERT(kTooPinchyNormalDotProd >= -1);
|
||||
SkASSERT(kTooPinchyNormalDotProd < SkDoubleToScalar(-0.999));
|
||||
|
||||
return SkPoint::DotProduct(norm0, norm1) <= kTooPinchyNormalDotProd;
|
||||
SkScalar dot = SkPoint::DotProduct(norm0, norm1);
|
||||
return dot <= kTooPinchyNormalDotProd;
|
||||
}
|
||||
|
||||
static bool set_normal_unitnormal(const SkPoint& before, const SkPoint& after,
|
||||
|
Loading…
Reference in New Issue
Block a user