aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-01-27 14:15:54 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 19:53:18 +0000
commit91af72703830f3946c538b47c6c7c96afc0adde2 (patch)
treef478faca5f38782c9178ca51068ff4fc827f35d3 /include
parentfe8225802d2ab0dbc6f0d40f9666ebca1b4e2a4a (diff)
Add geometric version of spot shadow
BUG=skia:6119 Change-Id: Ib9770bd88f4eebd68f2d893c5788f966d89f193c Reviewed-on: https://skia-review.googlesource.com/7585 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'include')
-rwxr-xr-xinclude/gpu/effects/GrBlurredEdgeFragmentProcessor.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h b/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h
new file mode 100755
index 0000000000..2e52485791
--- /dev/null
+++ b/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrBlurredEdgeFragmentProcessor_DEFINED
+#define GrBlurredEdgeFragmentProcessor_DEFINED
+
+#include "GrFragmentProcessor.h"
+
+/**
+ * Shader for managing a blurred edge for a shadow.
+ *
+ * There are two blurring modes supported: Gaussian blur function and smoothstep function.
+ *
+ * If the primitive supports an implicit distance to the edge, the radius of the blur is specified
+ * by r & g values of the color in 14.2 fixed point. For spot shadows, we increase the stroke width
+ * to set the shadow against the shape. This pad is specified by b, also in 6.2 fixed point.
+ *
+ * When not using implicit distance, then b in the input color represents the input to the
+ * blur function.
+ *
+ * In either case, the a value represents the max final alpha.
+ */
+class GrBlurredEdgeFP : public GrFragmentProcessor {
+public:
+ enum Mode {
+ kGaussian_Mode,
+ kSmoothstep_Mode,
+
+ kLastMode = kSmoothstep_Mode
+ };
+ static const int kModeCnt = kLastMode + 1;
+
+ static sk_sp<GrFragmentProcessor> Make(Mode mode = kGaussian_Mode) {
+ return sk_sp<GrFragmentProcessor>(new GrBlurredEdgeFP(mode));
+ }
+
+ const char* name() const override { return "BlurredEdge"; }
+
+ Mode mode() const { return fMode; }
+
+private:
+ GrBlurredEdgeFP(Mode mode)
+ : INHERITED(kNone_OptimizationFlags)
+ , fMode(mode) {
+ // enable output of distance information for shape
+ this->setWillUseDistanceVectorField();
+
+ this->initClassID<GrBlurredEdgeFP>();
+ }
+
+ GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
+
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
+
+ bool onIsEqual(const GrFragmentProcessor&) const override;
+
+ void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ Mode fMode;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif