2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2019-05-01 21:28:53 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBitmap.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkFilterQuality.h"
|
|
|
|
#include "include/core/SkFont.h"
|
|
|
|
#include "include/core/SkImage.h"
|
|
|
|
#include "include/core/SkImageInfo.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkScalar.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkShader.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkTileMode.h"
|
|
|
|
#include "include/core/SkTypeface.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
#include "include/effects/SkGradientShader.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/utils/SkTextUtils.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "tools/Resources.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ToolUtils.h"
|
2009-06-22 02:17:34 +00:00
|
|
|
|
2019-05-01 21:28:53 +00:00
|
|
|
#include <functional>
|
2018-02-16 17:40:18 +00:00
|
|
|
|
2014-02-17 21:21:46 +00:00
|
|
|
static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
|
|
|
|
bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
|
2012-12-06 21:47:40 +00:00
|
|
|
bm->eraseColor(SK_ColorTRANSPARENT);
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
SkCanvas canvas(*bm);
|
|
|
|
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} };
|
|
|
|
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
|
|
|
|
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
|
|
|
|
SkPaint paint;
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
paint.setDither(true);
|
2016-03-13 21:13:58 +00:00
|
|
|
paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, SK_ARRAY_COUNT(colors),
|
2019-04-03 14:27:45 +00:00
|
|
|
SkTileMode::kClamp));
|
2009-06-22 02:17:34 +00:00
|
|
|
canvas.drawPaint(paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
|
2019-04-03 14:27:45 +00:00
|
|
|
SkTileMode tmx, SkTileMode tmy) {
|
2019-04-08 17:20:23 +00:00
|
|
|
paint->setShader(bm.makeShader(tmx, tmy));
|
2015-03-16 17:08:34 +00:00
|
|
|
paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
|
2009-06-22 02:17:34 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 18:24:54 +00:00
|
|
|
constexpr SkColorType gColorTypes[] = {
|
2014-04-11 17:15:40 +00:00
|
|
|
kN32_SkColorType,
|
2014-02-17 21:21:46 +00:00
|
|
|
kRGB_565_SkColorType,
|
2009-06-22 02:17:34 +00:00
|
|
|
};
|
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
class TilingGM : public skiagm::GM {
|
2009-06-22 02:17:34 +00:00
|
|
|
public:
|
2013-07-25 17:52:32 +00:00
|
|
|
TilingGM(bool powerOfTwoSize)
|
2013-08-30 12:41:42 +00:00
|
|
|
: fPowerOfTwoSize(powerOfTwoSize) {
|
2009-06-22 02:17:34 +00:00
|
|
|
}
|
|
|
|
|
2014-02-17 21:21:46 +00:00
|
|
|
SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
protected:
|
2013-07-25 17:52:32 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kPOTSize = 32,
|
|
|
|
kNPOTSize = 21,
|
|
|
|
};
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkString onShortName() override {
|
2013-07-25 17:52:32 +00:00
|
|
|
SkString name("tilemodes");
|
|
|
|
if (!fPowerOfTwoSize) {
|
|
|
|
name.append("_npot");
|
|
|
|
}
|
|
|
|
return name;
|
2009-06-22 02:17:34 +00:00
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize onISize() override { return SkISize::Make(880, 560); }
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onOnceBeforeDraw() override {
|
2013-07-25 17:52:32 +00:00
|
|
|
int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
|
2014-02-17 21:21:46 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
|
|
|
|
makebm(&fTexture[i], gColorTypes[i], size, size);
|
2012-11-27 15:15:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2019-01-08 14:38:02 +00:00
|
|
|
SkPaint textPaint;
|
2019-03-20 16:12:10 +00:00
|
|
|
SkFont font(ToolUtils::create_portable_typeface(), 12);
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2013-07-25 17:52:32 +00:00
|
|
|
int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
|
|
|
|
|
|
|
|
SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
|
2009-06-22 02:17:34 +00:00
|
|
|
|
2016-09-01 18:24:54 +00:00
|
|
|
const char* gConfigNames[] = { "8888", "565", "4444" };
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2016-09-01 18:24:54 +00:00
|
|
|
constexpr bool gFilters[] = { false, true };
|
|
|
|
static const char* gFilterNames[] = { "point", "bilinear" };
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
constexpr SkTileMode gModes[] = {
|
|
|
|
SkTileMode::kClamp, SkTileMode::kRepeat, SkTileMode::kMirror };
|
2016-09-01 18:24:54 +00:00
|
|
|
static const char* gModeNames[] = { "C", "R", "M" };
|
2009-06-22 02:17:34 +00:00
|
|
|
|
|
|
|
SkScalar y = SkIntToScalar(24);
|
|
|
|
SkScalar x = SkIntToScalar(10);
|
|
|
|
|
|
|
|
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
|
|
|
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
|
|
|
SkPaint p;
|
|
|
|
p.setDither(true);
|
2018-12-24 04:19:14 +00:00
|
|
|
SkString str;
|
2019-03-20 16:12:10 +00:00
|
|
|
SkFont font(ToolUtils::create_portable_typeface());
|
2009-06-22 02:17:34 +00:00
|
|
|
str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
|
|
|
|
|
2018-12-24 04:19:14 +00:00
|
|
|
SkTextUtils::DrawString(canvas, str.c_str(), x + r.width()/2, y, font, p,
|
2018-10-30 16:53:21 +00:00
|
|
|
SkTextUtils::kCenter_Align);
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
x += r.width() * 4 / 3;
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
y += SkIntToScalar(16);
|
|
|
|
|
2014-02-17 21:21:46 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
|
2009-06-22 02:17:34 +00:00
|
|
|
for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
|
|
|
|
x = SkIntToScalar(10);
|
|
|
|
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
|
|
|
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
|
|
|
SkPaint paint;
|
2013-08-06 20:47:52 +00:00
|
|
|
#if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue
|
|
|
|
// on SGX where resizing NPOT textures to POT textures exhibits a driver bug.
|
|
|
|
if (!fPowerOfTwoSize) {
|
2014-02-17 21:21:46 +00:00
|
|
|
makebm(&fTexture[i], gColorTypes[i], size, size);
|
2013-08-06 20:47:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-06-22 02:17:34 +00:00
|
|
|
setup(&paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]);
|
|
|
|
paint.setDither(true);
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
canvas->save();
|
|
|
|
canvas->translate(x, y);
|
|
|
|
canvas->drawRect(r, paint);
|
|
|
|
canvas->restore();
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
x += r.width() * 4 / 3;
|
|
|
|
}
|
|
|
|
}
|
2019-01-08 14:38:02 +00:00
|
|
|
canvas->drawString(SkStringPrintf("%s, %s", gConfigNames[i], gFilterNames[j]),
|
|
|
|
x, y + r.height() * 2 / 3, font, textPaint);
|
2009-06-22 02:17:34 +00:00
|
|
|
|
|
|
|
y += r.height() * 4 / 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 18:19:56 +00:00
|
|
|
|
2009-06-22 02:17:34 +00:00
|
|
|
private:
|
2013-07-25 17:52:32 +00:00
|
|
|
bool fPowerOfTwoSize;
|
2012-10-18 02:01:59 +00:00
|
|
|
typedef skiagm::GM INHERITED;
|
2009-06-22 02:17:34 +00:00
|
|
|
};
|
2018-02-16 17:40:18 +00:00
|
|
|
DEF_GM( return new TilingGM(true); )
|
|
|
|
DEF_GM( return new TilingGM(false); )
|
2009-06-22 02:17:34 +00:00
|
|
|
|
2016-09-01 18:24:54 +00:00
|
|
|
constexpr int gWidth = 32;
|
|
|
|
constexpr int gHeight = 32;
|
2013-07-25 17:52:32 +00:00
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
static sk_sp<SkShader> make_bm(SkTileMode tx, SkTileMode ty) {
|
2012-10-18 02:01:59 +00:00
|
|
|
SkBitmap bm;
|
2014-04-11 17:15:40 +00:00
|
|
|
makebm(&bm, kN32_SkColorType, gWidth, gHeight);
|
2019-04-08 17:20:23 +00:00
|
|
|
return bm.makeShader(tx, ty);
|
2012-10-18 02:01:59 +00:00
|
|
|
}
|
2009-06-22 02:17:34 +00:00
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
static sk_sp<SkShader> make_grad(SkTileMode tx, SkTileMode ty) {
|
2012-10-18 02:01:59 +00:00
|
|
|
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
|
|
|
|
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
|
|
|
|
SkScalar rad = SkIntToScalar(gWidth)/2;
|
2019-03-20 16:12:10 +00:00
|
|
|
SkColor colors[] = {0xFFFF0000, ToolUtils::color_to_565(0xFF0044FF)};
|
2012-10-18 02:01:59 +00:00
|
|
|
|
|
|
|
int index = (int)ty;
|
|
|
|
switch (index % 3) {
|
|
|
|
case 0:
|
2016-03-13 21:13:58 +00:00
|
|
|
return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
|
2012-10-18 02:01:59 +00:00
|
|
|
case 1:
|
2016-03-13 21:13:58 +00:00
|
|
|
return SkGradientShader::MakeRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
|
2012-10-18 02:01:59 +00:00
|
|
|
case 2:
|
2017-08-01 20:38:08 +00:00
|
|
|
return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr,
|
|
|
|
SK_ARRAY_COUNT(colors), tx, 135, 225, 0, nullptr);
|
2012-10-18 02:01:59 +00:00
|
|
|
}
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2012-10-18 02:01:59 +00:00
|
|
|
}
|
2009-06-22 02:17:34 +00:00
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
typedef sk_sp<SkShader> (*ShaderProc)(SkTileMode, SkTileMode);
|
2012-10-18 02:01:59 +00:00
|
|
|
|
|
|
|
class Tiling2GM : public skiagm::GM {
|
|
|
|
ShaderProc fProc;
|
|
|
|
SkString fName;
|
|
|
|
public:
|
|
|
|
Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) {
|
|
|
|
fName.printf("tilemode_%s", name);
|
|
|
|
}
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
protected:
|
2014-04-30 13:20:45 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkString onShortName() override {
|
2012-10-18 02:01:59 +00:00
|
|
|
return fName;
|
|
|
|
}
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2016-04-11 14:46:38 +00:00
|
|
|
SkISize onISize() override { return SkISize::Make(650, 610); }
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2012-10-18 02:01:59 +00:00
|
|
|
canvas->scale(SkIntToScalar(3)/2, SkIntToScalar(3)/2);
|
|
|
|
|
|
|
|
const SkScalar w = SkIntToScalar(gWidth);
|
|
|
|
const SkScalar h = SkIntToScalar(gHeight);
|
|
|
|
SkRect r = { -w, -h, w*2, h*2 };
|
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
constexpr SkTileMode gModes[] = {
|
|
|
|
SkTileMode::kClamp, SkTileMode::kRepeat, SkTileMode::kMirror
|
2012-10-18 02:01:59 +00:00
|
|
|
};
|
2016-09-01 18:24:54 +00:00
|
|
|
const char* gModeNames[] = {
|
2012-10-18 02:01:59 +00:00
|
|
|
"Clamp", "Repeat", "Mirror"
|
|
|
|
};
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
SkScalar y = SkIntToScalar(24);
|
|
|
|
SkScalar x = SkIntToScalar(66);
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2019-03-20 16:12:10 +00:00
|
|
|
SkFont font(ToolUtils::create_portable_typeface());
|
2012-10-18 02:01:59 +00:00
|
|
|
|
|
|
|
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
|
|
|
SkString str(gModeNames[kx]);
|
2018-12-24 04:19:14 +00:00
|
|
|
SkTextUtils::DrawString(canvas, str.c_str(), x + r.width()/2, y, font, SkPaint(),
|
|
|
|
SkTextUtils::kCenter_Align);
|
2012-10-18 02:01:59 +00:00
|
|
|
x += r.width() * 4 / 3;
|
|
|
|
}
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
y += SkIntToScalar(16) + h;
|
|
|
|
|
|
|
|
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
|
|
|
x = SkIntToScalar(16) + w;
|
|
|
|
|
|
|
|
SkString str(gModeNames[ky]);
|
2018-12-24 04:19:14 +00:00
|
|
|
SkTextUtils::DrawString(canvas, str.c_str(), x, y + h/2, font, SkPaint(),
|
|
|
|
SkTextUtils::kRight_Align);
|
2012-10-18 02:01:59 +00:00
|
|
|
|
|
|
|
x += SkIntToScalar(50);
|
|
|
|
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
|
|
|
SkPaint paint;
|
2016-03-13 21:13:58 +00:00
|
|
|
paint.setShader(fProc(gModes[kx], gModes[ky]));
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
canvas->save();
|
|
|
|
canvas->translate(x, y);
|
|
|
|
canvas->drawRect(r, paint);
|
|
|
|
canvas->restore();
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
x += r.width() * 4 / 3;
|
|
|
|
}
|
|
|
|
y += r.height() * 4 / 3;
|
|
|
|
}
|
|
|
|
}
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 02:01:59 +00:00
|
|
|
private:
|
|
|
|
typedef skiagm::GM INHERITED;
|
|
|
|
};
|
2013-02-22 17:28:16 +00:00
|
|
|
DEF_GM( return new Tiling2GM(make_bm, "bitmap"); )
|
|
|
|
DEF_GM( return new Tiling2GM(make_grad, "gradient"); )
|
2018-02-16 17:40:18 +00:00
|
|
|
|
|
|
|
////////////////////
|
|
|
|
|
2018-12-17 14:50:51 +00:00
|
|
|
DEF_SIMPLE_GM(tilemode_decal, canvas, 720, 1100) {
|
2018-02-16 17:40:18 +00:00
|
|
|
auto img = GetResourceAsImage("images/mandrill_128.png");
|
|
|
|
SkPaint bgpaint;
|
|
|
|
bgpaint.setColor(SK_ColorYELLOW);
|
|
|
|
|
|
|
|
SkRect r = { -20, -20, img->width() + 20.0f, img->height() + 20.0f };
|
2018-12-17 14:50:51 +00:00
|
|
|
canvas->translate(45, 45);
|
2018-02-16 17:40:18 +00:00
|
|
|
|
2019-04-03 14:27:45 +00:00
|
|
|
std::function<void(SkPaint*, SkTileMode, SkTileMode)> shader_procs[] = {
|
|
|
|
[img](SkPaint* paint, SkTileMode tx, SkTileMode ty) {
|
2018-12-17 14:50:51 +00:00
|
|
|
// Test no filtering with decal mode
|
2018-02-16 17:40:18 +00:00
|
|
|
paint->setShader(img->makeShader(tx, ty));
|
2018-12-17 14:50:51 +00:00
|
|
|
paint->setFilterQuality(kNone_SkFilterQuality);
|
|
|
|
},
|
2019-04-03 14:27:45 +00:00
|
|
|
[img](SkPaint* paint, SkTileMode tx, SkTileMode ty) {
|
2018-12-17 14:50:51 +00:00
|
|
|
// Test bilerp approximation for decal mode (or clamp to border HW)
|
|
|
|
paint->setShader(img->makeShader(tx, ty));
|
|
|
|
paint->setFilterQuality(kLow_SkFilterQuality);
|
|
|
|
},
|
2019-04-03 14:27:45 +00:00
|
|
|
[img](SkPaint* paint, SkTileMode tx, SkTileMode ty) {
|
2018-12-17 14:50:51 +00:00
|
|
|
// Test bicubic filter with decal mode
|
|
|
|
paint->setShader(img->makeShader(tx, ty));
|
|
|
|
paint->setFilterQuality(kHigh_SkFilterQuality);
|
2018-02-16 17:40:18 +00:00
|
|
|
},
|
2019-04-03 14:27:45 +00:00
|
|
|
[img](SkPaint* paint, SkTileMode tx, SkTileMode ty) {
|
2018-02-16 17:40:18 +00:00
|
|
|
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
|
|
|
|
const SkPoint pts[] = {{ 0, 0 }, {img->width()*1.0f, img->height()*1.0f }};
|
|
|
|
const SkScalar* pos = nullptr;
|
|
|
|
const int count = SK_ARRAY_COUNT(colors);
|
|
|
|
paint->setShader(SkGradientShader::MakeLinear(pts, colors, pos, count, tx));
|
|
|
|
},
|
2019-04-03 14:27:45 +00:00
|
|
|
[img](SkPaint* paint, SkTileMode tx, SkTileMode ty) {
|
2018-02-16 17:40:18 +00:00
|
|
|
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
|
|
|
|
const SkScalar* pos = nullptr;
|
|
|
|
const int count = SK_ARRAY_COUNT(colors);
|
|
|
|
paint->setShader(SkGradientShader::MakeRadial({ img->width()*0.5f, img->width()*0.5f },
|
|
|
|
img->width()*0.5f, colors, pos, count, tx));
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct XY {
|
2019-04-03 14:27:45 +00:00
|
|
|
SkTileMode fX;
|
|
|
|
SkTileMode fY;
|
2018-02-16 17:40:18 +00:00
|
|
|
} pairs[] = {
|
2019-04-03 14:27:45 +00:00
|
|
|
{ SkTileMode::kClamp, SkTileMode::kClamp },
|
|
|
|
{ SkTileMode::kClamp, SkTileMode::kDecal },
|
|
|
|
{ SkTileMode::kDecal, SkTileMode::kClamp },
|
|
|
|
{ SkTileMode::kDecal, SkTileMode::kDecal },
|
2018-02-16 17:40:18 +00:00
|
|
|
};
|
|
|
|
for (const auto& p : pairs) {
|
|
|
|
SkPaint paint;
|
|
|
|
canvas->save();
|
|
|
|
for (const auto& proc : shader_procs) {
|
2018-12-17 14:50:51 +00:00
|
|
|
canvas->save();
|
|
|
|
// Apply a slight rotation to highlight the differences between filtered and unfiltered
|
|
|
|
// decal edges
|
|
|
|
canvas->rotate(4);
|
2018-02-16 17:40:18 +00:00
|
|
|
canvas->drawRect(r, bgpaint);
|
|
|
|
proc(&paint, p.fX, p.fY);
|
|
|
|
canvas->drawRect(r, paint);
|
2018-12-17 14:50:51 +00:00
|
|
|
canvas->restore();
|
2018-02-16 17:40:18 +00:00
|
|
|
canvas->translate(0, r.height() + 20);
|
|
|
|
}
|
|
|
|
canvas->restore();
|
|
|
|
canvas->translate(r.width() + 10, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|