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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 static GrGeometryProcessor* Create(GrColor, | 473 static GrGeometryProcessor* Create(GrColor, |
474 GrPrimitiveEdgeType edgeType, | 474 GrPrimitiveEdgeType edgeType, |
475 const DashInfo& info, | 475 const DashInfo& info, |
476 SkScalar radius, | 476 SkScalar radius, |
477 const SkMatrix& localMatrix); | 477 const SkMatrix& localMatrix); |
478 | 478 |
479 virtual ~DashingCircleEffect(); | 479 virtual ~DashingCircleEffect(); |
480 | 480 |
481 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect";
} | 481 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect";
} |
482 | 482 |
483 const GrAttribute* inPosition() const { return fInPosition; } | 483 const Attribute* inPosition() const { return fInPosition; } |
484 | 484 |
485 const GrAttribute* inCoord() const { return fInCoord; } | 485 const Attribute* inCoord() const { return fInCoord; } |
486 | 486 |
487 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 487 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
488 | 488 |
489 SkScalar getRadius() const { return fRadius; } | 489 SkScalar getRadius() const { return fRadius; } |
490 | 490 |
491 SkScalar getCenterX() const { return fCenterX; } | 491 SkScalar getCenterX() const { return fCenterX; } |
492 | 492 |
493 SkScalar getIntervalLength() const { return fIntervalLength; } | 493 SkScalar getIntervalLength() const { return fIntervalLength; } |
494 | 494 |
495 virtual void getGLProcessorKey(const GrBatchTracker&, | 495 virtual void getGLProcessorKey(const GrBatchTracker&, |
(...skipping 11 matching lines...) Expand all Loading... |
507 | 507 |
508 private: | 508 private: |
509 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i
nfo, | 509 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i
nfo, |
510 SkScalar radius, const SkMatrix& localMatrix); | 510 SkScalar radius, const SkMatrix& localMatrix); |
511 | 511 |
512 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 512 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
513 | 513 |
514 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O
VERRIDE; | 514 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O
VERRIDE; |
515 | 515 |
516 GrPrimitiveEdgeType fEdgeType; | 516 GrPrimitiveEdgeType fEdgeType; |
517 const GrAttribute* fInPosition; | 517 const Attribute* fInPosition; |
518 const GrAttribute* fInCoord; | 518 const Attribute* fInCoord; |
519 SkScalar fIntervalLength; | 519 SkScalar fIntervalLength; |
520 SkScalar fRadius; | 520 SkScalar fRadius; |
521 SkScalar fCenterX; | 521 SkScalar fCenterX; |
522 | 522 |
523 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 523 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
524 | 524 |
525 typedef GrGeometryProcessor INHERITED; | 525 typedef GrGeometryProcessor INHERITED; |
526 }; | 526 }; |
527 | 527 |
528 ////////////////////////////////////////////////////////////////////////////// | 528 ////////////////////////////////////////////////////////////////////////////// |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); | 681 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); |
682 } | 682 } |
683 | 683 |
684 DashingCircleEffect::DashingCircleEffect(GrColor color, | 684 DashingCircleEffect::DashingCircleEffect(GrColor color, |
685 GrPrimitiveEdgeType edgeType, | 685 GrPrimitiveEdgeType edgeType, |
686 const DashInfo& info, | 686 const DashInfo& info, |
687 SkScalar radius, | 687 SkScalar radius, |
688 const SkMatrix& localMatrix) | 688 const SkMatrix& localMatrix) |
689 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { | 689 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { |
690 this->initClassID<DashingCircleEffect>(); | 690 this->initClassID<DashingCircleEffect>(); |
691 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 691 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
692 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr
ibType)); | 692 fInCoord = &this->addVertexAttrib(Attribute("inCoord", kVec2f_GrVertexAttrib
Type)); |
693 SkScalar onLen = info.fIntervals[0]; | 693 SkScalar onLen = info.fIntervals[0]; |
694 SkScalar offLen = info.fIntervals[1]; | 694 SkScalar offLen = info.fIntervals[1]; |
695 fIntervalLength = onLen + offLen; | 695 fIntervalLength = onLen + offLen; |
696 fRadius = radius; | 696 fRadius = radius; |
697 fCenterX = SkScalarHalf(offLen); | 697 fCenterX = SkScalarHalf(offLen); |
698 } | 698 } |
699 | 699 |
700 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const { | 700 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const { |
701 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); | 701 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); |
702 return (fEdgeType == dce.fEdgeType && | 702 return (fEdgeType == dce.fEdgeType && |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 static GrGeometryProcessor* Create(GrColor, | 770 static GrGeometryProcessor* Create(GrColor, |
771 GrPrimitiveEdgeType edgeType, | 771 GrPrimitiveEdgeType edgeType, |
772 const DashInfo& info, | 772 const DashInfo& info, |
773 SkScalar strokeWidth, | 773 SkScalar strokeWidth, |
774 const SkMatrix& localMatrix); | 774 const SkMatrix& localMatrix); |
775 | 775 |
776 virtual ~DashingLineEffect(); | 776 virtual ~DashingLineEffect(); |
777 | 777 |
778 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; } | 778 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; } |
779 | 779 |
780 const GrAttribute* inPosition() const { return fInPosition; } | 780 const Attribute* inPosition() const { return fInPosition; } |
781 | 781 |
782 const GrAttribute* inCoord() const { return fInCoord; } | 782 const Attribute* inCoord() const { return fInCoord; } |
783 | 783 |
784 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 784 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
785 | 785 |
786 const SkRect& getRect() const { return fRect; } | 786 const SkRect& getRect() const { return fRect; } |
787 | 787 |
788 SkScalar getIntervalLength() const { return fIntervalLength; } | 788 SkScalar getIntervalLength() const { return fIntervalLength; } |
789 | 789 |
790 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 790 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
791 const GrGLCaps& caps, | 791 const GrGLCaps& caps, |
792 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 792 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
793 | 793 |
794 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 794 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
795 const GrGLCaps&) const SK_O
VERRIDE; | 795 const GrGLCaps&) const SK_O
VERRIDE; |
796 | 796 |
797 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE; | 797 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE; |
798 | 798 |
799 bool onCanMakeEqual(const GrBatchTracker&, | 799 bool onCanMakeEqual(const GrBatchTracker&, |
800 const GrGeometryProcessor&, | 800 const GrGeometryProcessor&, |
801 const GrBatchTracker&) const SK_OVERRIDE; | 801 const GrBatchTracker&) const SK_OVERRIDE; |
802 | 802 |
803 private: | 803 private: |
804 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf
o, | 804 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf
o, |
805 SkScalar strokeWidth, const SkMatrix& localMatrix); | 805 SkScalar strokeWidth, const SkMatrix& localMatrix); |
806 | 806 |
807 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 807 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
808 | 808 |
809 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O
VERRIDE; | 809 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O
VERRIDE; |
810 | 810 |
811 GrPrimitiveEdgeType fEdgeType; | 811 GrPrimitiveEdgeType fEdgeType; |
812 const GrAttribute* fInPosition; | 812 const Attribute* fInPosition; |
813 const GrAttribute* fInCoord; | 813 const Attribute* fInCoord; |
814 SkRect fRect; | 814 SkRect fRect; |
815 SkScalar fIntervalLength; | 815 SkScalar fIntervalLength; |
816 | 816 |
817 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 817 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
818 | 818 |
819 typedef GrGeometryProcessor INHERITED; | 819 typedef GrGeometryProcessor INHERITED; |
820 }; | 820 }; |
821 | 821 |
822 ////////////////////////////////////////////////////////////////////////////// | 822 ////////////////////////////////////////////////////////////////////////////// |
823 | 823 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); | 989 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); |
990 } | 990 } |
991 | 991 |
992 DashingLineEffect::DashingLineEffect(GrColor color, | 992 DashingLineEffect::DashingLineEffect(GrColor color, |
993 GrPrimitiveEdgeType edgeType, | 993 GrPrimitiveEdgeType edgeType, |
994 const DashInfo& info, | 994 const DashInfo& info, |
995 SkScalar strokeWidth, | 995 SkScalar strokeWidth, |
996 const SkMatrix& localMatrix) | 996 const SkMatrix& localMatrix) |
997 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { | 997 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { |
998 this->initClassID<DashingLineEffect>(); | 998 this->initClassID<DashingLineEffect>(); |
999 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 999 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
1000 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr
ibType)); | 1000 fInCoord = &this->addVertexAttrib(Attribute("inCoord", kVec2f_GrVertexAttrib
Type)); |
1001 SkScalar onLen = info.fIntervals[0]; | 1001 SkScalar onLen = info.fIntervals[0]; |
1002 SkScalar offLen = info.fIntervals[1]; | 1002 SkScalar offLen = info.fIntervals[1]; |
1003 SkScalar halfOffLen = SkScalarHalf(offLen); | 1003 SkScalar halfOffLen = SkScalarHalf(offLen); |
1004 SkScalar halfStroke = SkScalarHalf(strokeWidth); | 1004 SkScalar halfStroke = SkScalarHalf(strokeWidth); |
1005 fIntervalLength = onLen + offLen; | 1005 fIntervalLength = onLen + offLen; |
1006 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); | 1006 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); |
1007 } | 1007 } |
1008 | 1008 |
1009 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const { | 1009 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const { |
1010 const DashingLineEffect& de = other.cast<DashingLineEffect>(); | 1010 const DashingLineEffect& de = other.cast<DashingLineEffect>(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 return DashingCircleEffect::Create(color, edgeType, info, | 1065 return DashingCircleEffect::Create(color, edgeType, info, |
1066 SkScalarHalf(strokeWidth), | 1066 SkScalarHalf(strokeWidth), |
1067 localMatrix); | 1067 localMatrix); |
1068 case GrDashingEffect::kNonRound_DashCap: | 1068 case GrDashingEffect::kNonRound_DashCap: |
1069 return DashingLineEffect::Create(color, edgeType, info, strokeWidth,
localMatrix); | 1069 return DashingLineEffect::Create(color, edgeType, info, strokeWidth,
localMatrix); |
1070 default: | 1070 default: |
1071 SkFAIL("Unexpected dashed cap."); | 1071 SkFAIL("Unexpected dashed cap."); |
1072 } | 1072 } |
1073 return NULL; | 1073 return NULL; |
1074 } | 1074 } |
OLD | NEW |