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 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { | 41 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { |
42 const AARectEffect& aare = other.cast<AARectEffect>(); | 42 const AARectEffect& aare = other.cast<AARectEffect>(); |
43 return fRect == aare.fRect; | 43 return fRect == aare.fRect; |
44 } | 44 } |
45 | 45 |
46 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { | 46 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
47 if (fRect.isEmpty()) { | 47 if (fRect.isEmpty()) { |
48 // An empty rect will have no coverage anywhere. | 48 // An empty rect will have no coverage anywhere. |
49 inout->fColor = 0x00000000; | 49 inout->setToTransparentBlack(); |
50 inout->fValidFlags = kRGBA_GrColorComponentFlags; | |
51 } else { | 50 } else { |
52 inout->fValidFlags = 0; | 51 inout->mulByUnknownAlpha(); |
53 } | 52 } |
54 inout->fIsSingleComponent = false; | |
55 } | 53 } |
56 | 54 |
57 SkRect fRect; | 55 SkRect fRect; |
58 GrPrimitiveEdgeType fEdgeType; | 56 GrPrimitiveEdgeType fEdgeType; |
59 | 57 |
60 typedef GrFragmentProcessor INHERITED; | 58 typedef GrFragmentProcessor INHERITED; |
61 | 59 |
62 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 60 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
63 | 61 |
64 }; | 62 }; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { | 320 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { |
323 if (kHairlineAA_GrProcessorEdgeType == edgeType){ | 321 if (kHairlineAA_GrProcessorEdgeType == edgeType){ |
324 return NULL; | 322 return NULL; |
325 } | 323 } |
326 return AARectEffect::Create(edgeType, rect); | 324 return AARectEffect::Create(edgeType, rect); |
327 } | 325 } |
328 | 326 |
329 GrConvexPolyEffect::~GrConvexPolyEffect() {} | 327 GrConvexPolyEffect::~GrConvexPolyEffect() {} |
330 | 328 |
331 void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const
{ | 329 void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const
{ |
332 inout->fValidFlags = 0; | 330 inout->mulByUnknownAlpha(); |
333 inout->fIsSingleComponent = false; | |
334 } | 331 } |
335 | 332 |
336 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ | 333 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ |
337 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; | 334 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; |
338 } | 335 } |
339 | 336 |
340 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) | 337 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) |
341 : fEdgeType(edgeType) | 338 : fEdgeType(edgeType) |
342 , fEdgeCount(n) { | 339 , fEdgeCount(n) { |
343 // Factory function should have already ensured this. | 340 // Factory function should have already ensured this. |
(...skipping 29 matching lines...) Expand all Loading... |
373 } | 370 } |
374 | 371 |
375 GrFragmentProcessor* fp; | 372 GrFragmentProcessor* fp; |
376 do { | 373 do { |
377 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 374 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
378 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 375 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); |
379 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 376 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
380 } while (NULL == fp); | 377 } while (NULL == fp); |
381 return fp; | 378 return fp; |
382 } | 379 } |
OLD | NEW |