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

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

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: todo added Created 6 years 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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m atrix, 158 static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m atrix,
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 const SkPoint pts[2], const GrPaint& paint, 168 GrColor color, const SkPoint pts[2], const Gr Paint& paint,
169 const GrStrokeInfo& strokeInfo, const SkMatri x& vm) { 169 const GrStrokeInfo& strokeInfo, const SkMatri x& vm) {
170 170
171 if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, vm)) { 171 if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, vm)) {
172 return false; 172 return false;
173 } 173 }
174 174
175 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); 175 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
176 176
177 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); 177 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap();
178 178
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (fullDash) { 340 if (fullDash) {
341 SkPathEffect::DashInfo devInfo; 341 SkPathEffect::DashInfo devInfo;
342 devInfo.fPhase = devPhase; 342 devInfo.fPhase = devPhase;
343 devInfo.fCount = 2; 343 devInfo.fCount = 2;
344 devInfo.fIntervals = devIntervals; 344 devInfo.fIntervals = devIntervals;
345 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType : 345 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType :
346 kFillBW_GrProcessorEdgeType; 346 kFillBW_GrProcessorEdgeType;
347 bool isRoundCap = SkPaint::kRound_Cap == cap; 347 bool isRoundCap = SkPaint::kRound_Cap == cap;
348 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap : 348 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap :
349 GrDashingEffect::kNonRou nd_DashCap; 349 GrDashingEffect::kNonRou nd_DashCap;
350 gp = GrDashingEffect::Create(edgeType, devInfo, strokeWidth, capType); 350 gp = GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capT ype);
351 } else { 351 } else {
352 // Set up the vertex data for the line and start/end dashes 352 // Set up the vertex data for the line and start/end dashes
353 gp = GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_ GPType); 353 gp = GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory::kPo sition_GPType);
354 } 354 }
355 355
356 drawState->setGeometryProcessor(gp)->unref(); 356 drawState->setGeometryProcessor(gp)->unref();
357 357
358 int totalRectCnt = 0; 358 int totalRectCnt = 0;
359 359
360 totalRectCnt += !lineDone ? 1 : 0; 360 totalRectCnt += !lineDone ? 1 : 0;
361 totalRectCnt += hasStartRect ? 1 : 0; 361 totalRectCnt += hasStartRect ? 1 : 0;
362 totalRectCnt += hasEndRect ? 1 : 0; 362 totalRectCnt += hasEndRect ? 1 : 0;
363 363
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 * Both of the previous two parameters are in device space. This effect also req uires the setting of 449 * Both of the previous two parameters are in device space. This effect also req uires the setting of
450 * a vec2 vertex attribute for the the four corners of the bounding rect. This a ttribute is the 450 * a vec2 vertex attribute for the the four corners of the bounding rect. This a ttribute is the
451 * "dash position" of each vertex. In other words it is the vertex coords (in de vice space) if we 451 * "dash position" of each vertex. In other words it is the vertex coords (in de vice space) if we
452 * transform the line to be horizontal, with the start of line at the origin the n shifted to the 452 * transform the line to be horizontal, with the start of line at the origin the n shifted to the
453 * right by half the off interval. The line then goes in the positive x directio n. 453 * right by half the off interval. The line then goes in the positive x directio n.
454 */ 454 */
455 class DashingCircleEffect : public GrGeometryProcessor { 455 class DashingCircleEffect : public GrGeometryProcessor {
456 public: 456 public:
457 typedef SkPathEffect::DashInfo DashInfo; 457 typedef SkPathEffect::DashInfo DashInfo;
458 458
459 static GrGeometryProcessor* Create(GrPrimitiveEdgeType edgeType, 459 static GrGeometryProcessor* Create(GrColor,
460 GrPrimitiveEdgeType edgeType,
460 const DashInfo& info, 461 const DashInfo& info,
461 SkScalar radius); 462 SkScalar radius);
462 463
463 virtual ~DashingCircleEffect(); 464 virtual ~DashingCircleEffect();
464 465
465 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; } 466 virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; }
466 467
467 const GrAttribute* inPosition() const { return fInPosition; } 468 const GrAttribute* inPosition() const { return fInPosition; }
468 469
469 const GrAttribute* inCoord() const { return fInCoord; } 470 const GrAttribute* inCoord() const { return fInCoord; }
470 471
471 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 472 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
472 473
473 SkScalar getRadius() const { return fRadius; } 474 SkScalar getRadius() const { return fRadius; }
474 475
475 SkScalar getCenterX() const { return fCenterX; } 476 SkScalar getCenterX() const { return fCenterX; }
476 477
477 SkScalar getIntervalLength() const { return fIntervalLength; } 478 SkScalar getIntervalLength() const { return fIntervalLength; }
478 479
479 virtual void getGLProcessorKey(const GrBatchTracker&, 480 virtual void getGLProcessorKey(const GrBatchTracker&,
480 const GrGLCaps&, 481 const GrGLCaps&,
481 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 482 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
482 483
483 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE; 484 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE;
484 485
485 private: 486 private:
486 DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkSc alar radius); 487 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo,
488 SkScalar radius);
487 489
488 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 490 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
489 491
490 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; 492 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE;
491 493
492 GrPrimitiveEdgeType fEdgeType; 494 GrPrimitiveEdgeType fEdgeType;
493 const GrAttribute* fInPosition; 495 const GrAttribute* fInPosition;
494 const GrAttribute* fInCoord; 496 const GrAttribute* fInCoord;
495 SkScalar fIntervalLength; 497 SkScalar fIntervalLength;
496 SkScalar fRadius; 498 SkScalar fRadius;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor, 595 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor,
594 const GrBatchTracker&, 596 const GrBatchTracker&,
595 const GrGLCaps&, 597 const GrGLCaps&,
596 GrProcessorKeyBuilder* b) { 598 GrProcessorKeyBuilder* b) {
597 const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>(); 599 const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
598 b->add32(dce.getEdgeType()); 600 b->add32(dce.getEdgeType());
599 } 601 }
600 602
601 ////////////////////////////////////////////////////////////////////////////// 603 //////////////////////////////////////////////////////////////////////////////
602 604
603 GrGeometryProcessor* DashingCircleEffect::Create(GrPrimitiveEdgeType edgeType, c onst DashInfo& info, 605 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
606 GrPrimitiveEdgeType edgeType,
607 const DashInfo& info,
604 SkScalar radius) { 608 SkScalar radius) {
605 if (info.fCount != 2 || info.fIntervals[0] != 0) { 609 if (info.fCount != 2 || info.fIntervals[0] != 0) {
606 return NULL; 610 return NULL;
607 } 611 }
608 612
609 return SkNEW_ARGS(DashingCircleEffect, (edgeType, info, radius)); 613 return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius));
610 } 614 }
611 615
612 DashingCircleEffect::~DashingCircleEffect() {} 616 DashingCircleEffect::~DashingCircleEffect() {}
613 617
614 void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con st { 618 void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con st {
615 inout->mulByUnknownAlpha(); 619 inout->mulByUnknownAlpha();
616 } 620 }
617 621
618 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 622 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
619 const GrGLCaps& caps, 623 const GrGLCaps& caps,
620 GrProcessorKeyBuilder* b) const { 624 GrProcessorKeyBuilder* b) const {
621 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 625 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
622 } 626 }
623 627
624 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const { 628 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const {
625 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 629 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
626 } 630 }
627 631
628 DashingCircleEffect::DashingCircleEffect(GrPrimitiveEdgeType edgeType, const Das hInfo& info, 632 DashingCircleEffect::DashingCircleEffect(GrColor color,
633 GrPrimitiveEdgeType edgeType,
634 const DashInfo& info,
629 SkScalar radius) 635 SkScalar radius)
630 : fEdgeType(edgeType) { 636 : INHERITED(color), fEdgeType(edgeType) {
631 this->initClassID<DashingCircleEffect>(); 637 this->initClassID<DashingCircleEffect>();
632 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 638 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType));
633 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 639 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType));
634 SkScalar onLen = info.fIntervals[0]; 640 SkScalar onLen = info.fIntervals[0];
635 SkScalar offLen = info.fIntervals[1]; 641 SkScalar offLen = info.fIntervals[1];
636 fIntervalLength = onLen + offLen; 642 fIntervalLength = onLen + offLen;
637 fRadius = radius; 643 fRadius = radius;
638 fCenterX = SkScalarHalf(offLen); 644 fCenterX = SkScalarHalf(offLen);
639 } 645 }
640 646
(...skipping 15 matching lines...) Expand all
656 kGrProcessorEdgeTypeCnt)); 662 kGrProcessorEdgeTypeCnt));
657 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f); 663 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
658 DashInfo info; 664 DashInfo info;
659 info.fCount = 2; 665 info.fCount = 2;
660 SkAutoTArray<SkScalar> intervals(info.fCount); 666 SkAutoTArray<SkScalar> intervals(info.fCount);
661 info.fIntervals = intervals.get(); 667 info.fIntervals = intervals.get();
662 info.fIntervals[0] = 0; 668 info.fIntervals[0] = 0;
663 info.fIntervals[1] = random->nextRangeScalar(0, 10.f); 669 info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
664 info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]); 670 info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]);
665 671
666 return DashingCircleEffect::Create(edgeType, info, strokeWidth); 672 return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, st rokeWidth);
667 } 673 }
668 674
669 ////////////////////////////////////////////////////////////////////////////// 675 //////////////////////////////////////////////////////////////////////////////
670 676
671 class GLDashingLineEffect; 677 class GLDashingLineEffect;
672 678
673 /* 679 /*
674 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the 680 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the
675 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space. 681 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space.
676 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the 682 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the
677 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the 683 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the
678 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of 684 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of
679 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the 685 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the
680 * positive x direction. 686 * positive x direction.
681 */ 687 */
682 class DashingLineEffect : public GrGeometryProcessor { 688 class DashingLineEffect : public GrGeometryProcessor {
683 public: 689 public:
684 typedef SkPathEffect::DashInfo DashInfo; 690 typedef SkPathEffect::DashInfo DashInfo;
685 691
686 static GrGeometryProcessor* Create(GrPrimitiveEdgeType edgeType, 692 static GrGeometryProcessor* Create(GrColor,
693 GrPrimitiveEdgeType edgeType,
687 const DashInfo& info, 694 const DashInfo& info,
688 SkScalar strokeWidth); 695 SkScalar strokeWidth);
689 696
690 virtual ~DashingLineEffect(); 697 virtual ~DashingLineEffect();
691 698
692 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; } 699 virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; }
693 700
694 const GrAttribute* inPosition() const { return fInPosition; } 701 const GrAttribute* inPosition() const { return fInPosition; }
695 702
696 const GrAttribute* inCoord() const { return fInCoord; } 703 const GrAttribute* inCoord() const { return fInCoord; }
697 704
698 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 705 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
699 706
700 const SkRect& getRect() const { return fRect; } 707 const SkRect& getRect() const { return fRect; }
701 708
702 SkScalar getIntervalLength() const { return fIntervalLength; } 709 SkScalar getIntervalLength() const { return fIntervalLength; }
703 710
704 virtual void getGLProcessorKey(const GrBatchTracker& bt, 711 virtual void getGLProcessorKey(const GrBatchTracker& bt,
705 const GrGLCaps& caps, 712 const GrGLCaps& caps,
706 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 713 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
707 714
708 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE; 715 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE;
709 716
710 private: 717 private:
711 DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScal ar strokeWidth); 718 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o,
719 SkScalar strokeWidth);
712 720
713 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 721 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
714 722
715 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; 723 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE;
716 724
717 GrPrimitiveEdgeType fEdgeType; 725 GrPrimitiveEdgeType fEdgeType;
718 const GrAttribute* fInPosition; 726 const GrAttribute* fInPosition;
719 const GrAttribute* fInCoord; 727 const GrAttribute* fInCoord;
720 SkRect fRect; 728 SkRect fRect;
721 SkScalar fIntervalLength; 729 SkScalar fIntervalLength;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor, 838 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor,
831 const GrBatchTracker&, 839 const GrBatchTracker&,
832 const GrGLCaps&, 840 const GrGLCaps&,
833 GrProcessorKeyBuilder* b) { 841 GrProcessorKeyBuilder* b) {
834 const DashingLineEffect& de = processor.cast<DashingLineEffect>(); 842 const DashingLineEffect& de = processor.cast<DashingLineEffect>();
835 b->add32(de.getEdgeType()); 843 b->add32(de.getEdgeType());
836 } 844 }
837 845
838 ////////////////////////////////////////////////////////////////////////////// 846 //////////////////////////////////////////////////////////////////////////////
839 847
840 GrGeometryProcessor* DashingLineEffect::Create(GrPrimitiveEdgeType edgeType, 848 GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
849 GrPrimitiveEdgeType edgeType,
841 const DashInfo& info, 850 const DashInfo& info,
842 SkScalar strokeWidth) { 851 SkScalar strokeWidth) {
843 if (info.fCount != 2) { 852 if (info.fCount != 2) {
844 return NULL; 853 return NULL;
845 } 854 }
846 855
847 return SkNEW_ARGS(DashingLineEffect, (edgeType, info, strokeWidth)); 856 return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth));
848 } 857 }
849 858
850 DashingLineEffect::~DashingLineEffect() {} 859 DashingLineEffect::~DashingLineEffect() {}
851 860
852 void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 861 void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
853 inout->mulByUnknownAlpha(); 862 inout->mulByUnknownAlpha();
854 } 863 }
855 864
856 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 865 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
857 const GrGLCaps& caps, 866 const GrGLCaps& caps,
858 GrProcessorKeyBuilder* b) const { 867 GrProcessorKeyBuilder* b) const {
859 GLDashingLineEffect::GenKey(*this, bt, caps, b); 868 GLDashingLineEffect::GenKey(*this, bt, caps, b);
860 } 869 }
861 870
862 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const { 871 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const {
863 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 872 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
864 } 873 }
865 874
866 DashingLineEffect::DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInf o& info, 875 DashingLineEffect::DashingLineEffect(GrColor color,
876 GrPrimitiveEdgeType edgeType,
877 const DashInfo& info,
867 SkScalar strokeWidth) 878 SkScalar strokeWidth)
868 : fEdgeType(edgeType) { 879 : INHERITED(color), fEdgeType(edgeType) {
869 this->initClassID<DashingLineEffect>(); 880 this->initClassID<DashingLineEffect>();
870 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 881 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType));
871 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType)); 882 fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttr ibType));
872 SkScalar onLen = info.fIntervals[0]; 883 SkScalar onLen = info.fIntervals[0];
873 SkScalar offLen = info.fIntervals[1]; 884 SkScalar offLen = info.fIntervals[1];
874 SkScalar halfOffLen = SkScalarHalf(offLen); 885 SkScalar halfOffLen = SkScalarHalf(offLen);
875 SkScalar halfStroke = SkScalarHalf(strokeWidth); 886 SkScalar halfStroke = SkScalarHalf(strokeWidth);
876 fIntervalLength = onLen + offLen; 887 fIntervalLength = onLen + offLen;
877 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke); 888 fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke);
878 } 889 }
(...skipping 15 matching lines...) Expand all
894 kGrProcessorEdgeTypeCnt)); 905 kGrProcessorEdgeTypeCnt));
895 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f); 906 SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
896 DashInfo info; 907 DashInfo info;
897 info.fCount = 2; 908 info.fCount = 2;
898 SkAutoTArray<SkScalar> intervals(info.fCount); 909 SkAutoTArray<SkScalar> intervals(info.fCount);
899 info.fIntervals = intervals.get(); 910 info.fIntervals = intervals.get();
900 info.fIntervals[0] = random->nextRangeScalar(0, 10.f); 911 info.fIntervals[0] = random->nextRangeScalar(0, 10.f);
901 info.fIntervals[1] = random->nextRangeScalar(0, 10.f); 912 info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
902 info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fInterval s[1]); 913 info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fInterval s[1]);
903 914
904 return DashingLineEffect::Create(edgeType, info, strokeWidth); 915 return DashingLineEffect::Create(GrRandomColor(random), edgeType, info, stro keWidth);
905 } 916 }
906 917
907 ////////////////////////////////////////////////////////////////////////////// 918 //////////////////////////////////////////////////////////////////////////////
908 919
909 GrGeometryProcessor* GrDashingEffect::Create(GrPrimitiveEdgeType edgeType, 920 GrGeometryProcessor* GrDashingEffect::Create(GrColor color,
921 GrPrimitiveEdgeType edgeType,
910 const SkPathEffect::DashInfo& info, 922 const SkPathEffect::DashInfo& info,
911 SkScalar strokeWidth, 923 SkScalar strokeWidth,
912 GrDashingEffect::DashCap cap) { 924 GrDashingEffect::DashCap cap) {
913 switch (cap) { 925 switch (cap) {
914 case GrDashingEffect::kRound_DashCap: 926 case GrDashingEffect::kRound_DashCap:
915 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro keWidth)); 927 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth));
916 case GrDashingEffect::kNonRound_DashCap: 928 case GrDashingEffect::kNonRound_DashCap:
917 return DashingLineEffect::Create(edgeType, info, strokeWidth); 929 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ;
918 default: 930 default:
919 SkFAIL("Unexpected dashed cap."); 931 SkFAIL("Unexpected dashed cap.");
920 } 932 }
921 return NULL; 933 return NULL;
922 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698