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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/core/SkMaskFilter.cpp ('k') | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrCircleBlurFragmentProcessor_DEFINED
9 #define GrCircleBlurFragmentProcessor_DEFINED
10
11 #include "SkTypes.h"
12
13 #if SK_SUPPORT_GPU
14
15 #include "GrFragmentProcessor.h"
16 #include "GrProcessorUnitTest.h"
17
18 class GrTextureProvider;
19
20 // This FP handles the special case of a blurred circle. It uses a 1D
21 // profile that is just rotated about the origin of the circle.
22 class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
23 public:
24 ~GrCircleBlurFragmentProcessor() override {};
25
26 const char* name() const override { return "CircleBlur"; }
27
28 static const GrFragmentProcessor* Create(GrTextureProvider*textureProvider,
29 const SkRect& circle, float sigma) {
30 float offset;
31
32 SkAutoTUnref<GrTexture> blurProfile(CreateCircleBlurProfileTexture(textu reProvider,
33 circl e,
34 sigma ,
35 &offs et));
36 if (!blurProfile) {
37 return nullptr;
38 }
39 return new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProf ile);
40 }
41
42 const SkRect& circle() const { return fCircle; }
43 float sigma() const { return fSigma; }
44 float offset() const { return fOffset; }
45 int profileSize() const { return fBlurProfileAccess.getTexture()->width(); }
46
47 private:
48 GrCircleBlurFragmentProcessor(const SkRect& circle, float sigma,
49 float offset, GrTexture* blurProfile);
50
51 GrGLFragmentProcessor* onCreateGLInstance() const override;
52
53 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c onst override;
54
55 bool onIsEqual(const GrFragmentProcessor& other) const override {
56 const GrCircleBlurFragmentProcessor& cbfp = other.cast<GrCircleBlurFragm entProcessor>();
57 // fOffset is computed from the circle width and the sigma
58 return this->circle().width() == cbfp.circle().width() && fSigma == cbfp .fSigma;
59 }
60
61 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
62
63 static GrTexture* CreateCircleBlurProfileTexture(GrTextureProvider*,
64 const SkRect& circle,
65 float sigma, float* offset) ;
66
67 SkRect fCircle;
68 float fSigma;
69 float fOffset;
70 GrTextureAccess fBlurProfileAccess;
71
72 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
73
74 typedef GrFragmentProcessor INHERITED;
75 };
76
77 #endif
78 #endif
OLDNEW
« 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