Flutter Engine
The Flutter Engine
Functions
crbug_1156804.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/effects/SkImageFilters.h"

Go to the source code of this file.

Functions

static void drawOne (SkCanvas *canvas, SkRect rect, float saveBorder, float sigma, SkColor c)
 
 DEF_SIMPLE_GM (crbug_1156804, canvas, 250, 250)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( crbug_1156804  ,
canvas  ,
250  ,
250   
)

Definition at line 32 of file crbug_1156804.cpp.

32 {
33 drawOne(canvas, SkRect::MakeXYWH( 64, 64, 25, 25), 1, 3, SK_ColorGREEN);
34 drawOne(canvas, SkRect::MakeXYWH(164, 64, 25, 25), 30, 3, SK_ColorGREEN);
35 // This one would draw incorrectly because the large sigma causes downscaling of the source
36 // and the one-pixel border would make the downscaled image not contain trans-black at the
37 // edges. Combined with the clamp mode on the blur filter it would "harden" the edge.
38 drawOne(canvas, SkRect::MakeXYWH( 64, 164, 25, 25), 1, 20, SK_ColorRED);
39 drawOne(canvas, SkRect::MakeXYWH(164, 164, 25, 25), 30, 20, SK_ColorGREEN);
40}
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
static void drawOne(SkCanvas *canvas, SkRect rect, float saveBorder, float sigma, SkColor c)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ drawOne()

static void drawOne ( SkCanvas canvas,
SkRect  rect,
float  saveBorder,
float  sigma,
SkColor  c 
)
static

Definition at line 14 of file crbug_1156804.cpp.

14 {
15 SkRect borderRect = rect.makeOutset(saveBorder, saveBorder);
16
17 SkPaint p;
18 p.setColor(c);
19 p.setImageFilter(
20 SkImageFilters::Blur(sigma, sigma,
21 // The blur's input is forced to have transparent padding because 'borderRect' is outset
22 // from the non-transparent content ('rect') that's drawn into the layer.
23 SkImageFilters::Crop(borderRect, SkTileMode::kClamp, nullptr),
24 // The blur's output crop visually won't affect the output because the transparent
25 // padding is blurred out by the edge of 3*sigma.
26 borderRect.makeOutset(3 * sigma, 3 * sigma)));
27 p.setAntiAlias(true);
28
29 canvas->drawRect(rect, p);
30}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002