SkPDF: less tolerance for small circles

BUG=chromium:772953
Change-Id: I9452ac8ad66ab8be26a9388f8c85a1f0e61bd392
Reviewed-on: https://skia-review.googlesource.com/75960
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2017-11-27 09:33:44 -05:00 committed by Skia Commit-Bot
parent 4b0e364f92
commit dfaa057c15
3 changed files with 19 additions and 1 deletions

16
gm/circle_sizes.cpp Normal file
View File

@ -0,0 +1,16 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
// https://crbug.com/772953
DEF_SIMPLE_GM(circle_sizes, canvas, 128, 128) {
SkPaint p;
p.setAntiAlias(true);
for (int i = 0; i < 16; ++i) {
canvas->drawCircle({14.0f + 32.0f * (i % 4),
14.0f + 32.0f * (i / 4)}, i + 1.0f, p);
}
}

View File

@ -60,6 +60,7 @@ gm_sources = [
"$_gm/bug615686.cpp",
"$_gm/cgm.c",
"$_gm/cgms.cpp",
"$_gm/circle_sizes.cpp",
"$_gm/circles.cpp",
"$_gm/circulararcs.cpp",
"$_gm/circularclips.cpp",

View File

@ -952,8 +952,9 @@ void SkPDFDevice::internalDrawPath(const SkClipStack& clipStack,
if (!content.entry()) {
return;
}
constexpr SkScalar kToleranceScale = 0.0625f; // smaller = better conics (circles).
SkScalar matrixScale = matrix.mapRadius(1.0f);
SkScalar tolerance = matrixScale > 0.0f ? 0.25f / matrixScale : 0.25f;
SkScalar tolerance = matrixScale > 0.0f ? kToleranceScale / matrixScale : kToleranceScale;
bool consumeDegeratePathSegments =
paint.getStyle() == SkPaint::kFill_Style ||
(paint.getStrokeCap() != SkPaint::kRound_Cap &&