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 30 matching lines...) Expand all Loading... |
41 kNone_CornerFlags = 0 | 41 kNone_CornerFlags = 0 |
42 }; | 42 }; |
43 | 43 |
44 // The flags are used to indicate which corners are circluar (unflagged corn
ers are assumed to | 44 // The flags are used to indicate which corners are circluar (unflagged corn
ers are assumed to |
45 // be square). | 45 // be square). |
46 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCor
nerFlags, | 46 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCor
nerFlags, |
47 const SkRRect&); | 47 const SkRRect&); |
48 | 48 |
49 virtual ~CircularRRectEffect() {}; | 49 virtual ~CircularRRectEffect() {}; |
50 | 50 |
51 virtual const char* name() const SK_OVERRIDE { return "CircularRRect"; } | 51 const char* name() const SK_OVERRIDE { return "CircularRRect"; } |
52 | 52 |
53 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 53 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
54 | 54 |
55 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 55 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
56 | 56 |
57 const SkRRect& getRRect() const { return fRRect; } | 57 const SkRRect& getRRect() const { return fRRect; } |
58 | 58 |
59 uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; } | 59 uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; } |
60 | 60 |
61 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 61 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
62 | 62 |
63 private: | 63 private: |
64 CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const
SkRRect&); | 64 CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const
SkRRect&); |
65 | 65 |
66 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; | 66 bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; |
67 | 67 |
68 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 68 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
69 | 69 |
70 SkRRect fRRect; | 70 SkRRect fRRect; |
71 GrPrimitiveEdgeType fEdgeType; | 71 GrPrimitiveEdgeType fEdgeType; |
72 uint32_t fCircularCornerFlags; | 72 uint32_t fCircularCornerFlags; |
73 | 73 |
74 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 74 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
75 | 75 |
76 typedef GrFragmentProcessor INHERITED; | 76 typedef GrFragmentProcessor INHERITED; |
77 }; | 77 }; |
78 | 78 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 virtual void emitCode(GrGLFPBuilder* builder, | 135 virtual void emitCode(GrGLFPBuilder* builder, |
136 const GrFragmentProcessor& fp, | 136 const GrFragmentProcessor& fp, |
137 const char* outputColor, | 137 const char* outputColor, |
138 const char* inputColor, | 138 const char* inputColor, |
139 const TransformedCoordsArray&, | 139 const TransformedCoordsArray&, |
140 const TextureSamplerArray&) SK_OVERRIDE; | 140 const TextureSamplerArray&) SK_OVERRIDE; |
141 | 141 |
142 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 142 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
143 | 143 |
144 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 144 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
145 | 145 |
146 private: | 146 private: |
147 GrGLProgramDataManager::UniformHandle fInnerRectUniform; | 147 GrGLProgramDataManager::UniformHandle fInnerRectUniform; |
148 GrGLProgramDataManager::UniformHandle fRadiusPlusHalfUniform; | 148 GrGLProgramDataManager::UniformHandle fRadiusPlusHalfUniform; |
149 SkRRect fPrevRRect; | 149 SkRRect fPrevRRect; |
150 typedef GrGLFragmentProcessor INHERITED; | 150 typedef GrGLFragmentProcessor INHERITED; |
151 }; | 151 }; |
152 | 152 |
153 GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) { | 153 GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) { |
154 fPrevRRect.setEmpty(); | 154 fPrevRRect.setEmpty(); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 | 386 |
387 ////////////////////////////////////////////////////////////////////////////// | 387 ////////////////////////////////////////////////////////////////////////////// |
388 | 388 |
389 class EllipticalRRectEffect : public GrFragmentProcessor { | 389 class EllipticalRRectEffect : public GrFragmentProcessor { |
390 public: | 390 public: |
391 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&); | 391 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&); |
392 | 392 |
393 virtual ~EllipticalRRectEffect() {}; | 393 virtual ~EllipticalRRectEffect() {}; |
394 | 394 |
395 virtual const char* name() const SK_OVERRIDE { return "EllipticalRRect"; } | 395 const char* name() const SK_OVERRIDE { return "EllipticalRRect"; } |
396 | 396 |
397 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 397 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
398 | 398 |
399 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 399 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
400 | 400 |
401 const SkRRect& getRRect() const { return fRRect; } | 401 const SkRRect& getRRect() const { return fRRect; } |
402 | 402 |
403 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 403 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
404 | 404 |
405 private: | 405 private: |
406 EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&); | 406 EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&); |
407 | 407 |
408 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; | 408 bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; |
409 | 409 |
410 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 410 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
411 | 411 |
412 SkRRect fRRect; | 412 SkRRect fRRect; |
413 GrPrimitiveEdgeType fEdgeType; | 413 GrPrimitiveEdgeType fEdgeType; |
414 | 414 |
415 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 415 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
416 | 416 |
417 typedef GrFragmentProcessor INHERITED; | 417 typedef GrFragmentProcessor INHERITED; |
418 }; | 418 }; |
419 | 419 |
420 GrFragmentProcessor* | 420 GrFragmentProcessor* |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 491 |
492 virtual void emitCode(GrGLFPBuilder* builder, | 492 virtual void emitCode(GrGLFPBuilder* builder, |
493 const GrFragmentProcessor& effect, | 493 const GrFragmentProcessor& effect, |
494 const char* outputColor, | 494 const char* outputColor, |
495 const char* inputColor, | 495 const char* inputColor, |
496 const TransformedCoordsArray&, | 496 const TransformedCoordsArray&, |
497 const TextureSamplerArray&) SK_OVERRIDE; | 497 const TextureSamplerArray&) SK_OVERRIDE; |
498 | 498 |
499 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 499 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
500 | 500 |
501 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 501 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
502 | 502 |
503 private: | 503 private: |
504 GrGLProgramDataManager::UniformHandle fInnerRectUniform; | 504 GrGLProgramDataManager::UniformHandle fInnerRectUniform; |
505 GrGLProgramDataManager::UniformHandle fInvRadiiSqdUniform; | 505 GrGLProgramDataManager::UniformHandle fInvRadiiSqdUniform; |
506 SkRRect fPrevRRect; | 506 SkRRect fPrevRRect; |
507 typedef GrGLFragmentProcessor INHERITED; | 507 typedef GrGLFragmentProcessor INHERITED; |
508 }; | 508 }; |
509 | 509 |
510 GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrProcessor& effect) { | 510 GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrProcessor& effect) { |
511 fPrevRRect.setEmpty(); | 511 fPrevRRect.setEmpty(); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 if (rrect.isNinePatch()) { | 733 if (rrect.isNinePatch()) { |
734 return EllipticalRRectEffect::Create(edgeType, rrect); | 734 return EllipticalRRectEffect::Create(edgeType, rrect); |
735 } | 735 } |
736 return NULL; | 736 return NULL; |
737 } | 737 } |
738 } | 738 } |
739 } | 739 } |
740 | 740 |
741 return NULL; | 741 return NULL; |
742 } | 742 } |
OLD | NEW |