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

Side by Side Diff: src/effects/GrCircleBlurFragmentProcessor.h

Issue 2242973002: Improvements for circluar blurs in GPU backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix double to float conversion on windows Created 4 years, 4 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 | « no previous file | 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
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrCircleBlurFragmentProcessor_DEFINED 8 #ifndef GrCircleBlurFragmentProcessor_DEFINED
9 #define GrCircleBlurFragmentProcessor_DEFINED 9 #define GrCircleBlurFragmentProcessor_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 // This FP handles the special case of a blurred circle. It uses a 1D 21 // This FP handles the special case of a blurred circle. It uses a 1D
22 // profile that is just rotated about the origin of the circle. 22 // profile that is just rotated about the origin of the circle.
23 class GrCircleBlurFragmentProcessor : public GrFragmentProcessor { 23 class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
24 public: 24 public:
25 ~GrCircleBlurFragmentProcessor() override {}; 25 ~GrCircleBlurFragmentProcessor() override {};
26 26
27 const char* name() const override { return "CircleBlur"; } 27 const char* name() const override { return "CircleBlur"; }
28 28
29 SkString dumpInfo() const override { 29 SkString dumpInfo() const override {
30 SkString str; 30 SkString str;
31 str.appendf("Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], Sigma %.2f, soli dR: %.2f, " 31 str.appendf("Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], solidR: %.2f, te xtureR: %.2f",
32 "textureR: %.2f",
33 fCircle.fLeft, fCircle.fTop, fCircle.fRight, fCircle.fBottom , 32 fCircle.fLeft, fCircle.fTop, fCircle.fRight, fCircle.fBottom ,
34 fSigma, fSolidRadius, fTextureRadius); 33 fSolidRadius, fTextureRadius);
35 return str; 34 return str;
36 } 35 }
37 36
38 static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*textureProvider, 37 static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*textureProvider,
39 const SkRect& circle, float sigma) { 38 const SkRect& circle, float sigma);
40 float solidRadius;
41 float textureRadius;
42
43 SkAutoTUnref<GrTexture> profile(CreateCircleBlurProfileTexture(texturePr ovider,
44 circle,
45 sigma,
46 &solidRad ius,
47 &textureR adius));
48 if (!profile) {
49 return nullptr;
50 }
51 return sk_sp<GrFragmentProcessor>(
52 new GrCircleBlurFragmentProcessor(circle, sigma, solidRadius, textur eRadius, profile));
53 }
54 39
55 private: 40 private:
56 // This nested GLSL processor implementation is defined in the cpp file. 41 // This nested GLSL processor implementation is defined in the cpp file.
57 class GLSLProcessor; 42 class GLSLProcessor;
58 43
59 /** 44 /**
60 * Creates a profile texture for the circle and sigma. The texture will have a height of 1. 45 * Creates a profile texture for the circle and sigma. The texture will have a height of 1.
61 * The x texture coord should map from 0 to 1 across the radius range of sol idRadius to 46 * The x texture coord should map from 0 to 1 across the radius range of sol idRadius to
62 * solidRadius + textureRadius. 47 * solidRadius + textureRadius.
63 */ 48 */
64 GrCircleBlurFragmentProcessor(const SkRect& circle, float sigma, 49 GrCircleBlurFragmentProcessor(const SkRect& circle, float textureRadius, flo at innerRadius,
65 float solidRadius, float textureRadius, GrText ure* blurProfile); 50 GrTexture* blurProfile);
66 51
67 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 52 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
68 53
69 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; 54 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
70 55
71 bool onIsEqual(const GrFragmentProcessor& other) const override { 56 bool onIsEqual(const GrFragmentProcessor& other) const override {
72 const GrCircleBlurFragmentProcessor& cbfp = other.cast<GrCircleBlurFragm entProcessor>(); 57 const GrCircleBlurFragmentProcessor& cbfp = other.cast<GrCircleBlurFragm entProcessor>();
73 // fOffset is computed from the circle width and the sigma 58 return fCircle == cbfp.fCircle && fSolidRadius == cbfp.fSolidRadius &&
74 return this->fCircle == cbfp.fCircle && fSigma == cbfp.fSigma; 59 fTextureRadius == cbfp.fTextureRadius;
75 } 60 }
76 61
77 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 62 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
78 63
79 static GrTexture* CreateCircleBlurProfileTexture(GrTextureProvider*,
80 const SkRect& circle,
81 float sigma,
82 float* solidRadius,
83 float* textureRadius);
84
85 SkRect fCircle; 64 SkRect fCircle;
86 float fSigma; 65 SkScalar fSolidRadius;
87 float fSolidRadius;
88 float fTextureRadius; 66 float fTextureRadius;
89 GrTextureAccess fBlurProfileAccess; 67 GrTextureAccess fBlurProfileAccess;
90 68
91 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 69 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
92 70
93 typedef GrFragmentProcessor INHERITED; 71 typedef GrFragmentProcessor INHERITED;
94 }; 72 };
95 73
96 #endif 74 #endif
97 #endif 75 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698