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

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

Issue 818233002: Remove coordchanges from drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@coord-change-off-paint
Patch Set: adding test to ignore 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/GrDashingEffect.h ('k') | no next file » | 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 SkPoint* verts) { 159 SkPoint* verts) {
160 verts[idx] = SkPoint::Make(rect.fLeft, rect.fTop); 160 verts[idx] = SkPoint::Make(rect.fLeft, rect.fTop);
161 verts[idx + 1] = SkPoint::Make(rect.fLeft, rect.fBottom); 161 verts[idx + 1] = SkPoint::Make(rect.fLeft, rect.fBottom);
162 verts[idx + 2] = SkPoint::Make(rect.fRight, rect.fBottom); 162 verts[idx + 2] = SkPoint::Make(rect.fRight, rect.fBottom);
163 verts[idx + 3] = SkPoint::Make(rect.fRight, rect.fTop); 163 verts[idx + 3] = SkPoint::Make(rect.fRight, rect.fTop);
164 matrix.mapPoints(&verts[idx], 4); 164 matrix.mapPoints(&verts[idx], 4);
165 } 165 }
166 166
167 bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState * drawState, 167 bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState * drawState,
168 GrColor color, const SkPoint pts[2], const Gr Paint& paint, 168 GrColor color, const SkPoint pts[2], const Gr Paint& paint,
169 const GrStrokeInfo& strokeInfo, const SkMatri x& vm) { 169 const GrStrokeInfo& strokeInfo) {
170 const SkMatrix& vm = drawState->getViewMatrix();
170 171
171 if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, vm)) { 172 if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, vm)) {
172 return false; 173 return false;
173 } 174 }
174 175
175 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); 176 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
176 177
177 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); 178 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap();
178 179
179 SkScalar srcStrokeWidth = strokeInfo.getStrokeRec().getWidth(); 180 SkScalar srcStrokeWidth = strokeInfo.getStrokeRec().getWidth();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 329
329 SkPoint devicePts[2]; 330 SkPoint devicePts[2];
330 vm.mapPoints(devicePts, ptsRot, 2); 331 vm.mapPoints(devicePts, ptsRot, 2);
331 SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]); 332 SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]);
332 if (hasCap) { 333 if (hasCap) {
333 lineLength += 2.f * halfDevStroke; 334 lineLength += 2.f * halfDevStroke;
334 } 335 }
335 devIntervals[0] = lineLength; 336 devIntervals[0] = lineLength;
336 } 337 }
337 338
339 // reset to device coordinates
340 SkMatrix invert;
341 if (!vm.invert(&invert)) {
342 SkDebugf("Failed to invert\n");
343 return false;
344 }
345
346 GrDrawState::AutoViewMatrixRestore avmr(drawState);
347
338 SkAutoTUnref<const GrGeometryProcessor> gp; 348 SkAutoTUnref<const GrGeometryProcessor> gp;
339 bool fullDash = devIntervals[1] > 0.f || useAA; 349 bool fullDash = devIntervals[1] > 0.f || useAA;
340 if (fullDash) { 350 if (fullDash) {
341 SkPathEffect::DashInfo devInfo; 351 SkPathEffect::DashInfo devInfo;
342 devInfo.fPhase = devPhase; 352 devInfo.fPhase = devPhase;
343 devInfo.fCount = 2; 353 devInfo.fCount = 2;
344 devInfo.fIntervals = devIntervals; 354 devInfo.fIntervals = devIntervals;
345 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType : 355 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType :
346 kFillBW_GrProcessorEdgeType; 356 kFillBW_GrProcessorEdgeType;
347 bool isRoundCap = SkPaint::kRound_Cap == cap; 357 bool isRoundCap = SkPaint::kRound_Cap == cap;
348 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap : 358 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap :
349 GrDashingEffect::kNonRou nd_DashCap; 359 GrDashingEffect::kNonRou nd_DashCap;
350 gp.reset(GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType)); 360 gp.reset(GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType, invert));
351 } else { 361 } else {
352 // Set up the vertex data for the line and start/end dashes 362 // Set up the vertex data for the line and start/end dashes
353 gp.reset(GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory: :kPosition_GPType)); 363 gp.reset(GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory: :kPosition_GPType,
364 invert));
354 } 365 }
355 366
356 int totalRectCnt = 0; 367 int totalRectCnt = 0;
357 368
358 totalRectCnt += !lineDone ? 1 : 0; 369 totalRectCnt += !lineDone ? 1 : 0;
359 totalRectCnt += hasStartRect ? 1 : 0; 370 totalRectCnt += hasStartRect ? 1 : 0;
360 totalRectCnt += hasEndRect ? 1 : 0; 371 totalRectCnt += hasEndRect ? 1 : 0;
361 372
362 GrDrawTarget::AutoReleaseGeometry geo(target, 373 GrDrawTarget::AutoReleaseGeometry geo(target,
363 totalRectCnt * 4, 374 totalRectCnt * 4,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 * transform the line to be horizontal, with the start of line at the origin the n shifted to the 468 * transform the line to be horizontal, with the start of line at the origin the n shifted to the
458 * right by half the off interval. The line then goes in the positive x directio n. 469 * right by half the off interval. The line then goes in the positive x directio n.
459 */ 470 */
460 class DashingCircleEffect : public GrGeometryProcessor { 471 class DashingCircleEffect : public GrGeometryProcessor {
461 public: 472 public:
462 typedef SkPathEffect::DashInfo DashInfo; 473 typedef SkPathEffect::DashInfo DashInfo;
463 474
464 static GrGeometryProcessor* Create(GrColor, 475 static GrGeometryProcessor* Create(GrColor,
465 GrPrimitiveEdgeType edgeType, 476 GrPrimitiveEdgeType edgeType,
466 const DashInfo& info, 477 const DashInfo& info,
467 SkScalar radius); 478 SkScalar radius,
479 const SkMatrix& localMatrix);
468 480
469 virtual ~DashingCircleEffect(); 481 virtual ~DashingCircleEffect();
470 482
471 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; } 483 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; }
472 484
473 const GrAttribute* inPosition() const { return fInPosition; } 485 const GrAttribute* inPosition() const { return fInPosition; }
474 486
475 const GrAttribute* inCoord() const { return fInCoord; } 487 const GrAttribute* inCoord() const { return fInCoord; }
476 488
477 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 489 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
(...skipping 11 matching lines...) Expand all
489 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE; 501 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE;
490 502
491 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE; 503 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE;
492 504
493 bool onCanMakeEqual(const GrBatchTracker&, 505 bool onCanMakeEqual(const GrBatchTracker&,
494 const GrGeometryProcessor&, 506 const GrGeometryProcessor&,
495 const GrBatchTracker&) const SK_OVERRIDE; 507 const GrBatchTracker&) const SK_OVERRIDE;
496 508
497 private: 509 private:
498 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo, 510 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo,
499 SkScalar radius); 511 SkScalar radius, const SkMatrix& localMatrix);
500 512
501 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 513 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
502 514
503 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE; 515 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
504 516
505 GrPrimitiveEdgeType fEdgeType; 517 GrPrimitiveEdgeType fEdgeType;
506 const GrAttribute* fInPosition; 518 const GrAttribute* fInPosition;
507 const GrAttribute* fInCoord; 519 const GrAttribute* fInCoord;
508 SkScalar fIntervalLength; 520 SkScalar fIntervalLength;
509 SkScalar fRadius; 521 SkScalar fRadius;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>(); 638 const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
627 b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective()) ; 639 b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective()) ;
628 b->add32(dce.getEdgeType() << 16 | local.fInputColorType); 640 b->add32(dce.getEdgeType() << 16 | local.fInputColorType);
629 } 641 }
630 642
631 ////////////////////////////////////////////////////////////////////////////// 643 //////////////////////////////////////////////////////////////////////////////
632 644
633 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, 645 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
634 GrPrimitiveEdgeType edgeType, 646 GrPrimitiveEdgeType edgeType,
635 const DashInfo& info, 647 const DashInfo& info,
636 SkScalar radius) { 648 SkScalar radius,
649 const SkMatrix& localMatrix) {
637 if (info.fCount != 2 || info.fIntervals[0] != 0) { 650 if (info.fCount != 2 || info.fIntervals[0] != 0) {
638 return NULL; 651 return NULL;
639 } 652 }
640 653
641 return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius)); 654 return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius, local Matrix));
642 } 655 }
643 656
644 DashingCircleEffect::~DashingCircleEffect() {} 657 DashingCircleEffect::~DashingCircleEffect() {}
645 658
646 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const { 659 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const {
647 out->setUnknownSingleComponent(); 660 out->setUnknownSingleComponent();
648 } 661 }
649 662
650 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 663 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
651 const GrGLCaps& caps, 664 const GrGLCaps& caps,
652 GrProcessorKeyBuilder* b) const { 665 GrProcessorKeyBuilder* b) const {
653 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 666 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
654 } 667 }
655 668
656 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const { 669 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const {
657 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 670 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
658 } 671 }
659 672
660 DashingCircleEffect::DashingCircleEffect(GrColor color, 673 DashingCircleEffect::DashingCircleEffect(GrColor color,
661 GrPrimitiveEdgeType edgeType, 674 GrPrimitiveEdgeType edgeType,
662 const DashInfo& info, 675 const DashInfo& info,
663 SkScalar radius) 676 SkScalar radius,
664 : INHERITED(color), fEdgeType(edgeType) { 677 const SkMatrix& localMatrix)
678 : INHERITED(color, false, localMatrix), fEdgeType(edgeType) {
665 this->initClassID<DashingCircleEffect>(); 679 this->initClassID<DashingCircleEffect>();
666 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 680 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType));
667 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 681 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType));
668 SkScalar onLen = info.fIntervals[0]; 682 SkScalar onLen = info.fIntervals[0];
669 SkScalar offLen = info.fIntervals[1]; 683 SkScalar offLen = info.fIntervals[1];
670 fIntervalLength = onLen + offLen; 684 fIntervalLength = onLen + offLen;
671 fRadius = radius; 685 fRadius = radius;
672 fCenterX = SkScalarHalf(offLen); 686 fCenterX = SkScalarHalf(offLen);
673 } 687 }
674 688
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 kGrProcessorEdgeTypeCnt)); 721 kGrProcessorEdgeTypeCnt));
708 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f); 722 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
709 DashInfo info; 723 DashInfo info;
710 info.fCount = 2; 724 info.fCount = 2;
711 SkAutoTArray<SkScalar> intervals(info.fCount); 725 SkAutoTArray<SkScalar> intervals(info.fCount);
712 info.fIntervals = intervals.get(); 726 info.fIntervals = intervals.get();
713 info.fIntervals[0] = 0; 727 info.fIntervals[0] = 0;
714 info.fIntervals[1] = random->nextRangeScalar(0, 10.f); 728 info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
715 info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]); 729 info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]);
716 730
717 return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, st rokeWidth); 731 return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, st rokeWidth,
732 GrProcessorUnitTest::TestMatrix(random));
718 } 733 }
719 734
720 ////////////////////////////////////////////////////////////////////////////// 735 //////////////////////////////////////////////////////////////////////////////
721 736
722 class GLDashingLineEffect; 737 class GLDashingLineEffect;
723 738
724 struct DashingLineBatchTracker { 739 struct DashingLineBatchTracker {
725 GrGPInput fInputColorType; 740 GrGPInput fInputColorType;
726 GrColor fColor; 741 GrColor fColor;
727 bool fUsesLocalCoords; 742 bool fUsesLocalCoords;
728 }; 743 };
729 744
730 /* 745 /*
731 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the 746 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the
732 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space. 747 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space.
733 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the 748 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the
734 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the 749 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the
735 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of 750 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of
736 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the 751 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the
737 * positive x direction. 752 * positive x direction.
738 */ 753 */
739 class DashingLineEffect : public GrGeometryProcessor { 754 class DashingLineEffect : public GrGeometryProcessor {
740 public: 755 public:
741 typedef SkPathEffect::DashInfo DashInfo; 756 typedef SkPathEffect::DashInfo DashInfo;
742 757
743 static GrGeometryProcessor* Create(GrColor, 758 static GrGeometryProcessor* Create(GrColor,
744 GrPrimitiveEdgeType edgeType, 759 GrPrimitiveEdgeType edgeType,
745 const DashInfo& info, 760 const DashInfo& info,
746 SkScalar strokeWidth); 761 SkScalar strokeWidth,
762 const SkMatrix& localMatrix);
747 763
748 virtual ~DashingLineEffect(); 764 virtual ~DashingLineEffect();
749 765
750 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; } 766 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; }
751 767
752 const GrAttribute* inPosition() const { return fInPosition; } 768 const GrAttribute* inPosition() const { return fInPosition; }
753 769
754 const GrAttribute* inCoord() const { return fInCoord; } 770 const GrAttribute* inCoord() const { return fInCoord; }
755 771
756 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 772 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
757 773
758 const SkRect& getRect() const { return fRect; } 774 const SkRect& getRect() const { return fRect; }
759 775
760 SkScalar getIntervalLength() const { return fIntervalLength; } 776 SkScalar getIntervalLength() const { return fIntervalLength; }
761 777
762 virtual void getGLProcessorKey(const GrBatchTracker& bt, 778 virtual void getGLProcessorKey(const GrBatchTracker& bt,
763 const GrGLCaps& caps, 779 const GrGLCaps& caps,
764 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 780 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
765 781
766 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE; 782 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE;
767 783
768 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE; 784 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE;
769 785
770 bool onCanMakeEqual(const GrBatchTracker&, 786 bool onCanMakeEqual(const GrBatchTracker&,
771 const GrGeometryProcessor&, 787 const GrGeometryProcessor&,
772 const GrBatchTracker&) const SK_OVERRIDE; 788 const GrBatchTracker&) const SK_OVERRIDE;
773 789
774 private: 790 private:
775 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o, 791 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o,
776 SkScalar strokeWidth); 792 SkScalar strokeWidth, const SkMatrix& localMatrix);
777 793
778 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 794 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
779 795
780 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE; 796 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
781 797
782 GrPrimitiveEdgeType fEdgeType; 798 GrPrimitiveEdgeType fEdgeType;
783 const GrAttribute* fInPosition; 799 const GrAttribute* fInPosition;
784 const GrAttribute* fInCoord; 800 const GrAttribute* fInCoord;
785 SkRect fRect; 801 SkRect fRect;
786 SkScalar fIntervalLength; 802 SkScalar fIntervalLength;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 const DashingLineEffect& de = processor.cast<DashingLineEffect>(); 932 const DashingLineEffect& de = processor.cast<DashingLineEffect>();
917 b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective()) ; 933 b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective()) ;
918 b->add32(de.getEdgeType() << 16 | local.fInputColorType); 934 b->add32(de.getEdgeType() << 16 | local.fInputColorType);
919 } 935 }
920 936
921 ////////////////////////////////////////////////////////////////////////////// 937 //////////////////////////////////////////////////////////////////////////////
922 938
923 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, 939 GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
924 GrPrimitiveEdgeType edgeType, 940 GrPrimitiveEdgeType edgeType,
925 const DashInfo& info, 941 const DashInfo& info,
926 SkScalar strokeWidth) { 942 SkScalar strokeWidth,
943 const SkMatrix& localMatrix) {
927 if (info.fCount != 2) { 944 if (info.fCount != 2) {
928 return NULL; 945 return NULL;
929 } 946 }
930 947
931 return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth)); 948 return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth, lo calMatrix));
932 } 949 }
933 950
934 DashingLineEffect::~DashingLineEffect() {} 951 DashingLineEffect::~DashingLineEffect() {}
935 952
936 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const { 953 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
937 out->setUnknownSingleComponent(); 954 out->setUnknownSingleComponent();
938 } 955 }
939 956
940 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 957 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
941 const GrGLCaps& caps, 958 const GrGLCaps& caps,
942 GrProcessorKeyBuilder* b) const { 959 GrProcessorKeyBuilder* b) const {
943 GLDashingLineEffect::GenKey(*this, bt, caps, b); 960 GLDashingLineEffect::GenKey(*this, bt, caps, b);
944 } 961 }
945 962
946 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const { 963 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const {
947 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 964 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
948 } 965 }
949 966
950 DashingLineEffect::DashingLineEffect(GrColor color, 967 DashingLineEffect::DashingLineEffect(GrColor color,
951 GrPrimitiveEdgeType edgeType, 968 GrPrimitiveEdgeType edgeType,
952 const DashInfo& info, 969 const DashInfo& info,
953 SkScalar strokeWidth) 970 SkScalar strokeWidth,
954 : INHERITED(color), fEdgeType(edgeType) { 971 const SkMatrix& localMatrix)
972 : INHERITED(color, false, localMatrix), fEdgeType(edgeType) {
955 this->initClassID<DashingLineEffect>(); 973 this->initClassID<DashingLineEffect>();
956 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 974 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType));
957 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 975 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType));
958 SkScalar onLen = info.fIntervals[0]; 976 SkScalar onLen = info.fIntervals[0];
959 SkScalar offLen = info.fIntervals[1]; 977 SkScalar offLen = info.fIntervals[1];
960 SkScalar halfOffLen = SkScalarHalf(offLen); 978 SkScalar halfOffLen = SkScalarHalf(offLen);
961 SkScalar halfStroke = SkScalarHalf(strokeWidth); 979 SkScalar halfStroke = SkScalarHalf(strokeWidth);
962 fIntervalLength = onLen + offLen; 980 fIntervalLength = onLen + offLen;
963 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); 981 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke);
964 } 982 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 kGrProcessorEdgeTypeCnt)); 1015 kGrProcessorEdgeTypeCnt));
998 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f); 1016 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
999 DashInfo info; 1017 DashInfo info;
1000 info.fCount = 2; 1018 info.fCount = 2;
1001 SkAutoTArray<SkScalar> intervals(info.fCount); 1019 SkAutoTArray<SkScalar> intervals(info.fCount);
1002 info.fIntervals = intervals.get(); 1020 info.fIntervals = intervals.get();
1003 info.fIntervals[0] = random->nextRangeScalar(0, 10.f); 1021 info.fIntervals[0] = random->nextRangeScalar(0, 10.f);
1004 info.fIntervals[1] = random->nextRangeScalar(0, 10.f); 1022 info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
1005 info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fInterval s[1]); 1023 info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fInterval s[1]);
1006 1024
1007 return DashingLineEffect::Create(GrRandomColor(random), edgeType, info, stro keWidth); 1025 return DashingLineEffect::Create(GrRandomColor(random), edgeType, info, stro keWidth,
1026 GrProcessorUnitTest::TestMatrix(random));
1008 } 1027 }
1009 1028
1010 ////////////////////////////////////////////////////////////////////////////// 1029 //////////////////////////////////////////////////////////////////////////////
1011 1030
1012 GrGeometryProcessor* GrDashingEffect::Create(GrColor color, 1031 GrGeometryProcessor* GrDashingEffect::Create(GrColor color,
1013 GrPrimitiveEdgeType edgeType, 1032 GrPrimitiveEdgeType edgeType,
1014 const SkPathEffect::DashInfo& info, 1033 const SkPathEffect::DashInfo& info,
1015 SkScalar strokeWidth, 1034 SkScalar strokeWidth,
1016 GrDashingEffect::DashCap cap) { 1035 GrDashingEffect::DashCap cap,
1036 const SkMatrix& localMatrix) {
1017 switch (cap) { 1037 switch (cap) {
1018 case GrDashingEffect::kRound_DashCap: 1038 case GrDashingEffect::kRound_DashCap:
1019 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth)); 1039 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth),
1040 localMatrix);
1020 case GrDashingEffect::kNonRound_DashCap: 1041 case GrDashingEffect::kNonRound_DashCap:
1021 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ; 1042 return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix);
1022 default: 1043 default:
1023 SkFAIL("Unexpected dashed cap."); 1044 SkFAIL("Unexpected dashed cap.");
1024 } 1045 }
1025 return NULL; 1046 return NULL;
1026 } 1047 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDashingEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698