OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrOvalEffect.h" | 8 #include "GrOvalEffect.h" |
9 | 9 |
10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
11 #include "GrInvariantOutput.h" | 11 #include "GrInvariantOutput.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "gl/GrGLProcessor.h" | 13 #include "gl/GrGLProcessor.h" |
14 #include "gl/GrGLSL.h" | 14 #include "gl/GrGLSL.h" |
15 #include "gl/builders/GrGLProgramBuilder.h" | 15 #include "gl/builders/GrGLProgramBuilder.h" |
16 | 16 |
17 ////////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////////// |
18 | 18 |
19 class CircleEffect : public GrFragmentProcessor { | 19 class CircleEffect : public GrFragmentProcessor { |
20 public: | 20 public: |
21 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& cente
r, SkScalar radius); | 21 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& cente
r, SkScalar radius); |
22 | 22 |
23 virtual ~CircleEffect() {}; | 23 virtual ~CircleEffect() {}; |
24 | 24 |
25 virtual const char* name() const SK_OVERRIDE { return "Circle"; } | 25 const char* name() const SK_OVERRIDE { return "Circle"; } |
26 | 26 |
27 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 27 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
28 | 28 |
29 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 29 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
30 | 30 |
31 const SkPoint& getCenter() const { return fCenter; } | 31 const SkPoint& getCenter() const { return fCenter; } |
32 SkScalar getRadius() const { return fRadius; } | 32 SkScalar getRadius() const { return fRadius; } |
33 | 33 |
34 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 34 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
35 | 35 |
36 private: | 36 private: |
37 CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); | 37 CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); |
38 | 38 |
39 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 39 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
40 | 40 |
41 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 41 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
42 | 42 |
43 SkPoint fCenter; | 43 SkPoint fCenter; |
44 SkScalar fRadius; | 44 SkScalar fRadius; |
45 GrPrimitiveEdgeType fEdgeType; | 45 GrPrimitiveEdgeType fEdgeType; |
46 | 46 |
47 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 47 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
48 | 48 |
49 typedef GrFragmentProcessor INHERITED; | 49 typedef GrFragmentProcessor INHERITED; |
50 }; | 50 }; |
51 | 51 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 virtual void emitCode(GrGLFPBuilder* builder, | 100 virtual void emitCode(GrGLFPBuilder* builder, |
101 const GrFragmentProcessor& fp, | 101 const GrFragmentProcessor& fp, |
102 const char* outputColor, | 102 const char* outputColor, |
103 const char* inputColor, | 103 const char* inputColor, |
104 const TransformedCoordsArray&, | 104 const TransformedCoordsArray&, |
105 const TextureSamplerArray&) SK_OVERRIDE; | 105 const TextureSamplerArray&) SK_OVERRIDE; |
106 | 106 |
107 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 107 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
108 | 108 |
109 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 109 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
110 | 110 |
111 private: | 111 private: |
112 GrGLProgramDataManager::UniformHandle fCircleUniform; | 112 GrGLProgramDataManager::UniformHandle fCircleUniform; |
113 SkPoint fPrevCenter; | 113 SkPoint fPrevCenter; |
114 SkScalar fPrevRadius; | 114 SkScalar fPrevRadius; |
115 | 115 |
116 typedef GrGLFragmentProcessor INHERITED; | 116 typedef GrGLFragmentProcessor INHERITED; |
117 }; | 117 }; |
118 | 118 |
119 GLCircleEffect::GLCircleEffect(const GrProcessor&) { | 119 GLCircleEffect::GLCircleEffect(const GrProcessor&) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 ////////////////////////////////////////////////////////////////////////////// | 191 ////////////////////////////////////////////////////////////////////////////// |
192 | 192 |
193 class EllipseEffect : public GrFragmentProcessor { | 193 class EllipseEffect : public GrFragmentProcessor { |
194 public: | 194 public: |
195 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& cente
r, SkScalar rx, | 195 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& cente
r, SkScalar rx, |
196 SkScalar ry); | 196 SkScalar ry); |
197 | 197 |
198 virtual ~EllipseEffect() {}; | 198 virtual ~EllipseEffect() {}; |
199 | 199 |
200 virtual const char* name() const SK_OVERRIDE { return "Ellipse"; } | 200 const char* name() const SK_OVERRIDE { return "Ellipse"; } |
201 | 201 |
202 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 202 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
203 | 203 |
204 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 204 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
205 | 205 |
206 const SkPoint& getCenter() const { return fCenter; } | 206 const SkPoint& getCenter() const { return fCenter; } |
207 SkVector getRadii() const { return fRadii; } | 207 SkVector getRadii() const { return fRadii; } |
208 | 208 |
209 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 209 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
210 | 210 |
211 private: | 211 private: |
212 EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkSca
lar ry); | 212 EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkSca
lar ry); |
213 | 213 |
214 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 214 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
215 | 215 |
216 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 216 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
217 | 217 |
218 SkPoint fCenter; | 218 SkPoint fCenter; |
219 SkVector fRadii; | 219 SkVector fRadii; |
220 GrPrimitiveEdgeType fEdgeType; | 220 GrPrimitiveEdgeType fEdgeType; |
221 | 221 |
222 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 222 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
223 | 223 |
224 typedef GrFragmentProcessor INHERITED; | 224 typedef GrFragmentProcessor INHERITED; |
225 }; | 225 }; |
226 | 226 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 virtual void emitCode(GrGLFPBuilder* builder, | 278 virtual void emitCode(GrGLFPBuilder* builder, |
279 const GrFragmentProcessor& fp, | 279 const GrFragmentProcessor& fp, |
280 const char* outputColor, | 280 const char* outputColor, |
281 const char* inputColor, | 281 const char* inputColor, |
282 const TransformedCoordsArray&, | 282 const TransformedCoordsArray&, |
283 const TextureSamplerArray&) SK_OVERRIDE; | 283 const TextureSamplerArray&) SK_OVERRIDE; |
284 | 284 |
285 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 285 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
286 | 286 |
287 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 287 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
288 | 288 |
289 private: | 289 private: |
290 GrGLProgramDataManager::UniformHandle fEllipseUniform; | 290 GrGLProgramDataManager::UniformHandle fEllipseUniform; |
291 SkPoint fPrevCenter; | 291 SkPoint fPrevCenter; |
292 SkVector fPrevRadii; | 292 SkVector fPrevRadii; |
293 | 293 |
294 typedef GrGLFragmentProcessor INHERITED; | 294 typedef GrGLFragmentProcessor INHERITED; |
295 }; | 295 }; |
296 | 296 |
297 GLEllipseEffect::GLEllipseEffect(const GrProcessor& effect) { | 297 GLEllipseEffect::GLEllipseEffect(const GrProcessor& effect) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 w /= 2; | 387 w /= 2; |
388 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); | 388 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); |
389 } else { | 389 } else { |
390 w /= 2; | 390 w /= 2; |
391 h /= 2; | 391 h /= 2; |
392 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); | 392 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); |
393 } | 393 } |
394 | 394 |
395 return NULL; | 395 return NULL; |
396 } | 396 } |
OLD | NEW |