aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-20 17:20:24 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-21 16:02:31 +0000
commit54cbcd7056a1a56946f177059b1a5537f131271a (patch)
tree8b5e8185536940d4add8a107b14f5e5338754fee /src/gpu
parentc17dc24fa9994eacc640d3adc6633a02fd96d3fc (diff)
Remove all headers from include/gpu/effects
TBR=bsalomon@google.com Change-Id: I9ad2fa41262693b3a83bef625eac332eb1e71a3d Reviewed-on: https://skia-review.googlesource.com/13988 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.h68
-rw-r--r--src/gpu/effects/GrConstColorProcessor.h78
-rw-r--r--src/gpu/effects/GrXfermodeFragmentProcessor.cpp4
-rw-r--r--src/gpu/effects/GrXfermodeFragmentProcessor.h35
4 files changed, 183 insertions, 2 deletions
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
new file mode 100644
index 0000000000..d0864ed864
--- /dev/null
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ * The a value represents the max final alpha.
+ *
+ * When not using implicit distance, then b in the input color represents the input to the
+ * blur function, and r 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;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ Mode fMode;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif
diff --git a/src/gpu/effects/GrConstColorProcessor.h b/src/gpu/effects/GrConstColorProcessor.h
new file mode 100644
index 0000000000..b543aa5069
--- /dev/null
+++ b/src/gpu/effects/GrConstColorProcessor.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrColorProcessor_DEFINED
+#define GrColorProcessor_DEFINED
+
+#include "GrFragmentProcessor.h"
+
+/**
+ * This is a simple GrFragmentProcessor that outputs a constant color. It may do one of the
+ * following with its input color: ignore it, or multiply it by the constant color, multiply its
+ * alpha by the constant color and ignore the input color's r, g, and b.
+ */
+class GrConstColorProcessor : public GrFragmentProcessor {
+public:
+ enum InputMode {
+ kIgnore_InputMode,
+ kModulateRGBA_InputMode,
+ kModulateA_InputMode,
+
+ kLastInputMode = kModulateA_InputMode
+ };
+ static const int kInputModeCnt = kLastInputMode + 1;
+
+ static sk_sp<GrFragmentProcessor> Make(GrColor4f color, InputMode mode) {
+ return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
+ }
+
+ const char* name() const override { return "Color"; }
+
+ SkString dumpInfo() const override {
+ SkString str;
+ str.appendf("Color: 0x%08x", fColor.toGrColor());
+ return str;
+ }
+
+ GrColor4f color() const { return fColor; }
+
+ InputMode inputMode() const { return fMode; }
+
+private:
+ static OptimizationFlags OptFlags(GrColor4f color, InputMode mode) {
+ OptimizationFlags flags = kConstantOutputForConstantInput_OptimizationFlag;
+ if (mode != kIgnore_InputMode) {
+ flags |= kCompatibleWithCoverageAsAlpha_OptimizationFlag;
+ }
+ if (color.isOpaque()) {
+ flags |= kPreservesOpaqueInput_OptimizationFlag;
+ }
+ return flags;
+ }
+
+ GrConstColorProcessor(GrColor4f color, InputMode mode)
+ : INHERITED(OptFlags(color, mode)), fColor(color), fMode(mode) {
+ this->initClassID<GrConstColorProcessor>();
+ }
+
+ GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
+
+ void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
+
+ bool onIsEqual(const GrFragmentProcessor&) const override;
+
+ GrColor4f constantOutputForConstantInput(GrColor4f input) const override;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ GrColor4f fColor;
+ InputMode fMode;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 9671919dec..30a9faaf08 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "effects/GrXfermodeFragmentProcessor.h"
+#include "GrXfermodeFragmentProcessor.h"
+#include "GrConstColorProcessor.h"
#include "GrFragmentProcessor.h"
-#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLBlend.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.h b/src/gpu/effects/GrXfermodeFragmentProcessor.h
new file mode 100644
index 0000000000..edc5ae71e1
--- /dev/null
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrXfermodeFragmentProcessor_DEFINED
+#define GrXfermodeFragmentProcessor_DEFINED
+
+#include "SkRefCnt.h"
+#include "SkBlendMode.h"
+
+class GrFragmentProcessor;
+
+namespace GrXfermodeFragmentProcessor {
+ /** The color input to the returned processor is treated as the src and the passed in processor
+ is the dst. */
+ sk_sp<GrFragmentProcessor> MakeFromDstProcessor(sk_sp<GrFragmentProcessor> dst,
+ SkBlendMode mode);
+
+ /** The color input to the returned processor is treated as the dst and the passed in processor
+ is the src. */
+ sk_sp<GrFragmentProcessor> MakeFromSrcProcessor(sk_sp<GrFragmentProcessor> src,
+ SkBlendMode mode);
+
+ /** Takes the input color, which is assumed to be unpremultiplied, passes it as an opaque color
+ to both src and dst. The outputs of a src and dst are blended using mode and the original
+ input's alpha is applied to the blended color to produce a premul output. */
+ sk_sp<GrFragmentProcessor> MakeFromTwoProcessors(sk_sp<GrFragmentProcessor> src,
+ sk_sp<GrFragmentProcessor> dst,
+ SkBlendMode mode);
+};
+
+#endif