Flutter Engine
The Flutter Engine
Functions
imagefilterscropexpand.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/SkColorFilter.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkPoint3.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTileMode.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkImageFilters.h"
#include <utility>

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (imagefilterscropexpand, canvas, 730, 650)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( imagefilterscropexpand  ,
canvas  ,
730  ,
650   
)

Definition at line 39 of file imagefilterscropexpand.cpp.

39 {
40 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
41
42 sk_sp<SkImage> gradientCircle(make_gradient_circle(64, 64));
44
45 sk_sp<SkImageFilter> gradientCircleSource(SkImageFilters::Image(std::move(gradientCircle),
47 sk_sp<SkImageFilter> noopCropped(SkImageFilters::Offset(0, 0, nullptr, &cropRect));
48 // This color matrix saturates the green component but only partly increases the opacity.
49 // For the opaque checkerboard, the opacity boost doesn't matter but it does impact the
50 // area outside the checkerboard.
51 float matrix[20] = { 1, 0, 0, 0, 0,
52 0, 1, 0, 0, 1,
53 0, 0, 1, 0, 0,
54 0, 0, 0, 1, 32.0f/255 };
56
59
60 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
61 SkScalar kd = SkIntToScalar(2);
62 SkScalar surfaceScale = SkIntToScalar(1);
64 r.roundOut(&bounds);
65
67 canvas->translate(MARGIN, MARGIN);
68 for (int outset = -15; outset <= 20; outset += 5) {
69 canvas->save();
70 SkIRect bigRect = cropRect;
71 bigRect.outset(outset, outset);
72
73 draw(canvas, checkerboard, bigRect,
74 SkImageFilters::ColorFilter(cfAlphaTrans, noopCropped, &bigRect));
75
76 draw(canvas, checkerboard, bigRect,
77 SkImageFilters::Blur(0.3f, 0.3f, noopCropped, &bigRect));
78
79 draw(canvas, checkerboard, bigRect,
80 SkImageFilters::Blur(8.0f, 8.0f, noopCropped, &bigRect));
81
82 draw(canvas, checkerboard, bigRect,
83 SkImageFilters::Dilate(2, 2, noopCropped, &bigRect));
84
85 draw(canvas, checkerboard, bigRect,
86 SkImageFilters::Erode(2, 2, noopCropped, &bigRect));
87
88 draw(canvas, checkerboard, bigRect,
89 SkImageFilters::DropShadow(10, 10, 3, 3, SK_ColorBLUE, noopCropped, &bigRect));
90
91 draw(canvas, checkerboard, bigRect,
93 gradientCircleSource, noopCropped, &bigRect));
94
95 draw(canvas, checkerboard, bigRect,
96 SkImageFilters::Offset(SkIntToScalar(-8), SkIntToScalar(16), noopCropped, &bigRect));
97
98 draw(canvas, checkerboard, bigRect,
99 SkImageFilters::PointLitDiffuse(pointLocation, SK_ColorWHITE, surfaceScale, kd,
100 noopCropped, &bigRect));
101
102 canvas->restore();
103 canvas->translate(0, SkIntToScalar(80));
104 }
105}
static sk_sp< SkImage > make_checkerboard(int width, int height)
static const int outset
Definition: BlurTest.cpp:58
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkImageFilter > PointLitDiffuse(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DropShadow(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DisplacementMap(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
const Paint & paint
Definition: color_source.cc:38
#define MARGIN
float SkScalar
Definition: extension.cpp:12
static sk_sp< SkImage > make_gradient_circle(int width, int height)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
Definition: SkRect.h:32
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
void outset(int32_t dx, int32_t dy)
Definition: SkRect.h:428
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static void checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)