Flutter Engine
The Flutter Engine
skbug_9319.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 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"
14#include "include/core/SkRect.h"
15
16// Illustrates a bug where the outer portion of the GPU rect blur was too dark with a small sigma.
17DEF_SIMPLE_GM(skbug_9319, canvas, 256, 512) {
18 SkPaint p;
19 p.setAntiAlias(true);
20 p.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.5f));
21
22 const auto r = SkRect::MakeXYWH(10, 10, 100, 100);
23
24 {
25 SkAutoCanvasRestore acr(canvas, true);
26 // Clip out interior so that the outer portion stands out.
27 canvas->clipRect(r, SkClipOp::kDifference);
28 canvas->drawRect(r, p);
29 }
30
31 canvas->translate(0, 120);
32
33
34 // RRect for comparison.
35 const auto rr = SkRRect::MakeRectXY(r, .1f, .1f);
36 {
37 SkAutoCanvasRestore acr(canvas, true);
38 canvas->clipRRect(rr, SkClipOp::kDifference);
39 canvas->drawRRect(rr, p);
40 }
41}
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
DEF_SIMPLE_GM(skbug_9319, canvas, 256, 512)
Definition: skbug_9319.cpp:17
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659