aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-07-19 10:16:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-19 17:13:44 +0000
commit2f924b4b0e5d364d608e181da8270241038de6c9 (patch)
tree76798f96ce554d809aa57e943611d0788be1a014 /src
parent0c15ae82f0d5b5356f7650b78d749c09b3bc0403 (diff)
Use raster pipeline for repeat/mirror radial gradients
The legacy clamp specialization is still faster, but for repeat and mirror RP wins (at low color stop counts). Change-Id: Ifef3eb5b3111b3741d3a033310a4cdb58e592247 Reviewed-on: https://skia-review.googlesource.com/24283 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/shaders/gradients/SkRadialGradient.cpp15
-rw-r--r--src/shaders/gradients/SkRadialGradient.h6
2 files changed, 18 insertions, 3 deletions
diff --git a/src/shaders/gradients/SkRadialGradient.cpp b/src/shaders/gradients/SkRadialGradient.cpp
index 0a6a940b18..658ee55d3a 100644
--- a/src/shaders/gradients/SkRadialGradient.cpp
+++ b/src/shaders/gradients/SkRadialGradient.cpp
@@ -48,7 +48,11 @@ SkShaderBase::Context* SkRadialGradient::onMakeContext(
SkRadialGradient::RadialGradientContext::RadialGradientContext(
const SkRadialGradient& shader, const ContextRec& rec)
- : INHERITED(shader, rec) {}
+ : INHERITED(shader, rec) {
+#ifndef SK_SUPPORT_LEGACY_RADIAL_GRADIENT
+ SkASSERT(shader.getTileMode() == SkShader::kClamp_TileMode);
+#endif
+}
SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const {
if (info) {
@@ -359,6 +363,15 @@ sk_sp<SkShader> SkRadialGradient::onMakeColorSpace(SkColorSpaceXformer* xformer)
&this->getLocalMatrix());
}
+bool SkRadialGradient::onIsRasterPipelineOnly() const {
+#ifdef SK_SUPPORT_LEGACY_RADIAL_GRADIENT
+ return false;
+#else
+ // We have a clamp fast path; everything else -> RP.
+ return fTileMode != SkShader::kClamp_TileMode;
+#endif
+}
+
bool SkRadialGradient::adjustMatrixAndAppendStages(SkArenaAlloc* alloc,
SkMatrix* matrix,
SkRasterPipeline* p,
diff --git a/src/shaders/gradients/SkRadialGradient.h b/src/shaders/gradients/SkRadialGradient.h
index c0353cf153..f85bc8e53a 100644
--- a/src/shaders/gradients/SkRadialGradient.h
+++ b/src/shaders/gradients/SkRadialGradient.h
@@ -10,7 +10,7 @@
#include "SkGradientShaderPriv.h"
-class SkRadialGradient : public SkGradientShaderBase {
+class SkRadialGradient final : public SkGradientShaderBase {
public:
SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&);
@@ -41,7 +41,9 @@ protected:
bool adjustMatrixAndAppendStages(SkArenaAlloc* alloc,
SkMatrix* matrix,
SkRasterPipeline* tPipeline,
- SkRasterPipeline* postPipeline) const final;
+ SkRasterPipeline* postPipeline) const override;
+
+ bool onIsRasterPipelineOnly() const override;
private:
const SkPoint fCenter;