Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 820783005: More changes to bring together path / geo procs (Closed) Base URL: https://skia.googlesource.com/skia.git@lc1
Patch Set: dm fix Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; } 481 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
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 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 512 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
513 513
514 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE; 514 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 678 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
679 } 679 }
680 680
681 DashingCircleEffect::DashingCircleEffect(GrColor color, 681 DashingCircleEffect::DashingCircleEffect(GrColor color,
682 GrPrimitiveEdgeType edgeType, 682 GrPrimitiveEdgeType edgeType,
683 const DashInfo& info, 683 const DashInfo& info,
684 SkScalar radius, 684 SkScalar radius,
685 const SkMatrix& localMatrix) 685 const SkMatrix& localMatrix)
686 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { 686 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) {
687 this->initClassID<DashingCircleEffect>(); 687 this->initClassID<DashingCircleEffect>();
688 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 688 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
689 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 689 fInCoord = &this->addVertexAttrib(Attribute("inCoord", kVec2f_GrVertexAttrib Type));
690 SkScalar onLen = info.fIntervals[0]; 690 SkScalar onLen = info.fIntervals[0];
691 SkScalar offLen = info.fIntervals[1]; 691 SkScalar offLen = info.fIntervals[1];
692 fIntervalLength = onLen + offLen; 692 fIntervalLength = onLen + offLen;
693 fRadius = radius; 693 fRadius = radius;
694 fCenterX = SkScalarHalf(offLen); 694 fCenterX = SkScalarHalf(offLen);
695 } 695 }
696 696
697 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const { 697 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const {
698 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); 698 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
699 return (fEdgeType == dce.fEdgeType && 699 return (fEdgeType == dce.fEdgeType &&
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 static GrGeometryProcessor* Create(GrColor, 767 static GrGeometryProcessor* Create(GrColor,
768 GrPrimitiveEdgeType edgeType, 768 GrPrimitiveEdgeType edgeType,
769 const DashInfo& info, 769 const DashInfo& info,
770 SkScalar strokeWidth, 770 SkScalar strokeWidth,
771 const SkMatrix& localMatrix); 771 const SkMatrix& localMatrix);
772 772
773 virtual ~DashingLineEffect(); 773 virtual ~DashingLineEffect();
774 774
775 const char* name() const SK_OVERRIDE { return "DashingEffect"; } 775 const char* name() const SK_OVERRIDE { return "DashingEffect"; }
776 776
777 const GrAttribute* inPosition() const { return fInPosition; } 777 const Attribute* inPosition() const { return fInPosition; }
778 778
779 const GrAttribute* inCoord() const { return fInCoord; } 779 const Attribute* inCoord() const { return fInCoord; }
780 780
781 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 781 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
782 782
783 const SkRect& getRect() const { return fRect; } 783 const SkRect& getRect() const { return fRect; }
784 784
785 SkScalar getIntervalLength() const { return fIntervalLength; } 785 SkScalar getIntervalLength() const { return fIntervalLength; }
786 786
787 virtual void getGLProcessorKey(const GrBatchTracker& bt, 787 virtual void getGLProcessorKey(const GrBatchTracker& bt,
788 const GrGLCaps& caps, 788 const GrGLCaps& caps,
789 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 789 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
790 790
791 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 791 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
792 const GrGLCaps&) const SK_O VERRIDE; 792 const GrGLCaps&) const SK_O VERRIDE;
793 793
794 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE; 794 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE;
795 795
796 bool onCanMakeEqual(const GrBatchTracker&, 796 bool onCanMakeEqual(const GrBatchTracker&,
797 const GrGeometryProcessor&, 797 const GrGeometryProcessor&,
798 const GrBatchTracker&) const SK_OVERRIDE; 798 const GrBatchTracker&) const SK_OVERRIDE;
799 799
800 private: 800 private:
801 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o, 801 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o,
802 SkScalar strokeWidth, const SkMatrix& localMatrix); 802 SkScalar strokeWidth, const SkMatrix& localMatrix);
803 803
804 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 804 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
805 805
806 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE; 806 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
807 807
808 GrPrimitiveEdgeType fEdgeType; 808 GrPrimitiveEdgeType fEdgeType;
809 const GrAttribute* fInPosition; 809 const Attribute* fInPosition;
810 const GrAttribute* fInCoord; 810 const Attribute* fInCoord;
811 SkRect fRect; 811 SkRect fRect;
812 SkScalar fIntervalLength; 812 SkScalar fIntervalLength;
813 813
814 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 814 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
815 815
816 typedef GrGeometryProcessor INHERITED; 816 typedef GrGeometryProcessor INHERITED;
817 }; 817 };
818 818
819 ////////////////////////////////////////////////////////////////////////////// 819 //////////////////////////////////////////////////////////////////////////////
820 820
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 983 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
984 } 984 }
985 985
986 DashingLineEffect::DashingLineEffect(GrColor color, 986 DashingLineEffect::DashingLineEffect(GrColor color,
987 GrPrimitiveEdgeType edgeType, 987 GrPrimitiveEdgeType edgeType,
988 const DashInfo& info, 988 const DashInfo& info,
989 SkScalar strokeWidth, 989 SkScalar strokeWidth,
990 const SkMatrix& localMatrix) 990 const SkMatrix& localMatrix)
991 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) { 991 : INHERITED(color, SkMatrix::I(), localMatrix), fEdgeType(edgeType) {
992 this->initClassID<DashingLineEffect>(); 992 this->initClassID<DashingLineEffect>();
993 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 993 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
994 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 994 fInCoord = &this->addVertexAttrib(Attribute("inCoord", kVec2f_GrVertexAttrib Type));
995 SkScalar onLen = info.fIntervals[0]; 995 SkScalar onLen = info.fIntervals[0];
996 SkScalar offLen = info.fIntervals[1]; 996 SkScalar offLen = info.fIntervals[1];
997 SkScalar halfOffLen = SkScalarHalf(offLen); 997 SkScalar halfOffLen = SkScalarHalf(offLen);
998 SkScalar halfStroke = SkScalarHalf(strokeWidth); 998 SkScalar halfStroke = SkScalarHalf(strokeWidth);
999 fIntervalLength = onLen + offLen; 999 fIntervalLength = onLen + offLen;
1000 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); 1000 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke);
1001 } 1001 }
1002 1002
1003 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const { 1003 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const {
1004 const DashingLineEffect& de = other.cast<DashingLineEffect>(); 1004 const DashingLineEffect& de = other.cast<DashingLineEffect>();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 return DashingCircleEffect::Create(color, edgeType, info, 1059 return DashingCircleEffect::Create(color, edgeType, info,
1060 SkScalarHalf(strokeWidth), 1060 SkScalarHalf(strokeWidth),
1061 localMatrix); 1061 localMatrix);
1062 case GrDashingEffect::kNonRound_DashCap: 1062 case GrDashingEffect::kNonRound_DashCap:
1063 return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix); 1063 return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix);
1064 default: 1064 default:
1065 SkFAIL("Unexpected dashed cap."); 1065 SkFAIL("Unexpected dashed cap.");
1066 } 1066 }
1067 return NULL; 1067 return NULL;
1068 } 1068 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698