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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
11 #include "GrBatchTest.h" | 11 #include "GrBatchTest.h" |
12 #include "GrCaps.h" | 12 #include "GrCaps.h" |
13 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrCoordTransform.h" | 15 #include "GrCoordTransform.h" |
16 #include "GrDefaultGeoProcFactory.h" | 16 #include "GrDefaultGeoProcFactory.h" |
17 #include "GrDrawTarget.h" | 17 #include "GrDrawTarget.h" |
18 #include "GrInvariantOutput.h" | 18 #include "GrInvariantOutput.h" |
19 #include "GrProcessor.h" | 19 #include "GrProcessor.h" |
20 #include "GrStrokeInfo.h" | 20 #include "GrStrokeInfo.h" |
21 #include "GrVertexBuffer.h" | 21 #include "GrVertexBuffer.h" |
22 #include "SkGr.h" | 22 #include "SkGr.h" |
23 #include "batches/GrVertexBatch.h" | 23 #include "batches/GrVertexBatch.h" |
24 #include "gl/GrGLGeometryProcessor.h" | |
25 #include "glsl/GrGLSLFragmentProcessor.h" | |
26 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 24 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 25 #include "glsl/GrGLSLGeometryProcessor.h" |
27 #include "glsl/GrGLSLProgramBuilder.h" | 26 #include "glsl/GrGLSLProgramBuilder.h" |
28 #include "glsl/GrGLSLProgramDataManager.h" | 27 #include "glsl/GrGLSLProgramDataManager.h" |
29 #include "glsl/GrGLSLVertexShaderBuilder.h" | 28 #include "glsl/GrGLSLVertexShaderBuilder.h" |
30 | 29 |
31 /////////////////////////////////////////////////////////////////////////////// | 30 /////////////////////////////////////////////////////////////////////////////// |
32 | 31 |
33 // Returns whether or not the gpu can fast path the dash line effect. | 32 // Returns whether or not the gpu can fast path the dash line effect. |
34 bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo&
strokeInfo, | 33 bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo&
strokeInfo, |
35 const SkMatrix& viewMatrix) { | 34 const SkMatrix& viewMatrix) { |
36 // Pts must be either horizontal or vertical in src space | 35 // Pts must be either horizontal or vertical in src space |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 GrColor color() const { return fColor; } | 785 GrColor color() const { return fColor; } |
787 | 786 |
788 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 787 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
789 | 788 |
790 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 789 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
791 | 790 |
792 bool usesLocalCoords() const { return fUsesLocalCoords; } | 791 bool usesLocalCoords() const { return fUsesLocalCoords; } |
793 | 792 |
794 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const ov
erride; | 793 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const ov
erride; |
795 | 794 |
796 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; | 795 GrGLSLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override
; |
797 | 796 |
798 private: | 797 private: |
799 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, | 798 DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, |
800 bool usesLocalCoords); | 799 bool usesLocalCoords); |
801 | 800 |
802 GrColor fColor; | 801 GrColor fColor; |
803 SkMatrix fLocalMatrix; | 802 SkMatrix fLocalMatrix; |
804 bool fUsesLocalCoords; | 803 bool fUsesLocalCoords; |
805 DashAAMode fAAMode; | 804 DashAAMode fAAMode; |
806 const Attribute* fInPosition; | 805 const Attribute* fInPosition; |
807 const Attribute* fInDashParams; | 806 const Attribute* fInDashParams; |
808 const Attribute* fInCircleParams; | 807 const Attribute* fInCircleParams; |
809 | 808 |
810 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 809 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
811 | 810 |
812 typedef GrGeometryProcessor INHERITED; | 811 typedef GrGeometryProcessor INHERITED; |
813 }; | 812 }; |
814 | 813 |
815 ////////////////////////////////////////////////////////////////////////////// | 814 ////////////////////////////////////////////////////////////////////////////// |
816 | 815 |
817 class GLDashingCircleEffect : public GrGLGeometryProcessor { | 816 class GLDashingCircleEffect : public GrGLSLGeometryProcessor { |
818 public: | 817 public: |
819 GLDashingCircleEffect(); | 818 GLDashingCircleEffect(); |
820 | 819 |
821 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 820 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
822 | 821 |
823 static inline void GenKey(const GrGeometryProcessor&, | 822 static inline void GenKey(const GrGeometryProcessor&, |
824 const GrGLSLCaps&, | 823 const GrGLSLCaps&, |
825 GrProcessorKeyBuilder*); | 824 GrProcessorKeyBuilder*); |
826 | 825 |
827 void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) o
verride; | 826 void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) o
verride; |
828 | 827 |
829 void setTransformData(const GrPrimitiveProcessor& primProc, | 828 void setTransformData(const GrPrimitiveProcessor& primProc, |
830 const GrGLSLProgramDataManager& pdman, | 829 const GrGLSLProgramDataManager& pdman, |
831 int index, | 830 int index, |
832 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { | 831 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { |
833 this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index
, transforms); | 832 this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index
, transforms); |
834 } | 833 } |
835 | 834 |
836 private: | 835 private: |
837 UniformHandle fParamUniform; | 836 UniformHandle fParamUniform; |
838 UniformHandle fColorUniform; | 837 UniformHandle fColorUniform; |
839 GrColor fColor; | 838 GrColor fColor; |
840 SkScalar fPrevRadius; | 839 SkScalar fPrevRadius; |
841 SkScalar fPrevCenterX; | 840 SkScalar fPrevCenterX; |
842 SkScalar fPrevIntervalLength; | 841 SkScalar fPrevIntervalLength; |
843 typedef GrGLGeometryProcessor INHERITED; | 842 typedef GrGLSLGeometryProcessor INHERITED; |
844 }; | 843 }; |
845 | 844 |
846 GLDashingCircleEffect::GLDashingCircleEffect() { | 845 GLDashingCircleEffect::GLDashingCircleEffect() { |
847 fColor = GrColor_ILLEGAL; | 846 fColor = GrColor_ILLEGAL; |
848 fPrevRadius = SK_ScalarMin; | 847 fPrevRadius = SK_ScalarMin; |
849 fPrevCenterX = SK_ScalarMin; | 848 fPrevCenterX = SK_ScalarMin; |
850 fPrevIntervalLength = SK_ScalarMax; | 849 fPrevIntervalLength = SK_ScalarMax; |
851 } | 850 } |
852 | 851 |
853 void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 852 void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 DashAAMode aaMode, | 926 DashAAMode aaMode, |
928 const SkMatrix& localMatrix, | 927 const SkMatrix& localMatrix, |
929 bool usesLocalCoords) { | 928 bool usesLocalCoords) { |
930 return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords); | 929 return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords); |
931 } | 930 } |
932 | 931 |
933 void DashingCircleEffect::getGLProcessorKey(const GrGLSLCaps& caps,GrProcessorKe
yBuilder* b) const { | 932 void DashingCircleEffect::getGLProcessorKey(const GrGLSLCaps& caps,GrProcessorKe
yBuilder* b) const { |
934 GLDashingCircleEffect::GenKey(*this, caps, b); | 933 GLDashingCircleEffect::GenKey(*this, caps, b); |
935 } | 934 } |
936 | 935 |
937 GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrGLSLCaps&)
const { | 936 GrGLSLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrGLSLCaps
&) const { |
938 return new GLDashingCircleEffect(); | 937 return new GLDashingCircleEffect(); |
939 } | 938 } |
940 | 939 |
941 DashingCircleEffect::DashingCircleEffect(GrColor color, | 940 DashingCircleEffect::DashingCircleEffect(GrColor color, |
942 DashAAMode aaMode, | 941 DashAAMode aaMode, |
943 const SkMatrix& localMatrix, | 942 const SkMatrix& localMatrix, |
944 bool usesLocalCoords) | 943 bool usesLocalCoords) |
945 : fColor(color) | 944 : fColor(color) |
946 , fLocalMatrix(localMatrix) | 945 , fLocalMatrix(localMatrix) |
947 , fUsesLocalCoords(usesLocalCoords) | 946 , fUsesLocalCoords(usesLocalCoords) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 GrColor color() const { return fColor; } | 996 GrColor color() const { return fColor; } |
998 | 997 |
999 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 998 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
1000 | 999 |
1001 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 1000 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
1002 | 1001 |
1003 bool usesLocalCoords() const { return fUsesLocalCoords; } | 1002 bool usesLocalCoords() const { return fUsesLocalCoords; } |
1004 | 1003 |
1005 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 1004 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
1006 | 1005 |
1007 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; | 1006 GrGLSLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override
; |
1008 | 1007 |
1009 private: | 1008 private: |
1010 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, | 1009 DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, |
1011 bool usesLocalCoords); | 1010 bool usesLocalCoords); |
1012 | 1011 |
1013 GrColor fColor; | 1012 GrColor fColor; |
1014 SkMatrix fLocalMatrix; | 1013 SkMatrix fLocalMatrix; |
1015 bool fUsesLocalCoords; | 1014 bool fUsesLocalCoords; |
1016 DashAAMode fAAMode; | 1015 DashAAMode fAAMode; |
1017 const Attribute* fInPosition; | 1016 const Attribute* fInPosition; |
1018 const Attribute* fInDashParams; | 1017 const Attribute* fInDashParams; |
1019 const Attribute* fInRectParams; | 1018 const Attribute* fInRectParams; |
1020 | 1019 |
1021 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 1020 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
1022 | 1021 |
1023 typedef GrGeometryProcessor INHERITED; | 1022 typedef GrGeometryProcessor INHERITED; |
1024 }; | 1023 }; |
1025 | 1024 |
1026 ////////////////////////////////////////////////////////////////////////////// | 1025 ////////////////////////////////////////////////////////////////////////////// |
1027 | 1026 |
1028 class GLDashingLineEffect : public GrGLGeometryProcessor { | 1027 class GLDashingLineEffect : public GrGLSLGeometryProcessor { |
1029 public: | 1028 public: |
1030 GLDashingLineEffect(); | 1029 GLDashingLineEffect(); |
1031 | 1030 |
1032 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 1031 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
1033 | 1032 |
1034 static inline void GenKey(const GrGeometryProcessor&, | 1033 static inline void GenKey(const GrGeometryProcessor&, |
1035 const GrGLSLCaps&, | 1034 const GrGLSLCaps&, |
1036 GrProcessorKeyBuilder*); | 1035 GrProcessorKeyBuilder*); |
1037 | 1036 |
1038 void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) o
verride; | 1037 void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) o
verride; |
1039 | 1038 |
1040 void setTransformData(const GrPrimitiveProcessor& primProc, | 1039 void setTransformData(const GrPrimitiveProcessor& primProc, |
1041 const GrGLSLProgramDataManager& pdman, | 1040 const GrGLSLProgramDataManager& pdman, |
1042 int index, | 1041 int index, |
1043 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { | 1042 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { |
1044 this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index,
transforms); | 1043 this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index,
transforms); |
1045 } | 1044 } |
1046 | 1045 |
1047 private: | 1046 private: |
1048 GrColor fColor; | 1047 GrColor fColor; |
1049 UniformHandle fColorUniform; | 1048 UniformHandle fColorUniform; |
1050 typedef GrGLGeometryProcessor INHERITED; | 1049 typedef GrGLSLGeometryProcessor INHERITED; |
1051 }; | 1050 }; |
1052 | 1051 |
1053 GLDashingLineEffect::GLDashingLineEffect() { | 1052 GLDashingLineEffect::GLDashingLineEffect() { |
1054 fColor = GrColor_ILLEGAL; | 1053 fColor = GrColor_ILLEGAL; |
1055 } | 1054 } |
1056 | 1055 |
1057 void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 1056 void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
1058 const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>(); | 1057 const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>(); |
1059 GrGLSLGPBuilder* pb = args.fPB; | 1058 GrGLSLGPBuilder* pb = args.fPB; |
1060 | 1059 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 const SkMatrix& localMatrix, | 1151 const SkMatrix& localMatrix, |
1153 bool usesLocalCoords) { | 1152 bool usesLocalCoords) { |
1154 return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords); | 1153 return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords); |
1155 } | 1154 } |
1156 | 1155 |
1157 void DashingLineEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 1156 void DashingLineEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
1158 GrProcessorKeyBuilder* b) const { | 1157 GrProcessorKeyBuilder* b) const { |
1159 GLDashingLineEffect::GenKey(*this, caps, b); | 1158 GLDashingLineEffect::GenKey(*this, caps, b); |
1160 } | 1159 } |
1161 | 1160 |
1162 GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrGLSLCaps&) c
onst { | 1161 GrGLSLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrGLSLCaps&)
const { |
1163 return new GLDashingLineEffect(); | 1162 return new GLDashingLineEffect(); |
1164 } | 1163 } |
1165 | 1164 |
1166 DashingLineEffect::DashingLineEffect(GrColor color, | 1165 DashingLineEffect::DashingLineEffect(GrColor color, |
1167 DashAAMode aaMode, | 1166 DashAAMode aaMode, |
1168 const SkMatrix& localMatrix, | 1167 const SkMatrix& localMatrix, |
1169 bool usesLocalCoords) | 1168 bool usesLocalCoords) |
1170 : fColor(color) | 1169 : fColor(color) |
1171 , fLocalMatrix(localMatrix) | 1170 , fLocalMatrix(localMatrix) |
1172 , fUsesLocalCoords(usesLocalCoords) | 1171 , fUsesLocalCoords(usesLocalCoords) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 info.fIntervals = intervals; | 1280 info.fIntervals = intervals; |
1282 info.fCount = 2; | 1281 info.fCount = 2; |
1283 info.fPhase = phase; | 1282 info.fPhase = phase; |
1284 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); | 1283 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); |
1285 SkASSERT(success); | 1284 SkASSERT(success); |
1286 | 1285 |
1287 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); | 1286 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); |
1288 } | 1287 } |
1289 | 1288 |
1290 #endif | 1289 #endif |
OLD | NEW |