OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "gl/builders/GrGLFullProgramBuilder.h" | 10 #include "gl/builders/GrGLFullProgramBuilder.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 if (stroke) { | 69 if (stroke) { |
70 gCircleStrokeEdge->ref(); | 70 gCircleStrokeEdge->ref(); |
71 return gCircleStrokeEdge; | 71 return gCircleStrokeEdge; |
72 } else { | 72 } else { |
73 gCircleFillEdge->ref(); | 73 gCircleFillEdge->ref(); |
74 return gCircleFillEdge; | 74 return gCircleFillEdge; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 virtual void getConstantColorComponents(GrColor* color, | |
79 uint32_t* validFlags) const SK_OVERR
IDE { | |
80 *validFlags = 0; | |
81 } | |
82 | |
83 const GrShaderVar& inCircleEdge() const { return fInCircleEdge; } | 78 const GrShaderVar& inCircleEdge() const { return fInCircleEdge; } |
84 | 79 |
85 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 80 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
86 return GrTBackendGeometryProcessorFactory<CircleEdgeEffect>::getInstance
(); | 81 return GrTBackendGeometryProcessorFactory<CircleEdgeEffect>::getInstance
(); |
87 } | 82 } |
88 | 83 |
89 virtual ~CircleEdgeEffect() {} | 84 virtual ~CircleEdgeEffect() {} |
90 | 85 |
91 static const char* Name() { return "CircleEdge"; } | 86 static const char* Name() { return "CircleEdge"; } |
92 | 87 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 kVec4f_GrSLType, | 138 kVec4f_GrSLType, |
144 GrShaderVar::kAttribute_TypeModifier))) { | 139 GrShaderVar::kAttribute_TypeModifier))) { |
145 fStroke = stroke; | 140 fStroke = stroke; |
146 } | 141 } |
147 | 142 |
148 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { | 143 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { |
149 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); | 144 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); |
150 return cee.fStroke == fStroke; | 145 return cee.fStroke == fStroke; |
151 } | 146 } |
152 | 147 |
| 148 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
| 149 inout->fValidFlags = 0; |
| 150 inout->fIsSingleComponent = false; |
| 151 } |
| 152 |
153 const GrShaderVar& fInCircleEdge; | 153 const GrShaderVar& fInCircleEdge; |
154 bool fStroke; | 154 bool fStroke; |
155 | 155 |
156 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 156 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
157 | 157 |
158 typedef GrGeometryProcessor INHERITED; | 158 typedef GrGeometryProcessor INHERITED; |
159 }; | 159 }; |
160 | 160 |
161 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect); | 161 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect); |
162 | 162 |
(...skipping 22 matching lines...) Expand all Loading... |
185 | 185 |
186 if (stroke) { | 186 if (stroke) { |
187 gEllipseStrokeEdge->ref(); | 187 gEllipseStrokeEdge->ref(); |
188 return gEllipseStrokeEdge; | 188 return gEllipseStrokeEdge; |
189 } else { | 189 } else { |
190 gEllipseFillEdge->ref(); | 190 gEllipseFillEdge->ref(); |
191 return gEllipseFillEdge; | 191 return gEllipseFillEdge; |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 virtual void getConstantColorComponents(GrColor* color, | |
196 uint32_t* validFlags) const SK_OVERR
IDE { | |
197 *validFlags = 0; | |
198 } | |
199 | |
200 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 195 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
201 return GrTBackendGeometryProcessorFactory<EllipseEdgeEffect>::getInstanc
e(); | 196 return GrTBackendGeometryProcessorFactory<EllipseEdgeEffect>::getInstanc
e(); |
202 } | 197 } |
203 | 198 |
204 virtual ~EllipseEdgeEffect() {} | 199 virtual ~EllipseEdgeEffect() {} |
205 | 200 |
206 static const char* Name() { return "EllipseEdge"; } | 201 static const char* Name() { return "EllipseEdge"; } |
207 | 202 |
208 const GrShaderVar& inEllipseOffset() const { return fInEllipseOffset; } | 203 const GrShaderVar& inEllipseOffset() const { return fInEllipseOffset; } |
209 const GrShaderVar& inEllipseRadii() const { return fInEllipseRadii; } | 204 const GrShaderVar& inEllipseRadii() const { return fInEllipseRadii; } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 kVec4f_GrSLType, | 279 kVec4f_GrSLType, |
285 GrShaderVar::kAttribute_TypeModifier))) { | 280 GrShaderVar::kAttribute_TypeModifier))) { |
286 fStroke = stroke; | 281 fStroke = stroke; |
287 } | 282 } |
288 | 283 |
289 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { | 284 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { |
290 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); | 285 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); |
291 return eee.fStroke == fStroke; | 286 return eee.fStroke == fStroke; |
292 } | 287 } |
293 | 288 |
| 289 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
| 290 inout->fValidFlags = 0; |
| 291 inout->fIsSingleComponent = false; |
| 292 } |
| 293 |
294 const GrShaderVar& fInEllipseOffset; | 294 const GrShaderVar& fInEllipseOffset; |
295 const GrShaderVar& fInEllipseRadii; | 295 const GrShaderVar& fInEllipseRadii; |
296 bool fStroke; | 296 bool fStroke; |
297 | 297 |
298 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 298 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
299 | 299 |
300 typedef GrGeometryProcessor INHERITED; | 300 typedef GrGeometryProcessor INHERITED; |
301 }; | 301 }; |
302 | 302 |
303 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect); | 303 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect); |
(...skipping 30 matching lines...) Expand all Loading... |
334 return gEllipseStrokeEdge; | 334 return gEllipseStrokeEdge; |
335 } else if (kHairline == mode) { | 335 } else if (kHairline == mode) { |
336 gEllipseHairlineEdge->ref(); | 336 gEllipseHairlineEdge->ref(); |
337 return gEllipseHairlineEdge; | 337 return gEllipseHairlineEdge; |
338 } else { | 338 } else { |
339 gEllipseFillEdge->ref(); | 339 gEllipseFillEdge->ref(); |
340 return gEllipseFillEdge; | 340 return gEllipseFillEdge; |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 virtual void getConstantColorComponents(GrColor* color, | |
345 uint32_t* validFlags) const SK_OVERR
IDE { | |
346 *validFlags = 0; | |
347 } | |
348 | |
349 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 344 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
350 return GrTBackendGeometryProcessorFactory<DIEllipseEdgeEffect>::getInsta
nce(); | 345 return GrTBackendGeometryProcessorFactory<DIEllipseEdgeEffect>::getInsta
nce(); |
351 } | 346 } |
352 | 347 |
353 virtual ~DIEllipseEdgeEffect() {} | 348 virtual ~DIEllipseEdgeEffect() {} |
354 | 349 |
355 static const char* Name() { return "DIEllipseEdge"; } | 350 static const char* Name() { return "DIEllipseEdge"; } |
356 | 351 |
357 const GrShaderVar& inEllipseOffsets0() const { return fInEllipseOffsets0; } | 352 const GrShaderVar& inEllipseOffsets0() const { return fInEllipseOffsets0; } |
358 const GrShaderVar& inEllipseOffsets1() const { return fInEllipseOffsets1; } | 353 const GrShaderVar& inEllipseOffsets1() const { return fInEllipseOffsets1; } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 kVec2f_GrSLType, | 448 kVec2f_GrSLType, |
454 GrShaderVar::kAttribute_TypeModifier))) { | 449 GrShaderVar::kAttribute_TypeModifier))) { |
455 fMode = mode; | 450 fMode = mode; |
456 } | 451 } |
457 | 452 |
458 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { | 453 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { |
459 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); | 454 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); |
460 return eee.fMode == fMode; | 455 return eee.fMode == fMode; |
461 } | 456 } |
462 | 457 |
| 458 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
| 459 inout->fValidFlags = 0; |
| 460 inout->fIsSingleComponent = false; |
| 461 } |
| 462 |
463 const GrShaderVar& fInEllipseOffsets0; | 463 const GrShaderVar& fInEllipseOffsets0; |
464 const GrShaderVar& fInEllipseOffsets1; | 464 const GrShaderVar& fInEllipseOffsets1; |
465 Mode fMode; | 465 Mode fMode; |
466 | 466 |
467 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 467 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
468 | 468 |
469 typedef GrGeometryProcessor INHERITED; | 469 typedef GrGeometryProcessor INHERITED; |
470 }; | 470 }; |
471 | 471 |
472 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect); | 472 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect); |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 | 1237 |
1238 // drop out the middle quad if we're stroked | 1238 // drop out the middle quad if we're stroked |
1239 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : | 1239 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : |
1240 SK_ARRAY_COUNT(gRRectIndices); | 1240 SK_ARRAY_COUNT(gRRectIndices); |
1241 target->setIndexSourceToBuffer(indexBuffer); | 1241 target->setIndexSourceToBuffer(indexBuffer); |
1242 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); | 1242 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); |
1243 } | 1243 } |
1244 | 1244 |
1245 return true; | 1245 return true; |
1246 } | 1246 } |
OLD | NEW |