43 : fNameSuffix(nameSuffix),
44 fKernelFixture(kernelFixture) {
46 fColors[0] = colorOne;
47 fColors[1] = colorTwo;
59 paint.setColor(0xFFFFFFFF);
66 surf->getCanvas()->drawString(
"e", -10.0f, 80.0f,
font,
paint);
67 fImage = surf->makeImageSnapshot();
76 float normalizedXOffset = kernelOffsetIn.
fX / 2.0f;
77 float normalizedYOffset = kernelOffsetIn.
fY / 2.0f;
80 switch (fKernelFixture) {
88 {3,3}, kernel.data(), 0.3f, 100.0f,
89 kernelOffset, tileMode, convolveAlpha,
nullptr, tileBoundary);
100 {7,7}, kernel.data(), 0.3f, 100.0f,
101 kernelOffset, tileMode, convolveAlpha,
nullptr, tileBoundary);
107 std::vector<float> kernel(128, 0.0f);
111 {128,1}, kernel.data(), 0.3f, 100.0f,
112 kernelOffset, tileMode, convolveAlpha,
nullptr, tileBoundary);
118 std::vector<float> kernel(255, 0.0f);
122 {1,255}, kernel.data(), 0.3f, 100.0f,
123 kernelOffset, tileMode, convolveAlpha,
nullptr, tileBoundary);
132 const SkIRect* cropRect =
nullptr) {
134 auto filter = this->
makeFilter(kernelOffset, tileMode, convolveAlpha);
138 paint.setImageFilter(std::move(filter));
152 for (
int x = 10;
x < 310;
x += 100) {
172 const char* fNameSuffix;
175 using INHERITED =
GM;
constexpr SkColor SK_ColorBLACK
#define SkScalarRoundToInt(x)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
void translate(SkScalar dx, SkScalar dy)
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkImageFilter > MatrixConvolution(const SkISize &kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
GM(SkColor backgroundColor=SK_ColorWHITE)
void onOnceBeforeDraw() override
void draw(SkCanvas *canvas, int x, int y, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, const SkIRect *cropRect=nullptr)
void onDraw(SkCanvas *canvas) override
SkString getName() const override
bool runAsBench() const override
MatrixConvolutionGM(SkColor colorOne, SkColor colorTwo, KernelFixture kernelFixture, const char *nameSuffix)
sk_sp< SkImageFilter > makeFilter(const SkIPoint &kernelOffsetIn, SkTileMode tileMode, bool convolveAlpha)
SkISize getISize() override
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
font
Font Metadata and Metrics.
static constexpr int kMaxBlurSamples
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
static constexpr SkIPoint Make(int32_t x, int32_t y)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkRect Make(const SkISize &size)