Flutter Engine
The Flutter Engine
Functions
matriximagefilter.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImage.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/effects/SkImageFilters.h"

Go to the source code of this file.

Functions

static void draw (SkCanvas *canvas, const SkRect &rect, const SkBitmap &bitmap, const SkMatrix &matrix, const SkSamplingOptions &sampling)
 
static void make_checkerboard (SkBitmap *bitmap)
 
 DEF_SIMPLE_GM_BG (matriximagefilter, canvas, 420, 100, SK_ColorBLACK)
 

Function Documentation

◆ DEF_SIMPLE_GM_BG()

DEF_SIMPLE_GM_BG ( matriximagefilter  ,
canvas  ,
420  ,
100  ,
SK_ColorBLACK   
)

Definition at line 48 of file matriximagefilter.cpp.

48 {
50 SkScalar margin = SkIntToScalar(10);
51 matrix.setSkew(SkDoubleToScalar(0.5), SkDoubleToScalar(0.2));
54
55 SkRect srcRect = SkRect::MakeWH(96, 96);
56
57 canvas->translate(margin, margin);
58 draw(canvas, srcRect, checkerboard, matrix, SkSamplingOptions());
59
60 canvas->translate(srcRect.width() + margin, 0);
62}
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64
#define SkIntToScalar(x)
Definition: SkScalar.h:57
float SkScalar
Definition: extension.cpp:12
static void draw(SkCanvas *canvas, const SkRect &rect, const SkBitmap &bitmap, const SkMatrix &matrix, const SkSamplingOptions &sampling)
static void make_checkerboard(SkBitmap *bitmap)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkSamplingOptions(SkFilterMode::kLinear))
constexpr float width() const
Definition: SkRect.h:762
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static void checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)

◆ draw()

static void draw ( SkCanvas canvas,
const SkRect rect,
const SkBitmap bitmap,
const SkMatrix matrix,
const SkSamplingOptions sampling 
)
static

Definition at line 19 of file matriximagefilter.cpp.

20 {
22 paint.setImageFilter(SkImageFilters::MatrixTransform(matrix, sampling, nullptr));
23 canvas->saveLayer(&rect, &paint);
24 canvas->drawImage(bitmap.asImage(), 0, 0, sampling);
25 canvas->restore();
26}
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SkSamplingOptions sampling
Definition: SkRecords.h:337
Definition: bitmap.py:1

◆ make_checkerboard()

static void make_checkerboard ( SkBitmap bitmap)
static

Definition at line 28 of file matriximagefilter.cpp.

28 {
29 bitmap->allocN32Pixels(64, 64);
30 SkCanvas canvas(*bitmap);
31 SkPaint darkPaint;
32 darkPaint.setColor(0xFF404040);
33 SkPaint lightPaint;
34 lightPaint.setColor(0xFFA0A0A0);
35 for (int y = 0; y < 64; y += 32) {
36 for (int x = 0; x < 64; x += 32) {
37 canvas.save();
38 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
39 canvas.drawRect(SkRect::MakeXYWH(0, 0, 16, 16), darkPaint);
40 canvas.drawRect(SkRect::MakeXYWH(16, 0, 16, 16), lightPaint);
41 canvas.drawRect(SkRect::MakeXYWH(0, 16, 16, 16), lightPaint);
42 canvas.drawRect(SkRect::MakeXYWH(16, 16, 16, 16), darkPaint);
43 canvas.restore();
44 }
45 }
46}
void setColor(SkColor color)
Definition: SkPaint.cpp:119
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659