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

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

Issue 820523002: initial changes to add local matrix to primitive processor (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup-ccm-above-context
Patch Set: cleanup 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
« 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return true; 438 return true;
439 } 439 }
440 440
441 ////////////////////////////////////////////////////////////////////////////// 441 //////////////////////////////////////////////////////////////////////////////
442 442
443 class GLDashingCircleEffect; 443 class GLDashingCircleEffect;
444 444
445 struct DashingCircleBatchTracker { 445 struct DashingCircleBatchTracker {
446 GrGPInput fInputColorType; 446 GrGPInput fInputColorType;
447 GrColor fColor; 447 GrColor fColor;
448 bool fUsesLocalCoords;
448 }; 449 };
449 450
450 /* 451 /*
451 * This effect will draw a dotted line (defined as a dashed lined with round cap s and no on 452 * This effect will draw a dotted line (defined as a dashed lined with round cap s and no on
452 * interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo. 453 * interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
453 * Both of the previous two parameters are in device space. This effect also req uires the setting of 454 * Both of the previous two parameters are in device space. This effect also req uires the setting of
454 * a vec2 vertex attribute for the the four corners of the bounding rect. This a ttribute is the 455 * a vec2 vertex attribute for the the four corners of the bounding rect. This a ttribute is the
455 * "dash position" of each vertex. In other words it is the vertex coords (in de vice space) if we 456 * "dash position" of each vertex. In other words it is the vertex coords (in de vice space) if we
456 * transform the line to be horizontal, with the start of line at the origin the n shifted to the 457 * transform the line to be horizontal, with the start of line at the origin the n shifted to the
457 * right by half the off interval. The line then goes in the positive x directio n. 458 * right by half the off interval. The line then goes in the positive x directio n.
(...skipping 24 matching lines...) Expand all
482 SkScalar getIntervalLength() const { return fIntervalLength; } 483 SkScalar getIntervalLength() const { return fIntervalLength; }
483 484
484 virtual void getGLProcessorKey(const GrBatchTracker&, 485 virtual void getGLProcessorKey(const GrBatchTracker&,
485 const GrGLCaps&, 486 const GrGLCaps&,
486 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 487 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
487 488
488 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE; 489 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE;
489 490
490 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE; 491 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE;
491 492
492 bool onCanMakeEqual(const GrBatchTracker&, const GrBatchTracker&) const SK_O VERRIDE; 493 bool onCanMakeEqual(const GrBatchTracker&,
494 const GrGeometryProcessor&,
495 const GrBatchTracker&) const SK_OVERRIDE;
493 496
494 private: 497 private:
495 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo, 498 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo,
496 SkScalar radius); 499 SkScalar radius);
497 500
498 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 501 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
499 502
500 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE; 503 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
501 504
502 GrPrimitiveEdgeType fEdgeType; 505 GrPrimitiveEdgeType fEdgeType;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>(); 675 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
673 return (fEdgeType == dce.fEdgeType && 676 return (fEdgeType == dce.fEdgeType &&
674 fIntervalLength == dce.fIntervalLength && 677 fIntervalLength == dce.fIntervalLength &&
675 fRadius == dce.fRadius && 678 fRadius == dce.fRadius &&
676 fCenterX == dce.fCenterX); 679 fCenterX == dce.fCenterX);
677 } 680 }
678 681
679 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& ini t) const { 682 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& ini t) const {
680 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>(); 683 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>();
681 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 684 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
685 local->fUsesLocalCoords = init.fUsesLocalCoords;
682 } 686 }
683 687
684 bool DashingCircleEffect::onCanMakeEqual(const GrBatchTracker& m, const GrBatchT racker& t) const { 688 bool DashingCircleEffect::onCanMakeEqual(const GrBatchTracker& m,
689 const GrGeometryProcessor& that,
690 const GrBatchTracker& t) const {
685 const DashingCircleBatchTracker& mine = m.cast<DashingCircleBatchTracker>(); 691 const DashingCircleBatchTracker& mine = m.cast<DashingCircleBatchTracker>();
686 const DashingCircleBatchTracker& theirs = t.cast<DashingCircleBatchTracker>( ); 692 const DashingCircleBatchTracker& theirs = t.cast<DashingCircleBatchTracker>( );
687 return CanCombineOutput(mine.fInputColorType, mine.fColor, 693 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
694 that, theirs.fUsesLocalCoords) &&
695 CanCombineOutput(mine.fInputColorType, mine.fColor,
688 theirs.fInputColorType, theirs.fColor); 696 theirs.fInputColorType, theirs.fColor);
689 } 697 }
690 698
691 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); 699 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
692 700
693 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, 701 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
694 GrContext*, 702 GrContext*,
695 const GrDrawTargetCaps& cap s, 703 const GrDrawTargetCaps& cap s,
696 GrTexture*[]) { 704 GrTexture*[]) {
697 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->next ULessThan( 705 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->next ULessThan(
(...skipping 10 matching lines...) Expand all
708 return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, st rokeWidth); 716 return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, st rokeWidth);
709 } 717 }
710 718
711 ////////////////////////////////////////////////////////////////////////////// 719 //////////////////////////////////////////////////////////////////////////////
712 720
713 class GLDashingLineEffect; 721 class GLDashingLineEffect;
714 722
715 struct DashingLineBatchTracker { 723 struct DashingLineBatchTracker {
716 GrGPInput fInputColorType; 724 GrGPInput fInputColorType;
717 GrColor fColor; 725 GrColor fColor;
726 bool fUsesLocalCoords;
718 }; 727 };
719 728
720 /* 729 /*
721 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the 730 * This effect will draw a dashed line. The width of the dash is given by the st rokeWidth and the
722 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space. 731 * length and spacing by the DashInfo. Both of the previous two parameters are i n device space.
723 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the 732 * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the
724 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the 733 * bounding rect. This attribute is the "dash position" of each vertex. In other words it is the
725 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of 734 * vertex coords (in device space) if we transform the line to be horizontal, wi th the start of
726 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the 735 * line at the origin then shifted to the right by half the off interval. The li ne then goes in the
727 * positive x direction. 736 * positive x direction.
(...skipping 22 matching lines...) Expand all
750 SkScalar getIntervalLength() const { return fIntervalLength; } 759 SkScalar getIntervalLength() const { return fIntervalLength; }
751 760
752 virtual void getGLProcessorKey(const GrBatchTracker& bt, 761 virtual void getGLProcessorKey(const GrBatchTracker& bt,
753 const GrGLCaps& caps, 762 const GrGLCaps& caps,
754 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 763 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
755 764
756 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE; 765 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE;
757 766
758 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE; 767 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE;
759 768
760 bool onCanMakeEqual(const GrBatchTracker&, const GrBatchTracker&) const SK_O VERRIDE; 769 bool onCanMakeEqual(const GrBatchTracker&,
770 const GrGeometryProcessor&,
771 const GrBatchTracker&) const SK_OVERRIDE;
761 772
762 private: 773 private:
763 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o, 774 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o,
764 SkScalar strokeWidth); 775 SkScalar strokeWidth);
765 776
766 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 777 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
767 778
768 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE; 779 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
769 780
770 GrPrimitiveEdgeType fEdgeType; 781 GrPrimitiveEdgeType fEdgeType;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const { 964 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const {
954 const DashingLineEffect& de = other.cast<DashingLineEffect>(); 965 const DashingLineEffect& de = other.cast<DashingLineEffect>();
955 return (fEdgeType == de.fEdgeType && 966 return (fEdgeType == de.fEdgeType &&
956 fRect == de.fRect && 967 fRect == de.fRect &&
957 fIntervalLength == de.fIntervalLength); 968 fIntervalLength == de.fIntervalLength);
958 } 969 }
959 970
960 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& init) const { 971 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& init) const {
961 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>(); 972 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>();
962 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 973 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
974 local->fUsesLocalCoords = init.fUsesLocalCoords;
963 } 975 }
964 976
965 bool DashingLineEffect::onCanMakeEqual(const GrBatchTracker& m, const GrBatchTra cker& t) const { 977 bool DashingLineEffect::onCanMakeEqual(const GrBatchTracker& m,
978 const GrGeometryProcessor& that,
979 const GrBatchTracker& t) const {
966 const DashingLineBatchTracker& mine = m.cast<DashingLineBatchTracker>(); 980 const DashingLineBatchTracker& mine = m.cast<DashingLineBatchTracker>();
967 const DashingLineBatchTracker& theirs = t.cast<DashingLineBatchTracker>(); 981 const DashingLineBatchTracker& theirs = t.cast<DashingLineBatchTracker>();
968 return CanCombineOutput(mine.fInputColorType, mine.fColor, 982 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
983 that, theirs.fUsesLocalCoords) &&
984 CanCombineOutput(mine.fInputColorType, mine.fColor,
969 theirs.fInputColorType, theirs.fColor); 985 theirs.fInputColorType, theirs.fColor);
970 } 986 }
971 987
972 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); 988 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
973 989
974 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, 990 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
975 GrContext*, 991 GrContext*,
976 const GrDrawTargetCaps& caps, 992 const GrDrawTargetCaps& caps,
977 GrTexture*[]) { 993 GrTexture*[]) {
978 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->next ULessThan( 994 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->next ULessThan(
(...skipping 20 matching lines...) Expand all
999 switch (cap) { 1015 switch (cap) {
1000 case GrDashingEffect::kRound_DashCap: 1016 case GrDashingEffect::kRound_DashCap:
1001 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth)); 1017 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth));
1002 case GrDashingEffect::kNonRound_DashCap: 1018 case GrDashingEffect::kNonRound_DashCap:
1003 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ; 1019 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ;
1004 default: 1020 default:
1005 SkFAIL("Unexpected dashed cap."); 1021 SkFAIL("Unexpected dashed cap.");
1006 } 1022 }
1007 return NULL; 1023 return NULL;
1008 } 1024 }
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