Tighten up gradient clamp logic.
This is just a little refactor. Shouldn't change any logic or pixels. Change-Id: I782df78f2d693dc7e35c286b049730e763aa3dc8 Reviewed-on: https://skia-review.googlesource.com/15653 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
c2dd5ed937
commit
9bb75afed4
@ -92,21 +92,15 @@ bool SkLinearGradient::adjustMatrixAndAppendStages(SkArenaAlloc* alloc,
|
||||
SkVector dx = matrix->mapVector(1, 0);
|
||||
if (dx.fX >= 4) { return false; }
|
||||
|
||||
auto* limit = alloc->make<float>(1.0f);
|
||||
if (fColorCount == 2 && fOrigPos == nullptr) {
|
||||
switch (fTileMode) {
|
||||
case kClamp_TileMode: p->append(SkRasterPipeline::clamp_x, limit); break;
|
||||
case kMirror_TileMode: p->append(SkRasterPipeline::mirror_x, limit); break;
|
||||
case kRepeat_TileMode: p->append(SkRasterPipeline::repeat_x, limit); break;
|
||||
}
|
||||
} else {
|
||||
switch (fTileMode) {
|
||||
// The search strategy does not need clamping. It has implicit hard stops at the
|
||||
// first and last stop.
|
||||
case kClamp_TileMode: break;
|
||||
case kMirror_TileMode: p->append(SkRasterPipeline::mirror_x, limit); break;
|
||||
case kRepeat_TileMode: p->append(SkRasterPipeline::repeat_x, limit); break;
|
||||
}
|
||||
switch(fTileMode) {
|
||||
case kMirror_TileMode: p->append(SkRasterPipeline::mirror_x, alloc->make<float>(1)); break;
|
||||
case kRepeat_TileMode: p->append(SkRasterPipeline::repeat_x, alloc->make<float>(1)); break;
|
||||
case kClamp_TileMode:
|
||||
if (fColorCount == 2 && fOrigPos == nullptr) {
|
||||
// The general strategy does not need clamping due to implicit hard stops at 0 and 1,
|
||||
// but the 2-point specialization must be clamped.
|
||||
p->append(SkRasterPipeline::clamp_x, alloc->make<float>(1));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user