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/SkCanvas.h" 10 #include "include/core/SkMaskFilter.h" 11 #include "include/core/SkPaint.h" 12 #include "include/core/SkRRect.h" 13 #include "include/core/SkRect.h" 14 15 // Illustrates a bug where the outer portion of the GPU rect blur was too dark with a small sigma. 16 DEF_SIMPLE_GM(skbug_9319, canvas, 256, 512) { 17 SkPaint p; 18 p.setAntiAlias(true); 19 p.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.5f)); 20 21 const auto r = SkRect::MakeXYWH(10, 10, 100, 100); 22 23 { 24 SkAutoCanvasRestore acr(canvas, true); 25 // Clip out interior so that the outer portion stands out. 26 canvas->clipRect(r, SkClipOp::kDifference); 27 canvas->drawRect(r, p); 28 } 29 30 canvas->translate(0, 120); 31 32 33 // RRect for comparison. 34 const auto rr = SkRRect::MakeRectXY(r, .1f, .1f); 35 { 36 SkAutoCanvasRestore acr(canvas, true); 37 canvas->clipRRect(rr, SkClipOp::kDifference); 38 canvas->drawRRect(rr, p); 39 } 40 } 41