| 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 #include "GrInvariantOutput.h" |
| 11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
| 12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
| 13 #include "GrTBackendProcessorFactory.h" | 13 #include "GrTBackendProcessorFactory.h" |
| 14 | 14 |
| 15 #include "SkPath.h" | 15 #include "SkPath.h" |
| 16 | 16 |
| 17 ////////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////////// |
| 18 class GLAARectEffect; | 18 class GLAARectEffect; |
| 19 | 19 |
| 20 class AARectEffect : public GrFragmentProcessor { | 20 class AARectEffect : public GrFragmentProcessor { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 private: | 36 private: |
| 37 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect)
, fEdgeType(edgeType) { | 37 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect)
, fEdgeType(edgeType) { |
| 38 this->setWillReadFragmentPosition(); | 38 this->setWillReadFragmentPosition(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { | 41 virtual bool onIsEqual(const GrFragmentProcessor& 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(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
| 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->mulByKnownAlpha(0); | 49 inout->mulByKnownAlpha(0); |
| 50 } else { | 50 } else { |
| 51 inout->mulByUnknownAlpha(); | 51 inout->mulByUnknownAlpha(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 SkRect fRect; | 55 SkRect fRect; |
| 56 GrPrimitiveEdgeType fEdgeType; | 56 GrPrimitiveEdgeType fEdgeType; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { | 320 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { |
| 321 if (kHairlineAA_GrProcessorEdgeType == edgeType){ | 321 if (kHairlineAA_GrProcessorEdgeType == edgeType){ |
| 322 return NULL; | 322 return NULL; |
| 323 } | 323 } |
| 324 return AARectEffect::Create(edgeType, rect); | 324 return AARectEffect::Create(edgeType, rect); |
| 325 } | 325 } |
| 326 | 326 |
| 327 GrConvexPolyEffect::~GrConvexPolyEffect() {} | 327 GrConvexPolyEffect::~GrConvexPolyEffect() {} |
| 328 | 328 |
| 329 void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const
{ | 329 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
t { |
| 330 inout->mulByUnknownAlpha(); | 330 inout->mulByUnknownAlpha(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ | 333 const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const
{ |
| 334 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; | 334 return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance()
; |
| 335 } | 335 } |
| 336 | 336 |
| 337 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) | 337 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) |
| 338 : fEdgeType(edgeType) | 338 : fEdgeType(edgeType) |
| 339 , fEdgeCount(n) { | 339 , fEdgeCount(n) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 370 } | 370 } |
| 371 | 371 |
| 372 GrFragmentProcessor* fp; | 372 GrFragmentProcessor* fp; |
| 373 do { | 373 do { |
| 374 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 374 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 375 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 375 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); |
| 376 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 376 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
| 377 } while (NULL == fp); | 377 } while (NULL == fp); |
| 378 return fp; | 378 return fp; |
| 379 } | 379 } |
| OLD | NEW |