Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: src/effects/GrCircleBlurFragmentProcessor.h

Issue 1311583005: Add special case circle blur for Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no-GPU build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMaskFilter.cpp ('k') | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/GrCircleBlurFragmentProcessor.h
diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..4d39ec8e11f661c76f09a028b51e5d6e7151bc3e
--- /dev/null
+++ b/src/effects/GrCircleBlurFragmentProcessor.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 GrCircleBlurFragmentProcessor_DEFINED
+#define GrCircleBlurFragmentProcessor_DEFINED
+
+#include "SkTypes.h"
+
+#if SK_SUPPORT_GPU
+
+#include "GrFragmentProcessor.h"
+#include "GrProcessorUnitTest.h"
+
+class GrTextureProvider;
+
+// This FP handles the special case of a blurred circle. It uses a 1D
+// profile that is just rotated about the origin of the circle.
+class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
+public:
+ ~GrCircleBlurFragmentProcessor() override {};
+
+ const char* name() const override { return "CircleBlur"; }
+
+ static const GrFragmentProcessor* Create(GrTextureProvider*textureProvider,
+ const SkRect& circle, float sigma) {
+ float offset;
+
+ SkAutoTUnref<GrTexture> blurProfile(CreateCircleBlurProfileTexture(textureProvider,
+ circle,
+ sigma,
+ &offset));
+ if (!blurProfile) {
+ return nullptr;
+ }
+ return new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile);
+ }
+
+ const SkRect& circle() const { return fCircle; }
+ float sigma() const { return fSigma; }
+ float offset() const { return fOffset; }
+ int profileSize() const { return fBlurProfileAccess.getTexture()->width(); }
+
+private:
+ GrCircleBlurFragmentProcessor(const SkRect& circle, float sigma,
+ float offset, GrTexture* blurProfile);
+
+ GrGLFragmentProcessor* onCreateGLInstance() const override;
+
+ void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+
+ bool onIsEqual(const GrFragmentProcessor& other) const override {
+ const GrCircleBlurFragmentProcessor& cbfp = other.cast<GrCircleBlurFragmentProcessor>();
+ // fOffset is computed from the circle width and the sigma
+ return this->circle().width() == cbfp.circle().width() && fSigma == cbfp.fSigma;
+ }
+
+ void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
+
+ static GrTexture* CreateCircleBlurProfileTexture(GrTextureProvider*,
+ const SkRect& circle,
+ float sigma, float* offset);
+
+ SkRect fCircle;
+ float fSigma;
+ float fOffset;
+ GrTextureAccess fBlurProfileAccess;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif
+#endif
« no previous file with comments | « src/core/SkMaskFilter.cpp ('k') | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698