| 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 "GrDashingEffect.h" | 8 #include "GrDashingEffect.h" |
| 9 | 9 |
| 10 #include "../GrAARectRenderer.h" | 10 #include "../GrAARectRenderer.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 454 |
| 455 SkScalar getIntervalLength() const { return fIntervalLength; } | 455 SkScalar getIntervalLength() const { return fIntervalLength; } |
| 456 | 456 |
| 457 typedef GLDashingCircleEffect GLProcessor; | 457 typedef GLDashingCircleEffect GLProcessor; |
| 458 | 458 |
| 459 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE; | 459 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 460 | 460 |
| 461 private: | 461 private: |
| 462 DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkSc
alar radius); | 462 DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkSc
alar radius); |
| 463 | 463 |
| 464 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; | 464 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 465 | 465 |
| 466 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 466 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; |
| 467 | 467 |
| 468 GrPrimitiveEdgeType fEdgeType; | 468 GrPrimitiveEdgeType fEdgeType; |
| 469 const GrShaderVar& fInCoord; | 469 const GrShaderVar& fInCoord; |
| 470 SkScalar fIntervalLength; | 470 SkScalar fIntervalLength; |
| 471 SkScalar fRadius; | 471 SkScalar fRadius; |
| 472 SkScalar fCenterX; | 472 SkScalar fCenterX; |
| 473 | 473 |
| 474 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 474 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 , fInCoord(this->addVertexAttrib(GrShaderVar("inCoord", | 598 , fInCoord(this->addVertexAttrib(GrShaderVar("inCoord", |
| 599 kVec2f_GrSLType, | 599 kVec2f_GrSLType, |
| 600 GrShaderVar::kAttribute_TypeMod
ifier))) { | 600 GrShaderVar::kAttribute_TypeMod
ifier))) { |
| 601 SkScalar onLen = info.fIntervals[0]; | 601 SkScalar onLen = info.fIntervals[0]; |
| 602 SkScalar offLen = info.fIntervals[1]; | 602 SkScalar offLen = info.fIntervals[1]; |
| 603 fIntervalLength = onLen + offLen; | 603 fIntervalLength = onLen + offLen; |
| 604 fRadius = radius; | 604 fRadius = radius; |
| 605 fCenterX = SkScalarHalf(offLen); | 605 fCenterX = SkScalarHalf(offLen); |
| 606 } | 606 } |
| 607 | 607 |
| 608 bool DashingCircleEffect::onIsEqual(const GrProcessor& other) const { | 608 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const { |
| 609 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); | 609 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); |
| 610 return (fEdgeType == dce.fEdgeType && | 610 return (fEdgeType == dce.fEdgeType && |
| 611 fIntervalLength == dce.fIntervalLength && | 611 fIntervalLength == dce.fIntervalLength && |
| 612 fRadius == dce.fRadius && | 612 fRadius == dce.fRadius && |
| 613 fCenterX == dce.fCenterX); | 613 fCenterX == dce.fCenterX); |
| 614 } | 614 } |
| 615 | 615 |
| 616 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); | 616 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); |
| 617 | 617 |
| 618 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, | 618 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 666 |
| 667 SkScalar getIntervalLength() const { return fIntervalLength; } | 667 SkScalar getIntervalLength() const { return fIntervalLength; } |
| 668 | 668 |
| 669 typedef GLDashingLineEffect GLProcessor; | 669 typedef GLDashingLineEffect GLProcessor; |
| 670 | 670 |
| 671 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE; | 671 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 672 | 672 |
| 673 private: | 673 private: |
| 674 DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScal
ar strokeWidth); | 674 DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScal
ar strokeWidth); |
| 675 | 675 |
| 676 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; | 676 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 677 | 677 |
| 678 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 678 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; |
| 679 | 679 |
| 680 GrPrimitiveEdgeType fEdgeType; | 680 GrPrimitiveEdgeType fEdgeType; |
| 681 const GrShaderVar& fInCoord; | 681 const GrShaderVar& fInCoord; |
| 682 SkRect fRect; | 682 SkRect fRect; |
| 683 SkScalar fIntervalLength; | 683 SkScalar fIntervalLength; |
| 684 | 684 |
| 685 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 685 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 686 | 686 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 kVec2f_GrSLType, | 822 kVec2f_GrSLType, |
| 823 GrShaderVar::kAttribute_TypeMod
ifier))) { | 823 GrShaderVar::kAttribute_TypeMod
ifier))) { |
| 824 SkScalar onLen = info.fIntervals[0]; | 824 SkScalar onLen = info.fIntervals[0]; |
| 825 SkScalar offLen = info.fIntervals[1]; | 825 SkScalar offLen = info.fIntervals[1]; |
| 826 SkScalar halfOffLen = SkScalarHalf(offLen); | 826 SkScalar halfOffLen = SkScalarHalf(offLen); |
| 827 SkScalar halfStroke = SkScalarHalf(strokeWidth); | 827 SkScalar halfStroke = SkScalarHalf(strokeWidth); |
| 828 fIntervalLength = onLen + offLen; | 828 fIntervalLength = onLen + offLen; |
| 829 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); | 829 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); |
| 830 } | 830 } |
| 831 | 831 |
| 832 bool DashingLineEffect::onIsEqual(const GrProcessor& other) const { | 832 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const { |
| 833 const DashingLineEffect& de = other.cast<DashingLineEffect>(); | 833 const DashingLineEffect& de = other.cast<DashingLineEffect>(); |
| 834 return (fEdgeType == de.fEdgeType && | 834 return (fEdgeType == de.fEdgeType && |
| 835 fRect == de.fRect && | 835 fRect == de.fRect && |
| 836 fIntervalLength == de.fIntervalLength); | 836 fIntervalLength == de.fIntervalLength); |
| 837 } | 837 } |
| 838 | 838 |
| 839 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); | 839 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); |
| 840 | 840 |
| 841 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, | 841 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, |
| 842 GrContext*, | 842 GrContext*, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 865 switch (cap) { | 865 switch (cap) { |
| 866 case GrDashingEffect::kRound_DashCap: | 866 case GrDashingEffect::kRound_DashCap: |
| 867 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); | 867 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); |
| 868 case GrDashingEffect::kNonRound_DashCap: | 868 case GrDashingEffect::kNonRound_DashCap: |
| 869 return DashingLineEffect::Create(edgeType, info, strokeWidth); | 869 return DashingLineEffect::Create(edgeType, info, strokeWidth); |
| 870 default: | 870 default: |
| 871 SkFAIL("Unexpected dashed cap."); | 871 SkFAIL("Unexpected dashed cap."); |
| 872 } | 872 } |
| 873 return NULL; | 873 return NULL; |
| 874 } | 874 } |
| OLD | NEW |