Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
imageblur2.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2011 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/SkFont.h
"
11
#include "
include/core/SkImageFilter.h
"
12
#include "
include/core/SkPaint.h
"
13
#include "
include/core/SkScalar.h
"
14
#include "
include/core/SkTypeface.h
"
15
#include "
include/core/SkTypes.h
"
16
#include "
include/effects/SkImageFilters.h
"
17
#include "
src/base/SkRandom.h
"
18
#include "
tools/ToolUtils.h
"
19
#include "
tools/fonts/FontToolUtils.h
"
20
// TODO deprecate imageblur
21
22
constexpr
int
kWidth
= 500;
23
constexpr
int
kHeight
= 500;
24
25
DEF_SIMPLE_GM
(imageblur2, canvas,
kWidth
,
kHeight
) {
26
constexpr
float
kBlurSigmas[] = { 0.0, 0.3f, 0.5f, 2.0f, 32.0f, 80.0f };
27
const
char
* kTestStrings[] = {
28
"The quick`~"
,
29
"brown fox[]"
,
30
"jumped over"
,
31
"the lazy@#$"
,
32
"dog.{}!%^&"
,
33
"*()+=-\\'\"/"
,
34
};
35
constexpr
int
sigmaCount = std::size(kBlurSigmas);
36
constexpr
int
testStringCount = std::size(kTestStrings);
37
constexpr
SkScalar
dx =
kWidth
/ sigmaCount;
38
constexpr
SkScalar
dy =
kHeight
/ sigmaCount;
39
constexpr
SkScalar
textSize = 12;
40
41
SkFont
font(
ToolUtils::DefaultPortableTypeface
(), textSize);
42
font.setEdging(
SkFont::Edging::kAlias
);
43
44
for
(
int
x
= 0;
x
< sigmaCount;
x
++) {
45
SkScalar
sigmaX = kBlurSigmas[
x
];
46
for
(
int
y
= 0;
y
< sigmaCount;
y
++) {
47
SkScalar
sigmaY = kBlurSigmas[
y
];
48
49
SkPaint
paint
;
50
paint
.setImageFilter(
SkImageFilters::Blur
(sigmaX, sigmaY,
nullptr
));
51
canvas->saveLayer(
nullptr
, &
paint
);
52
53
SkRandom
rand;
54
SkPaint
textPaint;
55
textPaint.
setColor
(
ToolUtils::color_to_565
(rand.
nextBits
(24) | 0xFF000000));
56
for
(
int
i = 0; i < testStringCount; i++) {
57
canvas->drawString(kTestStrings[i],
58
SkIntToScalar
(
x
* dx),
59
SkIntToScalar
(
y
* dy + textSize * i + textSize),
60
font,
61
textPaint);
62
}
63
canvas->restore();
64
}
65
}
66
}
FontToolUtils.h
SkCanvas.h
SkFont.h
SkImageFilter.h
SkImageFilters.h
SkPaint.h
SkRandom.h
SkScalar.h
SkIntToScalar
#define SkIntToScalar(x)
Definition
SkScalar.h:57
SkTypeface.h
SkTypes.h
ToolUtils.h
SkFont
Definition
SkFont.h:35
SkFont::Edging::kAlias
@ kAlias
no transparent pixels on glyph edges
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::setColor
void setColor(SkColor color)
Definition
SkPaint.cpp:119
SkRandom
Definition
SkRandom.h:27
SkRandom::nextBits
uint32_t nextBits(unsigned bitCount)
Definition
SkRandom.h:72
paint
const Paint & paint
Definition
color_source.cc:38
SkScalar
float SkScalar
Definition
extension.cpp:12
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
kWidth
constexpr int kWidth
Definition
imageblur2.cpp:22
kHeight
constexpr int kHeight
Definition
imageblur2.cpp:23
y
double y
Definition
mouse-input-test.cc:83
x
double x
Definition
mouse-input-test.cc:82
ToolUtils::DefaultPortableTypeface
sk_sp< SkTypeface > DefaultPortableTypeface()
Definition
FontToolUtils.cpp:195
ToolUtils::color_to_565
SkColor color_to_565(SkColor color)
Definition
ToolUtils.cpp:139
Generated on Fri Apr 26 2024 06:16:05 for Flutter Engine by
1.9.8