aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-05-31 01:06:53 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-31 01:25:23 +0000
commit9d14f936cc09de2a37c05c7af2cf60aa31f74722 (patch)
tree887b766f9f271ffa5cdc79f682c09d4e0394fbcf /src/effects
parentb365cf590f87971b31bf71b6188da6c4268f2a91 (diff)
Revert "Delete SkGaussianEdgeShader"
This reverts commit 64790a3714467300848971aa153aca8cea91cf7b. Reason for revert: pending Android fix merge. Original change's description: > Delete SkGaussianEdgeShader > > No longer used. > > Change-Id: I65a61696060ca19f528066ea587e140798450e36 > Reviewed-on: https://skia-review.googlesource.com/18132 > Reviewed-by: Jim Van Verth <jvanverth@google.com> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=jvanverth@google.com,fmalita@chromium.org,reed@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I88a428e942c78b1fc8e70501ba7fdda5727b2ab2 Reviewed-on: https://skia-review.googlesource.com/18156 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkGaussianEdgeShader.cpp95
-rw-r--r--src/effects/SkGaussianEdgeShader.h27
2 files changed, 122 insertions, 0 deletions
diff --git a/src/effects/SkGaussianEdgeShader.cpp b/src/effects/SkGaussianEdgeShader.cpp
new file mode 100644
index 0000000000..c710b949d3
--- /dev/null
+++ b/src/effects/SkGaussianEdgeShader.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkGaussianEdgeShader.h"
+#include "SkReadBuffer.h"
+#include "SkWriteBuffer.h"
+
+class SkArenaAlloc;
+
+ /** \class SkGaussianEdgeShaderImpl
+ This subclass of shader applies a Gaussian to shadow edge
+
+ 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.
+ */
+class SkGaussianEdgeShaderImpl : public SkShaderBase {
+public:
+ SkGaussianEdgeShaderImpl() {}
+
+ bool isOpaque() const override;
+
+#if SK_SUPPORT_GPU
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+#endif
+
+ SK_TO_STRING_OVERRIDE()
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkGaussianEdgeShaderImpl)
+
+protected:
+ void flatten(SkWriteBuffer&) const override;
+ Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* storage) const override {
+ return nullptr;
+ }
+private:
+ friend class SkGaussianEdgeShader;
+
+ typedef SkShaderBase INHERITED;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+#if SK_SUPPORT_GPU
+
+#include "effects/GrBlurredEdgeFragmentProcessor.h"
+
+////////////////////////////////////////////////////////////////////////////
+
+sk_sp<GrFragmentProcessor> SkGaussianEdgeShaderImpl::asFragmentProcessor(const AsFPArgs&) const {
+ return GrBlurredEdgeFP::Make(GrBlurredEdgeFP::kGaussian_Mode);
+}
+
+#endif
+
+////////////////////////////////////////////////////////////////////////////
+
+bool SkGaussianEdgeShaderImpl::isOpaque() const {
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef SK_IGNORE_TO_STRING
+void SkGaussianEdgeShaderImpl::toString(SkString* str) const {
+ str->appendf("GaussianEdgeShader: ()");
+}
+#endif
+
+sk_sp<SkFlattenable> SkGaussianEdgeShaderImpl::CreateProc(SkReadBuffer& buf) {
+ return sk_make_sp<SkGaussianEdgeShaderImpl>();
+}
+
+void SkGaussianEdgeShaderImpl::flatten(SkWriteBuffer& buf) const {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+sk_sp<SkShader> SkGaussianEdgeShader::Make() {
+ return sk_make_sp<SkGaussianEdgeShaderImpl>();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkGaussianEdgeShader)
+SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkGaussianEdgeShaderImpl)
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
+
+///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkGaussianEdgeShader.h b/src/effects/SkGaussianEdgeShader.h
new file mode 100644
index 0000000000..f0554dd0a7
--- /dev/null
+++ b/src/effects/SkGaussianEdgeShader.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkGaussianEdgeShader_DEFINED
+#define SkGaussianEdgeShader_DEFINED
+
+#include "SkShaderBase.h"
+
+class SK_API SkGaussianEdgeShader {
+public:
+ /** Returns a shader that applies a Gaussian blur depending on distance to the edge
+ * Currently this is only useable with Circle and RRect shapes on the GPU backend.
+ * Raster will draw nothing.
+ */
+ static sk_sp<SkShader> Make();
+
+ SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
+
+private:
+ SkGaussianEdgeShader(); // can't be instantiated
+};
+
+#endif