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 "GrConvexPolyEffect.h" | 9 #include "GrConvexPolyEffect.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 typedef GLAARectEffect GLProcessor; | 22 typedef GLAARectEffect GLProcessor; |
23 | 23 |
24 const SkRect& getRect() const { return fRect; } | 24 const SkRect& getRect() const { return fRect; } |
25 | 25 |
26 static const char* Name() { return "AARect"; } | 26 static const char* Name() { return "AARect"; } |
27 | 27 |
28 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec
t& rect) { | 28 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec
t& rect) { |
29 return SkNEW_ARGS(AARectEffect, (edgeType, rect)); | 29 return SkNEW_ARGS(AARectEffect, (edgeType, rect)); |
30 } | 30 } |
31 | 31 |
32 virtual void getConstantColorComponents(GrColor* color, | |
33 uint32_t* validFlags) const SK_OVERR
IDE { | |
34 if (fRect.isEmpty()) { | |
35 // An empty rect will have no coverage anywhere. | |
36 *color = 0x00000000; | |
37 *validFlags = kRGBA_GrColorComponentFlags; | |
38 } else { | |
39 *validFlags = 0; | |
40 } | |
41 } | |
42 | |
43 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 32 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
44 | 33 |
45 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 34 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
46 | 35 |
47 private: | 36 private: |
48 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect)
, fEdgeType(edgeType) { | 37 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect)
, fEdgeType(edgeType) { |
49 this->setWillReadFragmentPosition(); | 38 this->setWillReadFragmentPosition(); |
50 } | 39 } |
51 | 40 |
52 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { | 41 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { |
53 const AARectEffect& aare = other.cast<AARectEffect>(); | 42 const AARectEffect& aare = other.cast<AARectEffect>(); |
54 return fRect == aare.fRect; | 43 return fRect == aare.fRect; |
55 } | 44 } |
56 | 45 |
| 46 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
| 47 if (fRect.isEmpty()) { |
| 48 // An empty rect will have no coverage anywhere. |
| 49 inout->fColor = 0x00000000; |
| 50 inout->fValidFlags = kRGBA_GrColorComponentFlags; |
| 51 } else { |
| 52 inout->fValidFlags = 0; |
| 53 } |
| 54 inout->fIsSingleComponent = false; |
| 55 } |
| 56 |
57 SkRect fRect; | 57 SkRect fRect; |
58 GrPrimitiveEdgeType fEdgeType; | 58 GrPrimitiveEdgeType fEdgeType; |
59 | 59 |
60 typedef GrFragmentProcessor INHERITED; | 60 typedef GrFragmentProcessor INHERITED; |
61 | 61 |
62 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 62 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
63 | 63 |
64 }; | 64 }; |
65 | 65 |
66 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect); | 66 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { | 322 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { |
323 if (kHairlineAA_GrProcessorEdgeType == edgeType){ | 323 if (kHairlineAA_GrProcessorEdgeType == edgeType){ |
324 return NULL; | 324 return NULL; |
325 } | 325 } |
326 return AARectEffect::Create(edgeType, rect); | 326 return AARectEffect::Create(edgeType, rect); |
327 } | 327 } |
328 | 328 |
329 GrConvexPolyEffect::~GrConvexPolyEffect() {} | 329 GrConvexPolyEffect::~GrConvexPolyEffect() {} |
330 | 330 |
331 void GrConvexPolyEffect::getConstantColorComponents(GrColor* color, uint32_t* va
lidFlags) const { | 331 void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const
{ |
332 *validFlags = 0; | 332 inout->fValidFlags = 0; |
| 333 inout->fIsSingleComponent = false; |
333 } | 334 } |
334 | 335 |
335 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ | 336 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ |
336 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; | 337 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; |
337 } | 338 } |
338 | 339 |
339 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) | 340 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) |
340 : fEdgeType(edgeType) | 341 : fEdgeType(edgeType) |
341 , fEdgeCount(n) { | 342 , fEdgeCount(n) { |
342 // Factory function should have already ensured this. | 343 // Factory function should have already ensured this. |
(...skipping 29 matching lines...) Expand all Loading... |
372 } | 373 } |
373 | 374 |
374 GrFragmentProcessor* fp; | 375 GrFragmentProcessor* fp; |
375 do { | 376 do { |
376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 377 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
377 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 378 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); |
378 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 379 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
379 } while (NULL == fp); | 380 } while (NULL == fp); |
380 return fp; | 381 return fp; |
381 } | 382 } |
OLD | NEW |