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

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

Issue 1110993002: Revert of removing equality / compute invariant loops from GrGeometryProcessors (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup1
Patch Set: 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 * right by half the off interval. The line then goes in the positive x directio n. 776 * right by half the off interval. The line then goes in the positive x directio n.
777 */ 777 */
778 class DashingCircleEffect : public GrGeometryProcessor { 778 class DashingCircleEffect : public GrGeometryProcessor {
779 public: 779 public:
780 typedef SkPathEffect::DashInfo DashInfo; 780 typedef SkPathEffect::DashInfo DashInfo;
781 781
782 static GrGeometryProcessor* Create(GrColor, 782 static GrGeometryProcessor* Create(GrColor,
783 DashAAMode aaMode, 783 DashAAMode aaMode,
784 const SkMatrix& localMatrix); 784 const SkMatrix& localMatrix);
785 785
786 virtual ~DashingCircleEffect();
787
786 const char* name() const override { return "DashingCircleEffect"; } 788 const char* name() const override { return "DashingCircleEffect"; }
787 789
788 const Attribute* inPosition() const { return fInPosition; } 790 const Attribute* inPosition() const { return fInPosition; }
789 791
790 const Attribute* inDashParams() const { return fInDashParams; } 792 const Attribute* inDashParams() const { return fInDashParams; }
791 793
792 const Attribute* inCircleParams() const { return fInCircleParams; } 794 const Attribute* inCircleParams() const { return fInCircleParams; }
793 795
794 DashAAMode aaMode() const { return fAAMode; } 796 DashAAMode aaMode() const { return fAAMode; }
795 797
796 virtual void getGLProcessorKey(const GrBatchTracker&, 798 virtual void getGLProcessorKey(const GrBatchTracker&,
797 const GrGLCaps&, 799 const GrGLCaps&,
798 GrProcessorKeyBuilder* b) const override; 800 GrProcessorKeyBuilder* b) const override;
799 801
800 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, 802 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&,
801 const GrGLCaps&) const over ride; 803 const GrGLCaps&) const over ride;
802 804
803 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 805 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
804 806
807 bool onCanMakeEqual(const GrBatchTracker&,
808 const GrGeometryProcessor&,
809 const GrBatchTracker&) const override;
810
805 private: 811 private:
806 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ; 812 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ;
807 813
814 bool onIsEqual(const GrGeometryProcessor& other) const override;
815
816 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override;
817
808 DashAAMode fAAMode; 818 DashAAMode fAAMode;
809 const Attribute* fInPosition; 819 const Attribute* fInPosition;
810 const Attribute* fInDashParams; 820 const Attribute* fInDashParams;
811 const Attribute* fInCircleParams; 821 const Attribute* fInCircleParams;
812 822
813 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 823 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
814 824
815 typedef GrGeometryProcessor INHERITED; 825 typedef GrGeometryProcessor INHERITED;
816 }; 826 };
817 827
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 } 936 }
927 937
928 ////////////////////////////////////////////////////////////////////////////// 938 //////////////////////////////////////////////////////////////////////////////
929 939
930 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, 940 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
931 DashAAMode aaMode, 941 DashAAMode aaMode,
932 const SkMatrix& localMatrix) { 942 const SkMatrix& localMatrix) {
933 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix)); 943 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix));
934 } 944 }
935 945
946 DashingCircleEffect::~DashingCircleEffect() {}
947
948 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const {
949 out->setUnknownSingleComponent();
950 }
951
936 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 952 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
937 const GrGLCaps& caps, 953 const GrGLCaps& caps,
938 GrProcessorKeyBuilder* b) const { 954 GrProcessorKeyBuilder* b) const {
939 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 955 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
940 } 956 }
941 957
942 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt, 958 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt,
943 const GrGLCaps&) c onst { 959 const GrGLCaps&) c onst {
944 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 960 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
945 } 961 }
946 962
947 DashingCircleEffect::DashingCircleEffect(GrColor color, 963 DashingCircleEffect::DashingCircleEffect(GrColor color,
948 DashAAMode aaMode, 964 DashAAMode aaMode,
949 const SkMatrix& localMatrix) 965 const SkMatrix& localMatrix)
950 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { 966 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) {
951 this->initClassID<DashingCircleEffect>(); 967 this->initClassID<DashingCircleEffect>();
952 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 968 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
953 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 969 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
954 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams", 970 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams",
955 kVec2f_GrVertexAttribType )); 971 kVec2f_GrVertexAttribType ));
956 } 972 }
957 973
974 bool DashingCircleEffect::onIsEqual(const GrGeometryProcessor& other) const {
975 const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
976 return fAAMode == dce.fAAMode;
977 }
978
958 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const { 979 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const {
959 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>(); 980 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>();
960 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 981 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
961 local->fUsesLocalCoords = init.fUsesLocalCoords; 982 local->fUsesLocalCoords = init.fUsesLocalCoords;
962 } 983 }
963 984
985 bool DashingCircleEffect::onCanMakeEqual(const GrBatchTracker& m,
986 const GrGeometryProcessor& that,
987 const GrBatchTracker& t) const {
988 const DashingCircleBatchTracker& mine = m.cast<DashingCircleBatchTracker>();
989 const DashingCircleBatchTracker& theirs = t.cast<DashingCircleBatchTracker>( );
990 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
991 that, theirs.fUsesLocalCoords) &&
992 CanCombineOutput(mine.fInputColorType, mine.fColor,
993 theirs.fInputColorType, theirs.fColor);
994 }
995
964 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); 996 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
965 997
966 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, 998 GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
967 GrContext*, 999 GrContext*,
968 const GrDrawTargetCaps& cap s, 1000 const GrDrawTargetCaps& cap s,
969 GrTexture*[]) { 1001 GrTexture*[]) {
970 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount)); 1002 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount));
971 return DashingCircleEffect::Create(GrRandomColor(random), 1003 return DashingCircleEffect::Create(GrRandomColor(random),
972 aaMode, GrProcessorUnitTest::TestMatrix(ra ndom)); 1004 aaMode, GrProcessorUnitTest::TestMatrix(ra ndom));
973 } 1005 }
(...skipping 18 matching lines...) Expand all
992 * positive x direction. 1024 * positive x direction.
993 */ 1025 */
994 class DashingLineEffect : public GrGeometryProcessor { 1026 class DashingLineEffect : public GrGeometryProcessor {
995 public: 1027 public:
996 typedef SkPathEffect::DashInfo DashInfo; 1028 typedef SkPathEffect::DashInfo DashInfo;
997 1029
998 static GrGeometryProcessor* Create(GrColor, 1030 static GrGeometryProcessor* Create(GrColor,
999 DashAAMode aaMode, 1031 DashAAMode aaMode,
1000 const SkMatrix& localMatrix); 1032 const SkMatrix& localMatrix);
1001 1033
1034 virtual ~DashingLineEffect();
1035
1002 const char* name() const override { return "DashingEffect"; } 1036 const char* name() const override { return "DashingEffect"; }
1003 1037
1004 const Attribute* inPosition() const { return fInPosition; } 1038 const Attribute* inPosition() const { return fInPosition; }
1005 1039
1006 const Attribute* inDashParams() const { return fInDashParams; } 1040 const Attribute* inDashParams() const { return fInDashParams; }
1007 1041
1008 const Attribute* inRectParams() const { return fInRectParams; } 1042 const Attribute* inRectParams() const { return fInRectParams; }
1009 1043
1010 DashAAMode aaMode() const { return fAAMode; } 1044 DashAAMode aaMode() const { return fAAMode; }
1011 1045
1012 virtual void getGLProcessorKey(const GrBatchTracker& bt, 1046 virtual void getGLProcessorKey(const GrBatchTracker& bt,
1013 const GrGLCaps& caps, 1047 const GrGLCaps& caps,
1014 GrProcessorKeyBuilder* b) const override; 1048 GrProcessorKeyBuilder* b) const override;
1015 1049
1016 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 1050 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
1017 const GrGLCaps&) const over ride; 1051 const GrGLCaps&) const over ride;
1018 1052
1019 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 1053 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
1020 1054
1055 bool onCanMakeEqual(const GrBatchTracker&,
1056 const GrGeometryProcessor&,
1057 const GrBatchTracker&) const override;
1058
1021 private: 1059 private:
1022 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix); 1060 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix);
1023 1061
1062 bool onIsEqual(const GrGeometryProcessor& other) const override;
1063
1064 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override;
1065
1024 DashAAMode fAAMode; 1066 DashAAMode fAAMode;
1025 const Attribute* fInPosition; 1067 const Attribute* fInPosition;
1026 const Attribute* fInDashParams; 1068 const Attribute* fInDashParams;
1027 const Attribute* fInRectParams; 1069 const Attribute* fInRectParams;
1028 1070
1029 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 1071 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
1030 1072
1031 typedef GrGeometryProcessor INHERITED; 1073 typedef GrGeometryProcessor INHERITED;
1032 }; 1074 };
1033 1075
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 } 1196 }
1155 1197
1156 ////////////////////////////////////////////////////////////////////////////// 1198 //////////////////////////////////////////////////////////////////////////////
1157 1199
1158 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, 1200 GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
1159 DashAAMode aaMode, 1201 DashAAMode aaMode,
1160 const SkMatrix& localMatrix) { 1202 const SkMatrix& localMatrix) {
1161 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix)); 1203 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix));
1162 } 1204 }
1163 1205
1206 DashingLineEffect::~DashingLineEffect() {}
1207
1208 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
1209 out->setUnknownSingleComponent();
1210 }
1211
1164 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 1212 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
1165 const GrGLCaps& caps, 1213 const GrGLCaps& caps,
1166 GrProcessorKeyBuilder* b) const { 1214 GrProcessorKeyBuilder* b) const {
1167 GLDashingLineEffect::GenKey(*this, bt, caps, b); 1215 GLDashingLineEffect::GenKey(*this, bt, caps, b);
1168 } 1216 }
1169 1217
1170 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt, 1218 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt,
1171 const GrGLCaps&) con st { 1219 const GrGLCaps&) con st {
1172 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 1220 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
1173 } 1221 }
1174 1222
1175 DashingLineEffect::DashingLineEffect(GrColor color, 1223 DashingLineEffect::DashingLineEffect(GrColor color,
1176 DashAAMode aaMode, 1224 DashAAMode aaMode,
1177 const SkMatrix& localMatrix) 1225 const SkMatrix& localMatrix)
1178 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { 1226 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) {
1179 this->initClassID<DashingLineEffect>(); 1227 this->initClassID<DashingLineEffect>();
1180 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 1228 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
1181 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 1229 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
1182 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType)); 1230 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType));
1183 } 1231 }
1184 1232
1233 bool DashingLineEffect::onIsEqual(const GrGeometryProcessor& other) const {
1234 const DashingLineEffect& de = other.cast<DashingLineEffect>();
1235 return fAAMode == de.fAAMode;
1236 }
1237
1185 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const { 1238 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const {
1186 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>(); 1239 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>();
1187 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 1240 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
1188 local->fUsesLocalCoords = init.fUsesLocalCoords; 1241 local->fUsesLocalCoords = init.fUsesLocalCoords;
1189 } 1242 }
1190 1243
1244 bool DashingLineEffect::onCanMakeEqual(const GrBatchTracker& m,
1245 const GrGeometryProcessor& that,
1246 const GrBatchTracker& t) const {
1247 const DashingLineBatchTracker& mine = m.cast<DashingLineBatchTracker>();
1248 const DashingLineBatchTracker& theirs = t.cast<DashingLineBatchTracker>();
1249 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
1250 that, theirs.fUsesLocalCoords) &&
1251 CanCombineOutput(mine.fInputColorType, mine.fColor,
1252 theirs.fInputColorType, theirs.fColor);
1253 }
1254
1191 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); 1255 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
1192 1256
1193 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, 1257 GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
1194 GrContext*, 1258 GrContext*,
1195 const GrDrawTargetCaps& caps, 1259 const GrDrawTargetCaps& caps,
1196 GrTexture*[]) { 1260 GrTexture*[]) {
1197 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount)); 1261 DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAMod eCount));
1198 return DashingLineEffect::Create(GrRandomColor(random), 1262 return DashingLineEffect::Create(GrRandomColor(random),
1199 aaMode, GrProcessorUnitTest::TestMatrix(ran dom)); 1263 aaMode, GrProcessorUnitTest::TestMatrix(ran dom));
1200 } 1264 }
1201 1265
1202 ////////////////////////////////////////////////////////////////////////////// 1266 //////////////////////////////////////////////////////////////////////////////
1203 1267
1204 static GrGeometryProcessor* create_dash_gp(GrColor color, 1268 static GrGeometryProcessor* create_dash_gp(GrColor color,
1205 DashAAMode dashAAMode, 1269 DashAAMode dashAAMode,
1206 DashCap cap, 1270 DashCap cap,
1207 const SkMatrix& localMatrix) { 1271 const SkMatrix& localMatrix) {
1208 switch (cap) { 1272 switch (cap) {
1209 case kRound_DashCap: 1273 case kRound_DashCap:
1210 return DashingCircleEffect::Create(color, dashAAMode, localMatrix); 1274 return DashingCircleEffect::Create(color, dashAAMode, localMatrix);
1211 case kNonRound_DashCap: 1275 case kNonRound_DashCap:
1212 return DashingLineEffect::Create(color, dashAAMode, localMatrix); 1276 return DashingLineEffect::Create(color, dashAAMode, localMatrix);
1213 default: 1277 default:
1214 SkFAIL("Unexpected dashed cap."); 1278 SkFAIL("Unexpected dashed cap.");
1215 } 1279 }
1216 return NULL; 1280 return NULL;
1217 } 1281 }
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