Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
blurpositioning.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Google Inc.
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/SkColor.h
"
11
#include "
include/core/SkImageFilter.h
"
12
#include "
include/core/SkPaint.h
"
13
#include "
include/core/SkRect.h
"
14
#include "
include/core/SkScalar.h
"
15
#include "
include/effects/SkImageFilters.h
"
16
17
#include <initializer_list>
18
19
// For all sigma, the black box should be centered in the red outline. For small sigma,
20
// the rectangle is not blurred, but still must be centered properly.
21
22
DEF_SIMPLE_GM
(check_small_sigma_offset, canvas, 200, 1200) {
23
24
for
(
auto
sigma : {0.0, 0.1, 0.2, 0.3, 0.4, 0.6, 0.8, 1.0, 1.2}) {
25
// border calculation from SkBlurImageFilter
26
int
border =
SkScalarCeilToInt
(sigma * 3);
27
28
SkRect
r =
SkRect::MakeXYWH
(50, 50, 100, 50);
29
SkRect
b
= r.
makeOutset
(border + 1, border + 1);
30
b
.
inset
(0.5f, 0.5f);
31
SkPaint
p;
32
p.setColor(
SK_ColorRED
);
33
p.setStyle(
SkPaint::Style::kStroke_Style
);
34
35
canvas->drawRect(
b
, p);
36
37
p.reset();
38
p.setColor(
SK_ColorBLACK
);
39
p.setImageFilter(
SkImageFilters::Blur
(sigma, sigma,
nullptr
));
40
canvas->drawRect(r, p);
41
42
canvas->translate(0, 100);
43
}
44
}
SkCanvas.h
SkColor.h
SK_ColorRED
constexpr SkColor SK_ColorRED
Definition
SkColor.h:126
SK_ColorBLACK
constexpr SkColor SK_ColorBLACK
Definition
SkColor.h:103
SkImageFilter.h
SkImageFilters.h
SkPaint.h
SkRect.h
SkScalar.h
SkScalarCeilToInt
#define SkScalarCeilToInt(x)
Definition
SkScalar.h:36
SkImageFilters::Blur
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Definition
SkBlurImageFilter.cpp:107
SkPaint
Definition
SkPaint.h:44
SkPaint::kStroke_Style
@ kStroke_Style
set to stroke geometry
Definition
SkPaint.h:194
b
static bool b
Definition
ffi_native_test_module.c:74
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
SkRect
Definition
extension.cpp:13
SkRect::inset
void inset(float dx, float dy)
Definition
SkRect.h:1060
SkRect::makeOutset
SkRect makeOutset(float dx, float dy) const
Definition
SkRect.h:1002
SkRect::MakeXYWH
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition
SkRect.h:659
Generated on Fri Apr 26 2024 06:16:00 for Flutter Engine by
1.9.8