Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
imageblur2.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkFont.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkImageFilters.h"
#include "src/base/SkRandom.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (imageblur2, canvas, kWidth, kHeight)
 

Variables

constexpr int kWidth = 500
 
constexpr int kHeight = 500
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( imageblur2  ,
canvas  ,
kWidth  ,
kHeight   
)

Definition at line 25 of file imageblur2.cpp.

25 {
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
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
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}
#define SkIntToScalar(x)
Definition SkScalar.h:57
@ kAlias
no transparent pixels on glyph edges
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
void setColor(SkColor color)
Definition SkPaint.cpp:119
uint32_t nextBits(unsigned bitCount)
Definition SkRandom.h:72
const Paint & paint
float SkScalar
Definition extension.cpp:12
constexpr int kWidth
constexpr int kHeight
double y
double x
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208
sk_sp< SkTypeface > DefaultPortableTypeface()
SkColor color_to_565(SkColor color)
font
Font Metadata and Metrics.

Variable Documentation

◆ kHeight

constexpr int kHeight = 500
constexpr

Definition at line 23 of file imageblur2.cpp.

◆ kWidth

constexpr int kWidth = 500
constexpr

Definition at line 22 of file imageblur2.cpp.