| OLD | NEW |
| 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 | 789 |
| 790 const Attribute* inPosition() const { return fInPosition; } | 790 const Attribute* inPosition() const { return fInPosition; } |
| 791 | 791 |
| 792 const Attribute* inDashParams() const { return fInDashParams; } | 792 const Attribute* inDashParams() const { return fInDashParams; } |
| 793 | 793 |
| 794 const Attribute* inCircleParams() const { return fInCircleParams; } | 794 const Attribute* inCircleParams() const { return fInCircleParams; } |
| 795 | 795 |
| 796 DashAAMode aaMode() const { return fAAMode; } | 796 DashAAMode aaMode() const { return fAAMode; } |
| 797 | 797 |
| 798 virtual void getGLProcessorKey(const GrBatchTracker&, | 798 virtual void getGLProcessorKey(const GrBatchTracker&, |
| 799 const GrGLCaps&, | 799 const GrGLSLCaps&, |
| 800 GrProcessorKeyBuilder* b) const override; | 800 GrProcessorKeyBuilder* b) const override; |
| 801 | 801 |
| 802 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, | 802 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, |
| 803 const GrGLCaps&) const over
ride; | 803 const GrGLSLCaps&) const ov
erride; |
| 804 | 804 |
| 805 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; | 805 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
| 806 | 806 |
| 807 bool onCanMakeEqual(const GrBatchTracker&, | 807 bool onCanMakeEqual(const GrBatchTracker&, |
| 808 const GrGeometryProcessor&, | 808 const GrGeometryProcessor&, |
| 809 const GrBatchTracker&) const override; | 809 const GrBatchTracker&) const override; |
| 810 | 810 |
| 811 private: | 811 private: |
| 812 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix)
; | 812 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix)
; |
| 813 | 813 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 828 ////////////////////////////////////////////////////////////////////////////// | 828 ////////////////////////////////////////////////////////////////////////////// |
| 829 | 829 |
| 830 class GLDashingCircleEffect : public GrGLGeometryProcessor { | 830 class GLDashingCircleEffect : public GrGLGeometryProcessor { |
| 831 public: | 831 public: |
| 832 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); | 832 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); |
| 833 | 833 |
| 834 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 834 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
| 835 | 835 |
| 836 static inline void GenKey(const GrGeometryProcessor&, | 836 static inline void GenKey(const GrGeometryProcessor&, |
| 837 const GrBatchTracker&, | 837 const GrBatchTracker&, |
| 838 const GrGLCaps&, | 838 const GrGLSLCaps&, |
| 839 GrProcessorKeyBuilder*); | 839 GrProcessorKeyBuilder*); |
| 840 | 840 |
| 841 virtual void setData(const GrGLProgramDataManager&, | 841 virtual void setData(const GrGLProgramDataManager&, |
| 842 const GrPrimitiveProcessor&, | 842 const GrPrimitiveProcessor&, |
| 843 const GrBatchTracker&) override; | 843 const GrBatchTracker&) override; |
| 844 | 844 |
| 845 private: | 845 private: |
| 846 UniformHandle fParamUniform; | 846 UniformHandle fParamUniform; |
| 847 UniformHandle fColorUniform; | 847 UniformHandle fColorUniform; |
| 848 GrColor fColor; | 848 GrColor fColor; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) { | 917 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) { |
| 918 GrGLfloat c[4]; | 918 GrGLfloat c[4]; |
| 919 GrColorToRGBAFloat(local.fColor, c); | 919 GrColorToRGBAFloat(local.fColor, c); |
| 920 pdman.set4fv(fColorUniform, 1, c); | 920 pdman.set4fv(fColorUniform, 1, c); |
| 921 fColor = local.fColor; | 921 fColor = local.fColor; |
| 922 } | 922 } |
| 923 } | 923 } |
| 924 | 924 |
| 925 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp, | 925 void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp, |
| 926 const GrBatchTracker& bt, | 926 const GrBatchTracker& bt, |
| 927 const GrGLCaps&, | 927 const GrGLSLCaps&, |
| 928 GrProcessorKeyBuilder* b) { | 928 GrProcessorKeyBuilder* b) { |
| 929 const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>(
); | 929 const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>(
); |
| 930 const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>(); | 930 const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>(); |
| 931 uint32_t key = 0; | 931 uint32_t key = 0; |
| 932 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0
x0; | 932 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0
x0; |
| 933 key |= ComputePosKey(gp.viewMatrix()) << 1; | 933 key |= ComputePosKey(gp.viewMatrix()) << 1; |
| 934 key |= dce.aaMode() << 8; | 934 key |= dce.aaMode() << 8; |
| 935 b->add32(key << 16 | local.fInputColorType); | 935 b->add32(key << 16 | local.fInputColorType); |
| 936 } | 936 } |
| 937 | 937 |
| 938 ////////////////////////////////////////////////////////////////////////////// | 938 ////////////////////////////////////////////////////////////////////////////// |
| 939 | 939 |
| 940 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, | 940 GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, |
| 941 DashAAMode aaMode, | 941 DashAAMode aaMode, |
| 942 const SkMatrix& localMatrix) { | 942 const SkMatrix& localMatrix) { |
| 943 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix)); | 943 return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix)); |
| 944 } | 944 } |
| 945 | 945 |
| 946 DashingCircleEffect::~DashingCircleEffect() {} | 946 DashingCircleEffect::~DashingCircleEffect() {} |
| 947 | 947 |
| 948 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou
t) const { | 948 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou
t) const { |
| 949 out->setUnknownSingleComponent(); | 949 out->setUnknownSingleComponent(); |
| 950 } | 950 } |
| 951 | 951 |
| 952 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, | 952 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 953 const GrGLCaps& caps, | 953 const GrGLSLCaps& caps, |
| 954 GrProcessorKeyBuilder* b) const { | 954 GrProcessorKeyBuilder* b) const { |
| 955 GLDashingCircleEffect::GenKey(*this, bt, caps, b); | 955 GLDashingCircleEffect::GenKey(*this, bt, caps, b); |
| 956 } | 956 } |
| 957 | 957 |
| 958 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack
er& bt, | 958 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack
er& bt, |
| 959 const GrGLCaps&) c
onst { | 959 const GrGLSLCaps&)
const { |
| 960 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); | 960 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); |
| 961 } | 961 } |
| 962 | 962 |
| 963 DashingCircleEffect::DashingCircleEffect(GrColor color, | 963 DashingCircleEffect::DashingCircleEffect(GrColor color, |
| 964 DashAAMode aaMode, | 964 DashAAMode aaMode, |
| 965 const SkMatrix& localMatrix) | 965 const SkMatrix& localMatrix) |
| 966 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { | 966 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { |
| 967 this->initClassID<DashingCircleEffect>(); | 967 this->initClassID<DashingCircleEffect>(); |
| 968 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 968 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
| 969 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe
rtexAttribType)); | 969 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe
rtexAttribType)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 | 1037 |
| 1038 const Attribute* inPosition() const { return fInPosition; } | 1038 const Attribute* inPosition() const { return fInPosition; } |
| 1039 | 1039 |
| 1040 const Attribute* inDashParams() const { return fInDashParams; } | 1040 const Attribute* inDashParams() const { return fInDashParams; } |
| 1041 | 1041 |
| 1042 const Attribute* inRectParams() const { return fInRectParams; } | 1042 const Attribute* inRectParams() const { return fInRectParams; } |
| 1043 | 1043 |
| 1044 DashAAMode aaMode() const { return fAAMode; } | 1044 DashAAMode aaMode() const { return fAAMode; } |
| 1045 | 1045 |
| 1046 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 1046 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 1047 const GrGLCaps& caps, | 1047 const GrGLSLCaps& caps, |
| 1048 GrProcessorKeyBuilder* b) const override; | 1048 GrProcessorKeyBuilder* b) const override; |
| 1049 | 1049 |
| 1050 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 1050 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 1051 const GrGLCaps&) const over
ride; | 1051 const GrGLSLCaps&) const ov
erride; |
| 1052 | 1052 |
| 1053 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; | 1053 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
| 1054 | 1054 |
| 1055 bool onCanMakeEqual(const GrBatchTracker&, | 1055 bool onCanMakeEqual(const GrBatchTracker&, |
| 1056 const GrGeometryProcessor&, | 1056 const GrGeometryProcessor&, |
| 1057 const GrBatchTracker&) const override; | 1057 const GrBatchTracker&) const override; |
| 1058 | 1058 |
| 1059 private: | 1059 private: |
| 1060 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix); | 1060 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix); |
| 1061 | 1061 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1076 ////////////////////////////////////////////////////////////////////////////// | 1076 ////////////////////////////////////////////////////////////////////////////// |
| 1077 | 1077 |
| 1078 class GLDashingLineEffect : public GrGLGeometryProcessor { | 1078 class GLDashingLineEffect : public GrGLGeometryProcessor { |
| 1079 public: | 1079 public: |
| 1080 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); | 1080 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); |
| 1081 | 1081 |
| 1082 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 1082 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
| 1083 | 1083 |
| 1084 static inline void GenKey(const GrGeometryProcessor&, | 1084 static inline void GenKey(const GrGeometryProcessor&, |
| 1085 const GrBatchTracker&, | 1085 const GrBatchTracker&, |
| 1086 const GrGLCaps&, | 1086 const GrGLSLCaps&, |
| 1087 GrProcessorKeyBuilder*); | 1087 GrProcessorKeyBuilder*); |
| 1088 | 1088 |
| 1089 virtual void setData(const GrGLProgramDataManager&, | 1089 virtual void setData(const GrGLProgramDataManager&, |
| 1090 const GrPrimitiveProcessor&, | 1090 const GrPrimitiveProcessor&, |
| 1091 const GrBatchTracker&) override; | 1091 const GrBatchTracker&) override; |
| 1092 | 1092 |
| 1093 private: | 1093 private: |
| 1094 GrColor fColor; | 1094 GrColor fColor; |
| 1095 UniformHandle fColorUniform; | 1095 UniformHandle fColorUniform; |
| 1096 typedef GrGLGeometryProcessor INHERITED; | 1096 typedef GrGLGeometryProcessor INHERITED; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) { | 1177 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) { |
| 1178 GrGLfloat c[4]; | 1178 GrGLfloat c[4]; |
| 1179 GrColorToRGBAFloat(local.fColor, c); | 1179 GrColorToRGBAFloat(local.fColor, c); |
| 1180 pdman.set4fv(fColorUniform, 1, c); | 1180 pdman.set4fv(fColorUniform, 1, c); |
| 1181 fColor = local.fColor; | 1181 fColor = local.fColor; |
| 1182 } | 1182 } |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp, | 1185 void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp, |
| 1186 const GrBatchTracker& bt, | 1186 const GrBatchTracker& bt, |
| 1187 const GrGLCaps&, | 1187 const GrGLSLCaps&, |
| 1188 GrProcessorKeyBuilder* b) { | 1188 GrProcessorKeyBuilder* b) { |
| 1189 const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>(); | 1189 const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>(); |
| 1190 const DashingLineEffect& de = gp.cast<DashingLineEffect>(); | 1190 const DashingLineEffect& de = gp.cast<DashingLineEffect>(); |
| 1191 uint32_t key = 0; | 1191 uint32_t key = 0; |
| 1192 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0
x0; | 1192 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0
x0; |
| 1193 key |= ComputePosKey(gp.viewMatrix()) << 1; | 1193 key |= ComputePosKey(gp.viewMatrix()) << 1; |
| 1194 key |= de.aaMode() << 8; | 1194 key |= de.aaMode() << 8; |
| 1195 b->add32(key << 16 | local.fInputColorType); | 1195 b->add32(key << 16 | local.fInputColorType); |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 ////////////////////////////////////////////////////////////////////////////// | 1198 ////////////////////////////////////////////////////////////////////////////// |
| 1199 | 1199 |
| 1200 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, | 1200 GrGeometryProcessor* DashingLineEffect::Create(GrColor color, |
| 1201 DashAAMode aaMode, | 1201 DashAAMode aaMode, |
| 1202 const SkMatrix& localMatrix) { | 1202 const SkMatrix& localMatrix) { |
| 1203 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix)); | 1203 return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix)); |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 DashingLineEffect::~DashingLineEffect() {} | 1206 DashingLineEffect::~DashingLineEffect() {} |
| 1207 | 1207 |
| 1208 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out)
const { | 1208 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out)
const { |
| 1209 out->setUnknownSingleComponent(); | 1209 out->setUnknownSingleComponent(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, | 1212 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 1213 const GrGLCaps& caps, | 1213 const GrGLSLCaps& caps, |
| 1214 GrProcessorKeyBuilder* b) const { | 1214 GrProcessorKeyBuilder* b) const { |
| 1215 GLDashingLineEffect::GenKey(*this, bt, caps, b); | 1215 GLDashingLineEffect::GenKey(*this, bt, caps, b); |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker
& bt, | 1218 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker
& bt, |
| 1219 const GrGLCaps&) con
st { | 1219 const GrGLSLCaps&) c
onst { |
| 1220 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); | 1220 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 DashingLineEffect::DashingLineEffect(GrColor color, | 1223 DashingLineEffect::DashingLineEffect(GrColor color, |
| 1224 DashAAMode aaMode, | 1224 DashAAMode aaMode, |
| 1225 const SkMatrix& localMatrix) | 1225 const SkMatrix& localMatrix) |
| 1226 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { | 1226 : INHERITED(color, SkMatrix::I(), localMatrix), fAAMode(aaMode) { |
| 1227 this->initClassID<DashingLineEffect>(); | 1227 this->initClassID<DashingLineEffect>(); |
| 1228 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 1228 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
| 1229 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe
rtexAttribType)); | 1229 fInDashParams = &this->addVertexAttrib(Attribute("inDashParams", kVec3f_GrVe
rtexAttribType)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 switch (cap) { | 1272 switch (cap) { |
| 1273 case kRound_DashCap: | 1273 case kRound_DashCap: |
| 1274 return DashingCircleEffect::Create(color, dashAAMode, localMatrix); | 1274 return DashingCircleEffect::Create(color, dashAAMode, localMatrix); |
| 1275 case kNonRound_DashCap: | 1275 case kNonRound_DashCap: |
| 1276 return DashingLineEffect::Create(color, dashAAMode, localMatrix); | 1276 return DashingLineEffect::Create(color, dashAAMode, localMatrix); |
| 1277 default: | 1277 default: |
| 1278 SkFAIL("Unexpected dashed cap."); | 1278 SkFAIL("Unexpected dashed cap."); |
| 1279 } | 1279 } |
| 1280 return NULL; | 1280 return NULL; |
| 1281 } | 1281 } |
| OLD | NEW |