skia2/gm/crbug_1139750.cpp
Brian Osman e3afdd5b75 Avoid infinite inverse inner-radii in eliiptical rrect op
Bug: chromium:1139750, skia:8389
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel,win10-blink-rel
Change-Id: I69c55f505947fdec5d9d391d2b2d2d3ff6dec9b8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330216
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-11-02 20:01:04 +00:00

30 lines
1023 B
C++

/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRRect.h"
DEF_SIMPLE_GM_BG(crbug_1139750, canvas, 50, 50, SK_ColorWHITE) {
// Draw a round-rect with a (slightly) non-square scale. This forces the GPU backend to use
// the elliptical round-rect op. We set the stroke width to exactly double the radii, which
// makes the inner radii exactly zero. The shader uses the inverse inner radii to compute the
// coverage ramp, so this would end up producing infinity, and the geometry would disappear.
SkPaint p;
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(2);
SkRect r = SkRect::MakeXYWH(1, 1, 19, 19);
SkRRect rr = SkRRect::MakeRectXY(r, 1, 1);
canvas->translate(10, 10);
canvas->scale(1.47619f, 1.52381f);
canvas->drawRRect(rr, p);
}