From dfaa057c15180a18f65d86317618a97d683e99c4 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Mon, 27 Nov 2017 09:33:44 -0500 Subject: [PATCH] SkPDF: less tolerance for small circles BUG=chromium:772953 Change-Id: I9452ac8ad66ab8be26a9388f8c85a1f0e61bd392 Reviewed-on: https://skia-review.googlesource.com/75960 Reviewed-by: Cary Clark Commit-Queue: Hal Canary --- gm/circle_sizes.cpp | 16 ++++++++++++++++ gn/gm.gni | 1 + src/pdf/SkPDFDevice.cpp | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gm/circle_sizes.cpp diff --git a/gm/circle_sizes.cpp b/gm/circle_sizes.cpp new file mode 100644 index 0000000000..8ed95dd0ed --- /dev/null +++ b/gm/circle_sizes.cpp @@ -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); + } +} diff --git a/gn/gm.gni b/gn/gm.gni index 22d562f187..ad542fb976 100644 --- a/gn/gm.gni +++ b/gn/gm.gni @@ -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", diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 61205ba36d..10ec6911a2 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -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 &&