| 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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrOvalEffect.h" | 9 #include "GrOvalEffect.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 virtual ~CircleEffect() {}; | 25 virtual ~CircleEffect() {}; |
| 26 static const char* Name() { return "Circle"; } | 26 static const char* Name() { return "Circle"; } |
| 27 | 27 |
| 28 const SkPoint& getCenter() const { return fCenter; } | 28 const SkPoint& getCenter() const { return fCenter; } |
| 29 SkScalar getRadius() const { return fRadius; } | 29 SkScalar getRadius() const { return fRadius; } |
| 30 | 30 |
| 31 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 31 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 32 | 32 |
| 33 typedef GLCircleEffect GLProcessor; | 33 typedef GLCircleEffect GLProcessor; |
| 34 | 34 |
| 35 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 36 | |
| 37 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 35 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 38 | 36 |
| 39 private: | 37 private: |
| 40 CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); | 38 CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); |
| 41 | 39 |
| 42 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 40 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
| 43 | 41 |
| 42 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; |
| 43 |
| 44 SkPoint fCenter; | 44 SkPoint fCenter; |
| 45 SkScalar fRadius; | 45 SkScalar fRadius; |
| 46 GrPrimitiveEdgeType fEdgeType; | 46 GrPrimitiveEdgeType fEdgeType; |
| 47 | 47 |
| 48 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 48 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 49 | 49 |
| 50 typedef GrFragmentProcessor INHERITED; | 50 typedef GrFragmentProcessor INHERITED; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const Sk
Point& center, | 53 GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const Sk
Point& center, |
| 54 SkScalar radius) { | 54 SkScalar radius) { |
| 55 SkASSERT(radius >= 0); | 55 SkASSERT(radius >= 0); |
| 56 return SkNEW_ARGS(CircleEffect, (edgeType, center, radius)); | 56 return SkNEW_ARGS(CircleEffect, (edgeType, center, radius)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void CircleEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla
gs) const { | 59 void CircleEffect::onComputeInvariantOutput(InvariantOutput* inout) const { |
| 60 *validFlags = 0; | 60 inout->fValidFlags = 0; |
| 61 inout->fIsSingleComponent = false; |
| 61 } | 62 } |
| 62 | 63 |
| 63 const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const { | 64 const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const { |
| 64 return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance(); | 65 return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkSca
lar r) | 68 CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkSca
lar r) |
| 68 : fCenter(c) | 69 : fCenter(c) |
| 69 , fRadius(r) | 70 , fRadius(r) |
| 70 , fEdgeType(edgeType) { | 71 , fEdgeType(edgeType) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 virtual ~EllipseEffect() {}; | 198 virtual ~EllipseEffect() {}; |
| 198 static const char* Name() { return "Ellipse"; } | 199 static const char* Name() { return "Ellipse"; } |
| 199 | 200 |
| 200 const SkPoint& getCenter() const { return fCenter; } | 201 const SkPoint& getCenter() const { return fCenter; } |
| 201 SkVector getRadii() const { return fRadii; } | 202 SkVector getRadii() const { return fRadii; } |
| 202 | 203 |
| 203 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 204 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 204 | 205 |
| 205 typedef GLEllipseEffect GLProcessor; | 206 typedef GLEllipseEffect GLProcessor; |
| 206 | 207 |
| 207 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 208 | |
| 209 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 208 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 210 | 209 |
| 211 private: | 210 private: |
| 212 EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkSca
lar ry); | 211 EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkSca
lar ry); |
| 213 | 212 |
| 214 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 213 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
| 215 | 214 |
| 215 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; |
| 216 |
| 216 SkPoint fCenter; | 217 SkPoint fCenter; |
| 217 SkVector fRadii; | 218 SkVector fRadii; |
| 218 GrPrimitiveEdgeType fEdgeType; | 219 GrPrimitiveEdgeType fEdgeType; |
| 219 | 220 |
| 220 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 221 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 221 | 222 |
| 222 typedef GrFragmentProcessor INHERITED; | 223 typedef GrFragmentProcessor INHERITED; |
| 223 }; | 224 }; |
| 224 | 225 |
| 225 GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType, | 226 GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType, |
| 226 const SkPoint& center, | 227 const SkPoint& center, |
| 227 SkScalar rx, | 228 SkScalar rx, |
| 228 SkScalar ry) { | 229 SkScalar ry) { |
| 229 SkASSERT(rx >= 0 && ry >= 0); | 230 SkASSERT(rx >= 0 && ry >= 0); |
| 230 return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry)); | 231 return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry)); |
| 231 } | 232 } |
| 232 | 233 |
| 233 void EllipseEffect::getConstantColorComponents(GrColor* color, uint32_t* validFl
ags) const { | 234 void EllipseEffect::onComputeInvariantOutput(InvariantOutput* inout) const { |
| 234 *validFlags = 0; | 235 inout->fValidFlags = 0; |
| 236 inout->fIsSingleComponent = false; |
| 235 } | 237 } |
| 236 | 238 |
| 237 const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const { | 239 const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const { |
| 238 return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance(); | 240 return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance(); |
| 239 } | 241 } |
| 240 | 242 |
| 241 EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkS
calar rx, SkScalar ry) | 243 EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkS
calar rx, SkScalar ry) |
| 242 : fCenter(c) | 244 : fCenter(c) |
| 243 , fRadii(SkVector::Make(rx, ry)) | 245 , fRadii(SkVector::Make(rx, ry)) |
| 244 , fEdgeType(edgeType) { | 246 , fEdgeType(edgeType) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 w /= 2; | 383 w /= 2; |
| 382 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); | 384 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); |
| 383 } else { | 385 } else { |
| 384 w /= 2; | 386 w /= 2; |
| 385 h /= 2; | 387 h /= 2; |
| 386 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); | 388 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); |
| 387 } | 389 } |
| 388 | 390 |
| 389 return NULL; | 391 return NULL; |
| 390 } | 392 } |
| OLD | NEW |