| 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" |
| 9 |
#include "include/core/SkBlurTypes.h" |
| 10 |
#include "include/core/SkCanvas.h" |
| 11 |
#include "include/core/SkMaskFilter.h" |
| 12 |
#include "include/core/SkPaint.h" |
| 13 |
#include "include/core/SkRRect.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. |
| 17 |
DEF_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 |
} |