GrGradientEffect::onIsEqual() must also consider tiling
Without this fix, the newly added GM draws incorrectly. Change-Id: Ic159ab3201c10369ad5f8151186245d8d076cc25 Reviewed-on: https://skia-review.googlesource.com/30484 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
121ad19a7e
commit
36f054ace3
@ -1072,3 +1072,49 @@ DEF_SIMPLE_GM(sweep_tiling, canvas, 690, 512) {
|
||||
canvas->translate(0, size * 1.1f);
|
||||
}
|
||||
}
|
||||
|
||||
// Exercises the special-case Ganesh gradient effects.
|
||||
DEF_SIMPLE_GM(gradients_interesting, canvas, 640, 1080) {
|
||||
static const SkColor colors2[] = { SK_ColorRED, SK_ColorBLUE };
|
||||
static const SkColor colors3[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorBLUE };
|
||||
static const SkColor colors4[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorYELLOW, SK_ColorBLUE };
|
||||
|
||||
static const SkScalar hardLeft[] = { 0, 0, 1 };
|
||||
static const SkScalar hardRight[] = { 0, 1, 1 };
|
||||
static const SkScalar hardCenter[] = { 0, .5f, .5f, 1 };
|
||||
|
||||
static const struct {
|
||||
const SkColor* colors;
|
||||
const SkScalar* pos;
|
||||
int count;
|
||||
} configs[] = {
|
||||
{ colors2, nullptr, 2 }, // kTwo_ColorType
|
||||
{ colors3, nullptr, 3 }, // kThree_ColorType
|
||||
{ colors3, hardLeft, 3 }, // kHardStopLeftEdged_ColorType
|
||||
{ colors3, hardRight, 3 }, // kHardStopRightEdged_ColorType
|
||||
{ colors4, hardCenter, 4 }, // kSingleHardStop_ColorType
|
||||
};
|
||||
|
||||
static const SkShader::TileMode modes[] = {
|
||||
SkShader::kClamp_TileMode,
|
||||
SkShader::kRepeat_TileMode,
|
||||
SkShader::kMirror_TileMode,
|
||||
};
|
||||
|
||||
static constexpr SkScalar size = 200;
|
||||
static const SkPoint pts[] = { { size / 3, size / 3 }, { size * 2 / 3, size * 2 / 3} };
|
||||
|
||||
SkPaint p;
|
||||
for (const auto& cfg : configs) {
|
||||
{
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
for (auto mode : modes) {
|
||||
p.setShader(SkGradientShader::MakeLinear(pts, cfg.colors, cfg.pos, cfg.count,
|
||||
mode));
|
||||
canvas->drawRect(SkRect::MakeWH(size, size), p);
|
||||
canvas->translate(size * 1.1f, 0);
|
||||
}
|
||||
}
|
||||
canvas->translate(0, size * 1.1f);
|
||||
}
|
||||
}
|
||||
|
@ -1906,7 +1906,7 @@ GrGradientEffect::~GrGradientEffect() {
|
||||
bool GrGradientEffect::onIsEqual(const GrFragmentProcessor& processor) const {
|
||||
const GrGradientEffect& ge = processor.cast<GrGradientEffect>();
|
||||
|
||||
if (this->fColorType != ge.getColorType()) {
|
||||
if (fTileMode != ge.fTileMode || fColorType != ge.getColorType()) {
|
||||
return false;
|
||||
}
|
||||
SkASSERT(this->useAtlas() == ge.useAtlas());
|
||||
|
Loading…
Reference in New Issue
Block a user