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

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

Issue 1131513005: remove localmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup4
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.cpp » ('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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 const Attribute* inPosition() const { return fInPosition; } 778 const Attribute* inPosition() const { return fInPosition; }
779 779
780 const Attribute* inDashParams() const { return fInDashParams; } 780 const Attribute* inDashParams() const { return fInDashParams; }
781 781
782 const Attribute* inCircleParams() const { return fInCircleParams; } 782 const Attribute* inCircleParams() const { return fInCircleParams; }
783 783
784 DashAAMode aaMode() const { return fAAMode; } 784 DashAAMode aaMode() const { return fAAMode; }
785 785
786 GrColor color() const { return fColor; } 786 GrColor color() const { return fColor; }
787 787
788 const SkMatrix& localMatrix() const { return fLocalMatrix; }
789
788 virtual void getGLProcessorKey(const GrBatchTracker&, 790 virtual void getGLProcessorKey(const GrBatchTracker&,
789 const GrGLSLCaps&, 791 const GrGLSLCaps&,
790 GrProcessorKeyBuilder* b) const override; 792 GrProcessorKeyBuilder* b) const override;
791 793
792 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, 794 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&,
793 const GrGLSLCaps&) const ov erride; 795 const GrGLSLCaps&) const ov erride;
794 796
795 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 797 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
796 798
797 private: 799 private:
798 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ; 800 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix) ;
799 801
800 GrColor fColor; 802 GrColor fColor;
803 SkMatrix fLocalMatrix;
801 DashAAMode fAAMode; 804 DashAAMode fAAMode;
802 const Attribute* fInPosition; 805 const Attribute* fInPosition;
803 const Attribute* fInDashParams; 806 const Attribute* fInDashParams;
804 const Attribute* fInCircleParams; 807 const Attribute* fInCircleParams;
805 808
806 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 809 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
807 810
808 typedef GrGeometryProcessor INHERITED; 811 typedef GrGeometryProcessor INHERITED;
809 }; 812 };
810 813
811 ////////////////////////////////////////////////////////////////////////////// 814 //////////////////////////////////////////////////////////////////////////////
812 815
813 class GLDashingCircleEffect : public GrGLGeometryProcessor { 816 class GLDashingCircleEffect : public GrGLGeometryProcessor {
814 public: 817 public:
815 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); 818 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&);
816 819
817 void onEmitCode(EmitArgs&, GrGPArgs*) override; 820 void onEmitCode(EmitArgs&, GrGPArgs*) override;
818 821
819 static inline void GenKey(const GrGeometryProcessor&, 822 static inline void GenKey(const GrGeometryProcessor&,
820 const GrBatchTracker&, 823 const GrBatchTracker&,
821 const GrGLSLCaps&, 824 const GrGLSLCaps&,
822 GrProcessorKeyBuilder*); 825 GrProcessorKeyBuilder*);
823 826
824 virtual void setData(const GrGLProgramDataManager&, 827 virtual void setData(const GrGLProgramDataManager&,
825 const GrPrimitiveProcessor&, 828 const GrPrimitiveProcessor&,
826 const GrBatchTracker&) override; 829 const GrBatchTracker&) override;
827 830
831 void setTransformData(const GrPrimitiveProcessor& primProc,
832 const GrGLProgramDataManager& pdman,
833 int index,
834 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
835 this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index , transforms);
836 }
837
828 private: 838 private:
829 UniformHandle fParamUniform; 839 UniformHandle fParamUniform;
830 UniformHandle fColorUniform; 840 UniformHandle fColorUniform;
831 GrColor fColor; 841 GrColor fColor;
832 SkScalar fPrevRadius; 842 SkScalar fPrevRadius;
833 SkScalar fPrevCenterX; 843 SkScalar fPrevCenterX;
834 SkScalar fPrevIntervalLength; 844 SkScalar fPrevIntervalLength;
835 typedef GrGLGeometryProcessor INHERITED; 845 typedef GrGLGeometryProcessor INHERITED;
836 }; 846 };
837 847
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 } 913 }
904 } 914 }
905 915
906 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp, 916 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
907 const GrBatchTracker& bt, 917 const GrBatchTracker& bt,
908 const GrGLSLCaps&, 918 const GrGLSLCaps&,
909 GrProcessorKeyBuilder* b) { 919 GrProcessorKeyBuilder* b) {
910 const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>( ); 920 const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>( );
911 const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>(); 921 const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>();
912 uint32_t key = 0; 922 uint32_t key = 0;
913 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0 x0; 923 key |= local.fUsesLocalCoords && dce.localMatrix().hasPerspective() ? 0x1 : 0x0;
914 key |= dce.aaMode() << 8; 924 key |= dce.aaMode() << 8;
915 b->add32(key << 16 | local.fInputColorType); 925 b->add32(key << 16 | local.fInputColorType);
916 } 926 }
917 927
918 ////////////////////////////////////////////////////////////////////////////// 928 //////////////////////////////////////////////////////////////////////////////
919 929
920 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, 930 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
921 DashAAMode aaMode, 931 DashAAMode aaMode,
922 const SkMatrix& localMatrix) { 932 const SkMatrix& localMatrix) {
923 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix)); 933 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix));
924 } 934 }
925 935
926 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 936 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
927 const GrGLSLCaps& caps, 937 const GrGLSLCaps& caps,
928 GrProcessorKeyBuilder* b) const { 938 GrProcessorKeyBuilder* b) const {
929 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 939 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
930 } 940 }
931 941
932 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt, 942 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack er& bt,
933 const GrGLSLCaps&) const { 943 const GrGLSLCaps&) const {
934 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 944 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
935 } 945 }
936 946
937 DashingCircleEffect::DashingCircleEffect(GrColor color, 947 DashingCircleEffect::DashingCircleEffect(GrColor color,
938 DashAAMode aaMode, 948 DashAAMode aaMode,
939 const SkMatrix& localMatrix) 949 const SkMatrix& localMatrix)
940 : INHERITED(localMatrix) 950 : fColor(color)
941 , fColor(color) 951 , fLocalMatrix(localMatrix)
942 , fAAMode(aaMode) { 952 , fAAMode(aaMode) {
943 this->initClassID<DashingCircleEffect>(); 953 this->initClassID<DashingCircleEffect>();
944 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 954 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
945 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 955 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
946 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams", 956 fInCircleParams = &this->addVertexAttrib(Attribute("inCircleParams",
947 kVec2f_GrVertexAttribType )); 957 kVec2f_GrVertexAttribType ));
948 } 958 }
949 959
950 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const { 960 void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineI nfo& init) const {
951 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>(); 961 DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 const Attribute* inPosition() const { return fInPosition; } 1006 const Attribute* inPosition() const { return fInPosition; }
997 1007
998 const Attribute* inDashParams() const { return fInDashParams; } 1008 const Attribute* inDashParams() const { return fInDashParams; }
999 1009
1000 const Attribute* inRectParams() const { return fInRectParams; } 1010 const Attribute* inRectParams() const { return fInRectParams; }
1001 1011
1002 DashAAMode aaMode() const { return fAAMode; } 1012 DashAAMode aaMode() const { return fAAMode; }
1003 1013
1004 GrColor color() const { return fColor; } 1014 GrColor color() const { return fColor; }
1005 1015
1016 const SkMatrix& localMatrix() const { return fLocalMatrix; }
1017
1006 virtual void getGLProcessorKey(const GrBatchTracker& bt, 1018 virtual void getGLProcessorKey(const GrBatchTracker& bt,
1007 const GrGLSLCaps& caps, 1019 const GrGLSLCaps& caps,
1008 GrProcessorKeyBuilder* b) const override; 1020 GrProcessorKeyBuilder* b) const override;
1009 1021
1010 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 1022 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
1011 const GrGLSLCaps&) const ov erride; 1023 const GrGLSLCaps&) const ov erride;
1012 1024
1013 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override; 1025 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
1014 1026
1015 private: 1027 private:
1016 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix); 1028 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix);
1017 1029
1018 GrColor fColor; 1030 GrColor fColor;
1031 SkMatrix fLocalMatrix;
1019 DashAAMode fAAMode; 1032 DashAAMode fAAMode;
1020 const Attribute* fInPosition; 1033 const Attribute* fInPosition;
1021 const Attribute* fInDashParams; 1034 const Attribute* fInDashParams;
1022 const Attribute* fInRectParams; 1035 const Attribute* fInRectParams;
1023 1036
1024 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 1037 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
1025 1038
1026 typedef GrGeometryProcessor INHERITED; 1039 typedef GrGeometryProcessor INHERITED;
1027 }; 1040 };
1028 1041
1029 ////////////////////////////////////////////////////////////////////////////// 1042 //////////////////////////////////////////////////////////////////////////////
1030 1043
1031 class GLDashingLineEffect : public GrGLGeometryProcessor { 1044 class GLDashingLineEffect : public GrGLGeometryProcessor {
1032 public: 1045 public:
1033 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); 1046 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&);
1034 1047
1035 void onEmitCode(EmitArgs&, GrGPArgs*) override; 1048 void onEmitCode(EmitArgs&, GrGPArgs*) override;
1036 1049
1037 static inline void GenKey(const GrGeometryProcessor&, 1050 static inline void GenKey(const GrGeometryProcessor&,
1038 const GrBatchTracker&, 1051 const GrBatchTracker&,
1039 const GrGLSLCaps&, 1052 const GrGLSLCaps&,
1040 GrProcessorKeyBuilder*); 1053 GrProcessorKeyBuilder*);
1041 1054
1042 virtual void setData(const GrGLProgramDataManager&, 1055 virtual void setData(const GrGLProgramDataManager&,
1043 const GrPrimitiveProcessor&, 1056 const GrPrimitiveProcessor&,
1044 const GrBatchTracker&) override; 1057 const GrBatchTracker&) override;
1045 1058
1059 void setTransformData(const GrPrimitiveProcessor& primProc,
1060 const GrGLProgramDataManager& pdman,
1061 int index,
1062 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
1063 this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index, transforms);
1064 }
1065
1046 private: 1066 private:
1047 GrColor fColor; 1067 GrColor fColor;
1048 UniformHandle fColorUniform; 1068 UniformHandle fColorUniform;
1049 typedef GrGLGeometryProcessor INHERITED; 1069 typedef GrGLGeometryProcessor INHERITED;
1050 }; 1070 };
1051 1071
1052 GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&, 1072 GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&,
1053 const GrBatchTracker&) { 1073 const GrBatchTracker&) {
1054 fColor = GrColor_ILLEGAL; 1074 fColor = GrColor_ILLEGAL;
1055 } 1075 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 } 1153 }
1134 } 1154 }
1135 1155
1136 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp, 1156 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
1137 const GrBatchTracker& bt, 1157 const GrBatchTracker& bt,
1138 const GrGLSLCaps&, 1158 const GrGLSLCaps&,
1139 GrProcessorKeyBuilder* b) { 1159 GrProcessorKeyBuilder* b) {
1140 const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>(); 1160 const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>();
1141 const DashingLineEffect& de = gp.cast<DashingLineEffect>(); 1161 const DashingLineEffect& de = gp.cast<DashingLineEffect>();
1142 uint32_t key = 0; 1162 uint32_t key = 0;
1143 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0 x0; 1163 key |= local.fUsesLocalCoords && de.localMatrix().hasPerspective() ? 0x1 : 0 x0;
1144 key |= de.aaMode() << 8; 1164 key |= de.aaMode() << 8;
1145 b->add32(key << 16 | local.fInputColorType); 1165 b->add32(key << 16 | local.fInputColorType);
1146 } 1166 }
1147 1167
1148 ////////////////////////////////////////////////////////////////////////////// 1168 //////////////////////////////////////////////////////////////////////////////
1149 1169
1150 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, 1170 GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
1151 DashAAMode aaMode, 1171 DashAAMode aaMode,
1152 const SkMatrix& localMatrix) { 1172 const SkMatrix& localMatrix) {
1153 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix)); 1173 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix));
1154 } 1174 }
1155 1175
1156 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 1176 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
1157 const GrGLSLCaps& caps, 1177 const GrGLSLCaps& caps,
1158 GrProcessorKeyBuilder* b) const { 1178 GrProcessorKeyBuilder* b) const {
1159 GLDashingLineEffect::GenKey(*this, bt, caps, b); 1179 GLDashingLineEffect::GenKey(*this, bt, caps, b);
1160 } 1180 }
1161 1181
1162 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt, 1182 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker & bt,
1163 const GrGLSLCaps&) c onst { 1183 const GrGLSLCaps&) c onst {
1164 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 1184 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
1165 } 1185 }
1166 1186
1167 DashingLineEffect::DashingLineEffect(GrColor color, 1187 DashingLineEffect::DashingLineEffect(GrColor color,
1168 DashAAMode aaMode, 1188 DashAAMode aaMode,
1169 const SkMatrix& localMatrix) 1189 const SkMatrix& localMatrix)
1170 : INHERITED(localMatrix) 1190 : fColor(color)
1171 , fColor(color) 1191 , fLocalMatrix(localMatrix)
1172 , fAAMode(aaMode) { 1192 , fAAMode(aaMode) {
1173 this->initClassID<DashingLineEffect>(); 1193 this->initClassID<DashingLineEffect>();
1174 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); 1194 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType));
1175 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType)); 1195 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe rtexAttribType));
1176 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType)); 1196 fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAt tribType));
1177 } 1197 }
1178 1198
1179 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const { 1199 void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInf o& init) const {
1180 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>(); 1200 DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>();
1181 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false); 1201 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in it, false);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 info.fIntervals = intervals; 1303 info.fIntervals = intervals;
1284 info.fCount = 2; 1304 info.fCount = 2;
1285 info.fPhase = phase; 1305 info.fPhase = phase;
1286 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1306 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1287 SkASSERT(success); 1307 SkASSERT(success);
1288 1308
1289 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1309 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1290 } 1310 }
1291 1311
1292 #endif 1312 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698