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 "GrRRectEffect.h" | 8 #include "GrRRectEffect.h" |
9 | 9 |
10 #include "GrConvexPolyEffect.h" | 10 #include "GrConvexPolyEffect.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 73 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
74 | 74 |
75 typedef GrFragmentProcessor INHERITED; | 75 typedef GrFragmentProcessor INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType, | 78 GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType, |
79 uint32_t circularCornerFlags, | 79 uint32_t circularCornerFlags, |
80 const SkRRect& rrect) { | 80 const SkRRect& rrect) { |
81 if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdg
eType != edgeType) { | 81 if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdg
eType != edgeType) { |
82 return NULL; | 82 return nullptr; |
83 } | 83 } |
84 return new CircularRRectEffect(edgeType, circularCornerFlags, rrect); | 84 return new CircularRRectEffect(edgeType, circularCornerFlags, rrect); |
85 } | 85 } |
86 | 86 |
87 void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con
st { | 87 void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con
st { |
88 inout->mulByUnknownSingleComponent(); | 88 inout->mulByUnknownSingleComponent(); |
89 } | 89 } |
90 | 90 |
91 CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t
circularCornerFlags, | 91 CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t
circularCornerFlags, |
92 const SkRRect& rrect) | 92 const SkRRect& rrect) |
(...skipping 18 matching lines...) Expand all Loading... |
111 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); | 111 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); |
112 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); | 112 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); |
113 SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f); | 113 SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f); |
114 SkRRect rrect; | 114 SkRRect rrect; |
115 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); | 115 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); |
116 GrFragmentProcessor* fp; | 116 GrFragmentProcessor* fp; |
117 do { | 117 do { |
118 GrPrimitiveEdgeType et = | 118 GrPrimitiveEdgeType et = |
119 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); | 119 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); |
120 fp = GrRRectEffect::Create(et, rrect); | 120 fp = GrRRectEffect::Create(et, rrect); |
121 } while (NULL == fp); | 121 } while (nullptr == fp); |
122 return fp; | 122 return fp; |
123 } | 123 } |
124 | 124 |
125 ////////////////////////////////////////////////////////////////////////////// | 125 ////////////////////////////////////////////////////////////////////////////// |
126 | 126 |
127 class GLCircularRRectEffect : public GrGLFragmentProcessor { | 127 class GLCircularRRectEffect : public GrGLFragmentProcessor { |
128 public: | 128 public: |
129 GLCircularRRectEffect(const GrProcessor&); | 129 GLCircularRRectEffect(const GrProcessor&); |
130 | 130 |
131 virtual void emitCode(EmitArgs&) override; | 131 virtual void emitCode(EmitArgs&) override; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 GrPrimitiveEdgeType fEdgeType; | 400 GrPrimitiveEdgeType fEdgeType; |
401 | 401 |
402 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 402 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
403 | 403 |
404 typedef GrFragmentProcessor INHERITED; | 404 typedef GrFragmentProcessor INHERITED; |
405 }; | 405 }; |
406 | 406 |
407 GrFragmentProcessor* | 407 GrFragmentProcessor* |
408 EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect
) { | 408 EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect
) { |
409 if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdg
eType != edgeType) { | 409 if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdg
eType != edgeType) { |
410 return NULL; | 410 return nullptr; |
411 } | 411 } |
412 return new EllipticalRRectEffect(edgeType, rrect); | 412 return new EllipticalRRectEffect(edgeType, rrect); |
413 } | 413 } |
414 | 414 |
415 void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 415 void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
416 inout->mulByUnknownSingleComponent(); | 416 inout->mulByUnknownSingleComponent(); |
417 } | 417 } |
418 | 418 |
419 EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const
SkRRect& rrect) | 419 EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const
SkRRect& rrect) |
420 : fRRect(rrect) | 420 : fRRect(rrect) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 rrect.setRectRadii(SkRect::MakeWH(w, h), r); | 457 rrect.setRectRadii(SkRect::MakeWH(w, h), r); |
458 } else { | 458 } else { |
459 rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX, | 459 rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX, |
460 r[SkRRect::kUpperLeft_Corner].fY); | 460 r[SkRRect::kUpperLeft_Corner].fY); |
461 } | 461 } |
462 GrFragmentProcessor* fp; | 462 GrFragmentProcessor* fp; |
463 do { | 463 do { |
464 GrPrimitiveEdgeType et = | 464 GrPrimitiveEdgeType et = |
465 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); | 465 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); |
466 fp = GrRRectEffect::Create(et, rrect); | 466 fp = GrRRectEffect::Create(et, rrect); |
467 } while (NULL == fp); | 467 } while (nullptr == fp); |
468 return fp; | 468 return fp; |
469 } | 469 } |
470 | 470 |
471 ////////////////////////////////////////////////////////////////////////////// | 471 ////////////////////////////////////////////////////////////////////////////// |
472 | 472 |
473 class GLEllipticalRRectEffect : public GrGLFragmentProcessor { | 473 class GLEllipticalRRectEffect : public GrGLFragmentProcessor { |
474 public: | 474 public: |
475 GLEllipticalRRectEffect(const GrProcessor&); | 475 GLEllipticalRRectEffect(const GrProcessor&); |
476 | 476 |
477 virtual void emitCode(EmitArgs&) override; | 477 virtual void emitCode(EmitArgs&) override; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 } | 699 } |
700 return CircularRRectEffect::Create(edgeType, cornerFlags, *rr); | 700 return CircularRRectEffect::Create(edgeType, cornerFlags, *rr); |
701 } | 701 } |
702 case CircularRRectEffect::kNone_CornerFlags: | 702 case CircularRRectEffect::kNone_CornerFlags: |
703 return GrConvexPolyEffect::Create(edgeType, rrect.getBounds()); | 703 return GrConvexPolyEffect::Create(edgeType, rrect.getBounds()); |
704 default: { | 704 default: { |
705 if (squashedRadii) { | 705 if (squashedRadii) { |
706 // If we got here then we squashed some but not all the radi
i to zero. (If all | 706 // If we got here then we squashed some but not all the radi
i to zero. (If all |
707 // had been squashed cornerFlags would be 0.) The elliptical
effect doesn't | 707 // had been squashed cornerFlags would be 0.) The elliptical
effect doesn't |
708 // support some rounded and some square corners. | 708 // support some rounded and some square corners. |
709 return NULL; | 709 return nullptr; |
710 } | 710 } |
711 if (rrect.isNinePatch()) { | 711 if (rrect.isNinePatch()) { |
712 return EllipticalRRectEffect::Create(edgeType, rrect); | 712 return EllipticalRRectEffect::Create(edgeType, rrect); |
713 } | 713 } |
714 return NULL; | 714 return nullptr; |
715 } | 715 } |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 return NULL; | 719 return nullptr; |
720 } | 720 } |
OLD | NEW |