Flutter Engine
The Flutter Engine
Macros | Functions
imageblur.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.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/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.

Macros

#define WIDTH   500
 
#define HEIGHT   500
 

Functions

void imageblurgm_draw (SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas *canvas)
 
 DEF_SIMPLE_GM_BG (imageblur, canvas, WIDTH, HEIGHT, SK_ColorBLACK)
 
 DEF_SIMPLE_GM_BG (imageblur_large, canvas, WIDTH, HEIGHT, SK_ColorBLACK)
 

Macro Definition Documentation

◆ HEIGHT

#define HEIGHT   500

Definition at line 22 of file imageblur.cpp.

◆ WIDTH

#define WIDTH   500

Definition at line 21 of file imageblur.cpp.

Function Documentation

◆ DEF_SIMPLE_GM_BG() [1/2]

DEF_SIMPLE_GM_BG ( imageblur  ,
canvas  ,
WIDTH  ,
HEIGHT  ,
SK_ColorBLACK   
)

Definition at line 42 of file imageblur.cpp.

42 {
43 imageblurgm_draw(24.0f, 0.0f, canvas);
44}
void imageblurgm_draw(SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas *canvas)
Definition: imageblur.cpp:24

◆ DEF_SIMPLE_GM_BG() [2/2]

DEF_SIMPLE_GM_BG ( imageblur_large  ,
canvas  ,
WIDTH  ,
HEIGHT  ,
SK_ColorBLACK   
)

Definition at line 45 of file imageblur.cpp.

45 {
46 imageblurgm_draw(80.0f, 80.0f, canvas);
47}

◆ imageblurgm_draw()

void imageblurgm_draw ( SkScalar  fSigmaX,
SkScalar  fSigmaY,
SkCanvas canvas 
)

Definition at line 24 of file imageblur.cpp.

24 {
26 paint.setImageFilter(SkImageFilters::Blur(fSigmaX, fSigmaY, nullptr));
27 canvas->saveLayer(nullptr, &paint);
28 const char* str = "The quick brown fox jumped over the lazy dog.";
29
30 SkRandom rand;
31 SkPaint textPaint;
33 for (int i = 0; i < 25; ++i) {
34 int x = rand.nextULessThan(WIDTH);
35 int y = rand.nextULessThan(HEIGHT);
36 textPaint.setColor(ToolUtils::color_to_565(rand.nextBits(24) | 0xFF000000));
37 font.setSize(rand.nextRangeScalar(0, 300));
38 canvas->drawString(str, SkIntToScalar(x), SkIntToScalar(y), font, textPaint);
39 }
40 canvas->restore();
41}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
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
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
Definition: SkRandom.h:106
uint32_t nextULessThan(uint32_t count)
Definition: SkRandom.h:93
uint32_t nextBits(unsigned bitCount)
Definition: SkRandom.h:72
const Paint & paint
Definition: color_source.cc:38
#define WIDTH
Definition: imageblur.cpp:21
#define HEIGHT
Definition: imageblur.cpp:22
double y
double x
SkFont DefaultPortableFont()
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
font
Font Metadata and Metrics.