Brian Osman | e3afdd5 | 2020-10-28 10:49:56 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm/gm.h" |
| 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkPaint.h" |
| 11 | #include "include/core/SkRRect.h" |
| 12 | |
| 13 | DEF_SIMPLE_GM_BG(crbug_1139750, canvas, 50, 50, SK_ColorWHITE) { |
| 14 | // Draw a round-rect with a (slightly) non-square scale. This forces the GPU backend to use |
| 15 | // the elliptical round-rect op. We set the stroke width to exactly double the radii, which |
| 16 | // makes the inner radii exactly zero. The shader uses the inverse inner radii to compute the |
| 17 | // coverage ramp, so this would end up producing infinity, and the geometry would disappear. |
| 18 | SkPaint p; |
| 19 | p.setAntiAlias(true); |
| 20 | p.setStyle(SkPaint::kStroke_Style); |
| 21 | p.setStrokeWidth(2); |
| 22 | |
| 23 | SkRect r = SkRect::MakeXYWH(1, 1, 19, 19); |
| 24 | SkRRect rr = SkRRect::MakeRectXY(r, 1, 1); |
| 25 | |
| 26 | canvas->translate(10, 10); |
| 27 | canvas->scale(1.47619f, 1.52381f); |
| 28 | canvas->drawRRect(rr, p); |
| 29 | } |