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

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

Issue 1111603004: removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
Patch Set: tweaks Created 5 years, 7 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/GrDistanceFieldGeoProc.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 "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 * right by half the off interval. The line then goes in the positive x directio n. 766 * right by half the off interval. The line then goes in the positive x directio n.
767 */ 767 */
768 class DashingCircleEffect : public GrGeometryProcessor { 768 class DashingCircleEffect : public GrGeometryProcessor {
769 public: 769 public:
770 typedef SkPathEffect::DashInfo DashInfo; 770 typedef SkPathEffect::DashInfo DashInfo;
771 771
772 static GrGeometryProcessor* Create(GrColor, 772 static GrGeometryProcessor* Create(GrColor,
773 DashAAMode aaMode, 773 DashAAMode aaMode,
774 const SkMatrix& localMatrix); 774 const SkMatrix& localMatrix);
775 775
776 virtual ~DashingCircleEffect();
777
778 const char* name() const override { return "DashingCircleEffect"; } 776 const char* name() const override { return "DashingCircleEffect"; }
779 777
780 const Attribute* inPosition() const { return fInPosition; } 778 const Attribute* inPosition() const { return fInPosition; }
781 779
782 const Attribute* inDashParams() const { return fInDashParams; } 780 const Attribute* inDashParams() const { return fInDashParams; }
783 781
784 const Attribute* inCircleParams() const { return fInCircleParams; } 782 const Attribute* inCircleParams() const { return fInCircleParams; }
785 783
786 DashAAMode aaMode() const { return fAAMode; } 784 DashAAMode aaMode() const { return fAAMode; }
787 785
788 virtual void getGLProcessorKey(const GrBatchTracker&, 786 virtual void getGLProcessorKey(const GrBatchTracker&,
789 const GrGLSLCaps&, 787 const GrGLSLCaps&,
790 GrProcessorKeyBuilder* b) const override; 788 GrProcessorKeyBuilder* b) const override;
791 789
792 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, 790 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&,
793 const GrGLSLCaps&) const ov erride; 791 const GrGLSLCaps&) const ov erride;
794 792
795 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 793 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
796 794
797 bool onCanMakeEqual(const GrBatchTracker&,
798 const GrGeometryProcessor&,
799 const GrBatchTracker&) const override;
800
801 private: 795 private:
802 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ; 796 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ;
803 797
804 bool onIsEqual(const GrGeometryProcessor& other) const override;
805
806 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override;
807
808 DashAAMode fAAMode; 798 DashAAMode fAAMode;
809 const Attribute* fInPosition; 799 const Attribute* fInPosition;
810 const Attribute* fInDashParams; 800 const Attribute* fInDashParams;
811 const Attribute* fInCircleParams; 801 const Attribute* fInCircleParams;
812 802
813 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 803 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
814 804
815 typedef GrGeometryProcessor INHERITED; 805 typedef GrGeometryProcessor INHERITED;
816 }; 806 };
817 807
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 } 916 }
927 917
928 ////////////////////////////////////////////////////////////////////////////// 918 //////////////////////////////////////////////////////////////////////////////
929 919
930 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, 920 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
931 DashAAMode aaMode, 921 DashAAMode aaMode,
932 const SkMatrix& localMatrix) { 922 const SkMatrix& localMatrix) {
933 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix)); 923 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix));
934 } 924 }
935 925
936 DashingCircleEffect::~DashingCircleEffect() {}
937
938 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const {
939 out->setUnknownSingleComponent();
940 }
941
942 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 926 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
943 const GrGLSLCaps& caps, 927 const GrGLSLCaps& caps,
944 GrProcessorKeyBuilder* b) const { 928 GrProcessorKeyBuilder* b) const {
945 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 929 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
946 } 930 }
947 931
948 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt, 932 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt,
949 const GrGLSLCaps&) const { 933 const GrGLSLCaps&) const {
950 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 934 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
951 } 935 }
952 936
953 DashingCircleEffect::DashingCircleEffect(GrColor color, 937 DashingCircleEffect::DashingCircleEffect(GrColor color,
954 DashAAMode aaMode, 938 DashAAMode aaMode,
955 const SkMatrix& localMatrix) 939 const SkMatrix& localMatrix)
956 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { 940 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) {
957 this->initClassID<DashingCircleEffect>(); 941 this->initClassID<DashingCircleEffect>();
958 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 942 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
959 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 943 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
960 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams", 944 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams",
961 kVec2f_GrVertexAttribType )); 945 kVec2f_GrVertexAttribType ));
962 } 946 }
963 947
964 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const {
965 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
966 return fAAMode == dce.fAAMode;
967 }
968
969 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const { 948 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const {
970 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>(); 949 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>();
971 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 950 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
972 local->fUsesLocalCoords = init.fUsesLocalCoords; 951 local->fUsesLocalCoords = init.fUsesLocalCoords;
973 } 952 }
974 953
975 bool DashingCircleEffect::onCanMakeEqual(const GrBatchTracker& m,
976 const GrGeometryProcessor& that,
977 const GrBatchTracker& t) const {
978 const DashingCircleBatchTracker& mine = m.cast<DashingCircleBatchTracker>();
979 const DashingCircleBatchTracker& theirs = t.cast<DashingCircleBatchTracker>( );
980 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
981 that, theirs.fUsesLocalCoords) &&
982 CanCombineOutput(mine.fInputColorType, mine.fColor,
983 theirs.fInputColorType, theirs.fColor);
984 }
985
986 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); 954 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
987 955
988 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, 956 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
989 GrContext*, 957 GrContext*,
990 const GrDrawTargetCaps& cap s, 958 const GrDrawTargetCaps& cap s,
991 GrTexture*[]) { 959 GrTexture*[]) {
992 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount)); 960 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount));
993 return DashingCircleEffect::Create(GrRandomColor(random), 961 return DashingCircleEffect::Create(GrRandomColor(random),
994 aaMode, GrTest::TestMatrix(random)); 962 aaMode, GrTest::TestMatrix(random));
995 } 963 }
(...skipping 18 matching lines...) Expand all
1014 * positive x direction. 982 * positive x direction.
1015 */ 983 */
1016 class DashingLineEffect : public GrGeometryProcessor { 984 class DashingLineEffect : public GrGeometryProcessor {
1017 public: 985 public:
1018 typedef SkPathEffect::DashInfo DashInfo; 986 typedef SkPathEffect::DashInfo DashInfo;
1019 987
1020 static GrGeometryProcessor* Create(GrColor, 988 static GrGeometryProcessor* Create(GrColor,
1021 DashAAMode aaMode, 989 DashAAMode aaMode,
1022 const SkMatrix& localMatrix); 990 const SkMatrix& localMatrix);
1023 991
1024 virtual ~DashingLineEffect();
1025
1026 const char* name() const override { return "DashingEffect"; } 992 const char* name() const override { return "DashingEffect"; }
1027 993
1028 const Attribute* inPosition() const { return fInPosition; } 994 const Attribute* inPosition() const { return fInPosition; }
1029 995
1030 const Attribute* inDashParams() const { return fInDashParams; } 996 const Attribute* inDashParams() const { return fInDashParams; }
1031 997
1032 const Attribute* inRectParams() const { return fInRectParams; } 998 const Attribute* inRectParams() const { return fInRectParams; }
1033 999
1034 DashAAMode aaMode() const { return fAAMode; } 1000 DashAAMode aaMode() const { return fAAMode; }
1035 1001
1036 virtual void getGLProcessorKey(const GrBatchTracker& bt, 1002 virtual void getGLProcessorKey(const GrBatchTracker& bt,
1037 const GrGLSLCaps& caps, 1003 const GrGLSLCaps& caps,
1038 GrProcessorKeyBuilder* b) const override; 1004 GrProcessorKeyBuilder* b) const override;
1039 1005
1040 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 1006 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
1041 const GrGLSLCaps&) const ov erride; 1007 const GrGLSLCaps&) const ov erride;
1042 1008
1043 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 1009 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
1044 1010
1045 bool onCanMakeEqual(const GrBatchTracker&,
1046 const GrGeometryProcessor&,
1047 const GrBatchTracker&) const override;
1048
1049 private: 1011 private:
1050 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix); 1012 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix);
1051 1013
1052 bool onIsEqual(const GrGeometryProcessor& other) const override;
1053
1054 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override;
1055
1056 DashAAMode fAAMode; 1014 DashAAMode fAAMode;
1057 const Attribute* fInPosition; 1015 const Attribute* fInPosition;
1058 const Attribute* fInDashParams; 1016 const Attribute* fInDashParams;
1059 const Attribute* fInRectParams; 1017 const Attribute* fInRectParams;
1060 1018
1061 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 1019 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
1062 1020
1063 typedef GrGeometryProcessor INHERITED; 1021 typedef GrGeometryProcessor INHERITED;
1064 }; 1022 };
1065 1023
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1144 }
1187 1145
1188 ////////////////////////////////////////////////////////////////////////////// 1146 //////////////////////////////////////////////////////////////////////////////
1189 1147
1190 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, 1148 GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
1191 DashAAMode aaMode, 1149 DashAAMode aaMode,
1192 const SkMatrix& localMatrix) { 1150 const SkMatrix& localMatrix) {
1193 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix)); 1151 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix));
1194 } 1152 }
1195 1153
1196 DashingLineEffect::~DashingLineEffect() {}
1197
1198 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
1199 out->setUnknownSingleComponent();
1200 }
1201
1202 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 1154 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
1203 const GrGLSLCaps& caps, 1155 const GrGLSLCaps& caps,
1204 GrProcessorKeyBuilder* b) const { 1156 GrProcessorKeyBuilder* b) const {
1205 GLDashingLineEffect::GenKey(*this, bt, caps, b); 1157 GLDashingLineEffect::GenKey(*this, bt, caps, b);
1206 } 1158 }
1207 1159
1208 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt, 1160 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt,
1209 const GrGLSLCaps&) c onst { 1161 const GrGLSLCaps&) c onst {
1210 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 1162 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
1211 } 1163 }
1212 1164
1213 DashingLineEffect::DashingLineEffect(GrColor color, 1165 DashingLineEffect::DashingLineEffect(GrColor color,
1214 DashAAMode aaMode, 1166 DashAAMode aaMode,
1215 const SkMatrix& localMatrix) 1167 const SkMatrix& localMatrix)
1216 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { 1168 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) {
1217 this->initClassID<DashingLineEffect>(); 1169 this->initClassID<DashingLineEffect>();
1218 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 1170 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
1219 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 1171 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
1220 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType)); 1172 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType));
1221 } 1173 }
1222 1174
1223 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const {
1224 const DashingLineEffect& de = other.cast<DashingLineEffect>();
1225 return fAAMode == de.fAAMode;
1226 }
1227
1228 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const { 1175 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const {
1229 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>(); 1176 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>();
1230 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 1177 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
1231 local->fUsesLocalCoords = init.fUsesLocalCoords; 1178 local->fUsesLocalCoords = init.fUsesLocalCoords;
1232 } 1179 }
1233 1180
1234 bool DashingLineEffect::onCanMakeEqual(const GrBatchTracker& m,
1235 const GrGeometryProcessor& that,
1236 const GrBatchTracker& t) const {
1237 const DashingLineBatchTracker& mine = m.cast<DashingLineBatchTracker>();
1238 const DashingLineBatchTracker& theirs = t.cast<DashingLineBatchTracker>();
1239 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
1240 that, theirs.fUsesLocalCoords) &&
1241 CanCombineOutput(mine.fInputColorType, mine.fColor,
1242 theirs.fInputColorType, theirs.fColor);
1243 }
1244
1245 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); 1181 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
1246 1182
1247 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, 1183 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
1248 GrContext*, 1184 GrContext*,
1249 const GrDrawTargetCaps& caps, 1185 const GrDrawTargetCaps& caps,
1250 GrTexture*[]) { 1186 GrTexture*[]) {
1251 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount)); 1187 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount));
1252 return DashingLineEffect::Create(GrRandomColor(random), 1188 return DashingLineEffect::Create(GrRandomColor(random),
1253 aaMode, GrTest::TestMatrix(random)); 1189 aaMode, GrTest::TestMatrix(random));
1254 } 1190 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 info.fIntervals = intervals; 1279 info.fIntervals = intervals;
1344 info.fCount = 2; 1280 info.fCount = 2;
1345 info.fPhase = phase; 1281 info.fPhase = phase;
1346 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1282 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1347 SkASSERT(success); 1283 SkASSERT(success);
1348 1284
1349 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1285 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1350 } 1286 }
1351 1287
1352 #endif 1288 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/effects/GrDistanceFieldGeoProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698