2pt conical stage for focal-pt-on-edge case
When the focal point is on the edge of the end circle, the quadratic
equation devolves to linear. Add a stage to handle this case.
As a complication, this case can produce "degenerate" values:
1) t == NaN
2) R(t) < 0
For these, we're supposed to draw transparent black - which means
overwriting the color from the gradient stage. To support this, build
a 0/1 vector mask in the context, and apply it post-gradient-stage.
Change-Id: Ice4e3243abfd8c784bb810f6c310aed7a4ac7dc8
Reviewed-on: https://skia-review.googlesource.com/21111
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 9d4a250..40da694 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -375,8 +375,9 @@
return false;
}
- SkRasterPipeline_<256> subclass;
- if (!this->adjustMatrixAndAppendStages(alloc, &matrix, &subclass)) {
+ SkRasterPipeline_<256> tPipeline;
+ SkRasterPipeline_<256> postPipeline;
+ if (!this->adjustMatrixAndAppendStages(alloc, &matrix, &tPipeline, &postPipeline)) {
return this->INHERITED::onAppendStages(p, dstCS, alloc, ctm, paint, localM);
}
@@ -390,7 +391,7 @@
p->append(SkRasterPipeline::matrix_perspective, m);
}
- p->extend(subclass);
+ p->extend(tPipeline);
switch(fTileMode) {
case kMirror_TileMode: p->append(SkRasterPipeline::mirror_x_1); break;
@@ -496,6 +497,8 @@
p->append(SkRasterPipeline::premul);
}
+ p->extend(postPipeline);
+
return true;
}