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