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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 SkScalar fIntervals[2]; | 250 SkScalar fIntervals[2]; |
251 SkScalar fParallelScale; | 251 SkScalar fParallelScale; |
252 SkScalar fPerpendicularScale; | 252 SkScalar fPerpendicularScale; |
253 SkDEBUGCODE(SkRect fDevBounds;) | 253 SkDEBUGCODE(SkRect fDevBounds;) |
254 }; | 254 }; |
255 | 255 |
256 static GrBatch* Create(const Geometry& geometry, SkPaint::Cap cap, bool useA
A, bool fullDash) { | 256 static GrBatch* Create(const Geometry& geometry, SkPaint::Cap cap, bool useA
A, bool fullDash) { |
257 return SkNEW_ARGS(DashBatch, (geometry, cap, useAA, fullDash)); | 257 return SkNEW_ARGS(DashBatch, (geometry, cap, useAA, fullDash)); |
258 } | 258 } |
259 | 259 |
260 const char* name() const SK_OVERRIDE { return "DashBatch"; } | 260 const char* name() const override { return "DashBatch"; } |
261 | 261 |
262 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 262 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
263 // When this is called on a batch, there is only one geometry bundle | 263 // When this is called on a batch, there is only one geometry bundle |
264 out->setKnownFourComponents(fGeoData[0].fColor); | 264 out->setKnownFourComponents(fGeoData[0].fColor); |
265 } | 265 } |
266 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 266 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
267 out->setUnknownSingleComponent(); | 267 out->setUnknownSingleComponent(); |
268 } | 268 } |
269 | 269 |
270 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 270 void initBatchTracker(const GrPipelineInfo& init) override { |
271 // Handle any color overrides | 271 // Handle any color overrides |
272 if (init.fColorIgnored) { | 272 if (init.fColorIgnored) { |
273 fGeoData[0].fColor = GrColor_ILLEGAL; | 273 fGeoData[0].fColor = GrColor_ILLEGAL; |
274 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 274 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
275 fGeoData[0].fColor = init.fOverrideColor; | 275 fGeoData[0].fColor = init.fOverrideColor; |
276 } | 276 } |
277 | 277 |
278 // setup batch properties | 278 // setup batch properties |
279 fBatch.fColorIgnored = init.fColorIgnored; | 279 fBatch.fColorIgnored = init.fColorIgnored; |
280 fBatch.fColor = fGeoData[0].fColor; | 280 fBatch.fColor = fGeoData[0].fColor; |
281 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 281 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
282 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 282 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
283 } | 283 } |
284 | 284 |
285 struct DashDraw { | 285 struct DashDraw { |
286 SkScalar fStartOffset; | 286 SkScalar fStartOffset; |
287 SkScalar fStrokeWidth; | 287 SkScalar fStrokeWidth; |
288 SkScalar fLineLength; | 288 SkScalar fLineLength; |
289 SkScalar fHalfDevStroke; | 289 SkScalar fHalfDevStroke; |
290 SkScalar fDevBloat; | 290 SkScalar fDevBloat; |
291 bool fLineDone; | 291 bool fLineDone; |
292 bool fHasStartRect; | 292 bool fHasStartRect; |
293 bool fHasEndRect; | 293 bool fHasEndRect; |
294 }; | 294 }; |
295 | 295 |
296 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 296 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
297 int instanceCount = fGeoData.count(); | 297 int instanceCount = fGeoData.count(); |
298 | 298 |
299 SkMatrix invert; | 299 SkMatrix invert; |
300 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 300 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { |
301 SkDebugf("Failed to invert\n"); | 301 SkDebugf("Failed to invert\n"); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 SkPaint::Cap cap = this->cap(); | 305 SkPaint::Cap cap = this->cap(); |
306 | 306 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 private: | 626 private: |
627 DashBatch(const Geometry& geometry, SkPaint::Cap cap, bool useAA, bool fullD
ash) { | 627 DashBatch(const Geometry& geometry, SkPaint::Cap cap, bool useAA, bool fullD
ash) { |
628 this->initClassID<DashBatch>(); | 628 this->initClassID<DashBatch>(); |
629 fGeoData.push_back(geometry); | 629 fGeoData.push_back(geometry); |
630 | 630 |
631 fBatch.fUseAA = useAA; | 631 fBatch.fUseAA = useAA; |
632 fBatch.fCap = cap; | 632 fBatch.fCap = cap; |
633 fBatch.fFullDash = fullDash; | 633 fBatch.fFullDash = fullDash; |
634 } | 634 } |
635 | 635 |
636 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 636 bool onCombineIfPossible(GrBatch* t) override { |
637 DashBatch* that = t->cast<DashBatch>(); | 637 DashBatch* that = t->cast<DashBatch>(); |
638 | 638 |
639 if (this->useAA() != that->useAA()) { | 639 if (this->useAA() != that->useAA()) { |
640 return false; | 640 return false; |
641 } | 641 } |
642 | 642 |
643 if (this->fullDash() != that->fullDash()) { | 643 if (this->fullDash() != that->fullDash()) { |
644 return false; | 644 return false; |
645 } | 645 } |
646 | 646 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrPrimitiveEdgeType edgeType, | 773 GrPrimitiveEdgeType edgeType, |
774 const SkMatrix& localMatrix); | 774 const SkMatrix& localMatrix); |
775 | 775 |
776 virtual ~DashingCircleEffect(); | 776 virtual ~DashingCircleEffect(); |
777 | 777 |
778 const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; } | 778 const char* name() const override { return "DashingCircleEffect"; } |
779 | 779 |
780 const Attribute* inPosition() const { return fInPosition; } | 780 const Attribute* inPosition() const { return fInPosition; } |
781 | 781 |
782 const Attribute* inDashParams() const { return fInDashParams; } | 782 const Attribute* inDashParams() const { return fInDashParams; } |
783 | 783 |
784 const Attribute* inCircleParams() const { return fInCircleParams; } | 784 const Attribute* inCircleParams() const { return fInCircleParams; } |
785 | 785 |
786 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 786 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
787 | 787 |
788 virtual void getGLProcessorKey(const GrBatchTracker&, | 788 virtual void getGLProcessorKey(const GrBatchTracker&, |
789 const GrGLCaps&, | 789 const GrGLCaps&, |
790 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 790 GrProcessorKeyBuilder* b) const override; |
791 | 791 |
792 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, | 792 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&, |
793 const GrGLCaps&) const SK_O
VERRIDE; | 793 const GrGLCaps&) const over
ride; |
794 | 794 |
795 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
SK_OVERRIDE; | 795 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
796 | 796 |
797 bool onCanMakeEqual(const GrBatchTracker&, | 797 bool onCanMakeEqual(const GrBatchTracker&, |
798 const GrGeometryProcessor&, | 798 const GrGeometryProcessor&, |
799 const GrBatchTracker&) const SK_OVERRIDE; | 799 const GrBatchTracker&) const override; |
800 | 800 |
801 private: | 801 private: |
802 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const SkMatrix& l
ocalMatrix); | 802 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const SkMatrix& l
ocalMatrix); |
803 | 803 |
804 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 804 bool onIsEqual(const GrGeometryProcessor& other) const override; |
805 | 805 |
806 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE; | 806 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; |
807 | 807 |
808 GrPrimitiveEdgeType fEdgeType; | 808 GrPrimitiveEdgeType fEdgeType; |
809 const Attribute* fInPosition; | 809 const Attribute* fInPosition; |
810 const Attribute* fInDashParams; | 810 const Attribute* fInDashParams; |
811 const Attribute* fInCircleParams; | 811 const Attribute* fInCircleParams; |
812 | 812 |
813 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 813 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
814 | 814 |
815 typedef GrGeometryProcessor INHERITED; | 815 typedef GrGeometryProcessor INHERITED; |
816 }; | 816 }; |
817 | 817 |
818 ////////////////////////////////////////////////////////////////////////////// | 818 ////////////////////////////////////////////////////////////////////////////// |
819 | 819 |
820 class GLDashingCircleEffect : public GrGLGeometryProcessor { | 820 class GLDashingCircleEffect : public GrGLGeometryProcessor { |
821 public: | 821 public: |
822 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); | 822 GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); |
823 | 823 |
824 void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE; | 824 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
825 | 825 |
826 static inline void GenKey(const GrGeometryProcessor&, | 826 static inline void GenKey(const GrGeometryProcessor&, |
827 const GrBatchTracker&, | 827 const GrBatchTracker&, |
828 const GrGLCaps&, | 828 const GrGLCaps&, |
829 GrProcessorKeyBuilder*); | 829 GrProcessorKeyBuilder*); |
830 | 830 |
831 virtual void setData(const GrGLProgramDataManager&, | 831 virtual void setData(const GrGLProgramDataManager&, |
832 const GrPrimitiveProcessor&, | 832 const GrPrimitiveProcessor&, |
833 const GrBatchTracker&) SK_OVERRIDE; | 833 const GrBatchTracker&) override; |
834 | 834 |
835 private: | 835 private: |
836 UniformHandle fParamUniform; | 836 UniformHandle fParamUniform; |
837 UniformHandle fColorUniform; | 837 UniformHandle fColorUniform; |
838 GrColor fColor; | 838 GrColor fColor; |
839 SkScalar fPrevRadius; | 839 SkScalar fPrevRadius; |
840 SkScalar fPrevCenterX; | 840 SkScalar fPrevCenterX; |
841 SkScalar fPrevIntervalLength; | 841 SkScalar fPrevIntervalLength; |
842 typedef GrGLGeometryProcessor INHERITED; | 842 typedef GrGLGeometryProcessor INHERITED; |
843 }; | 843 }; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 class DashingLineEffect : public GrGeometryProcessor { | 1017 class DashingLineEffect : public GrGeometryProcessor { |
1018 public: | 1018 public: |
1019 typedef SkPathEffect::DashInfo DashInfo; | 1019 typedef SkPathEffect::DashInfo DashInfo; |
1020 | 1020 |
1021 static GrGeometryProcessor* Create(GrColor, | 1021 static GrGeometryProcessor* Create(GrColor, |
1022 GrPrimitiveEdgeType edgeType, | 1022 GrPrimitiveEdgeType edgeType, |
1023 const SkMatrix& localMatrix); | 1023 const SkMatrix& localMatrix); |
1024 | 1024 |
1025 virtual ~DashingLineEffect(); | 1025 virtual ~DashingLineEffect(); |
1026 | 1026 |
1027 const char* name() const SK_OVERRIDE { return "DashingEffect"; } | 1027 const char* name() const override { return "DashingEffect"; } |
1028 | 1028 |
1029 const Attribute* inPosition() const { return fInPosition; } | 1029 const Attribute* inPosition() const { return fInPosition; } |
1030 | 1030 |
1031 const Attribute* inDashParams() const { return fInDashParams; } | 1031 const Attribute* inDashParams() const { return fInDashParams; } |
1032 | 1032 |
1033 const Attribute* inRectParams() const { return fInRectParams; } | 1033 const Attribute* inRectParams() const { return fInRectParams; } |
1034 | 1034 |
1035 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 1035 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
1036 | 1036 |
1037 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 1037 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
1038 const GrGLCaps& caps, | 1038 const GrGLCaps& caps, |
1039 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 1039 GrProcessorKeyBuilder* b) const override; |
1040 | 1040 |
1041 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 1041 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
1042 const GrGLCaps&) const SK_O
VERRIDE; | 1042 const GrGLCaps&) const over
ride; |
1043 | 1043 |
1044 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
SK_OVERRIDE; | 1044 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; |
1045 | 1045 |
1046 bool onCanMakeEqual(const GrBatchTracker&, | 1046 bool onCanMakeEqual(const GrBatchTracker&, |
1047 const GrGeometryProcessor&, | 1047 const GrGeometryProcessor&, |
1048 const GrBatchTracker&) const SK_OVERRIDE; | 1048 const GrBatchTracker&) const override; |
1049 | 1049 |
1050 private: | 1050 private: |
1051 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const SkMatrix& loc
alMatrix); | 1051 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const SkMatrix& loc
alMatrix); |
1052 | 1052 |
1053 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 1053 bool onIsEqual(const GrGeometryProcessor& other) const override; |
1054 | 1054 |
1055 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE; | 1055 void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const override; |
1056 | 1056 |
1057 GrPrimitiveEdgeType fEdgeType; | 1057 GrPrimitiveEdgeType fEdgeType; |
1058 const Attribute* fInPosition; | 1058 const Attribute* fInPosition; |
1059 const Attribute* fInDashParams; | 1059 const Attribute* fInDashParams; |
1060 const Attribute* fInRectParams; | 1060 const Attribute* fInRectParams; |
1061 | 1061 |
1062 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 1062 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
1063 | 1063 |
1064 typedef GrGeometryProcessor INHERITED; | 1064 typedef GrGeometryProcessor INHERITED; |
1065 }; | 1065 }; |
1066 | 1066 |
1067 ////////////////////////////////////////////////////////////////////////////// | 1067 ////////////////////////////////////////////////////////////////////////////// |
1068 | 1068 |
1069 class GLDashingLineEffect : public GrGLGeometryProcessor { | 1069 class GLDashingLineEffect : public GrGLGeometryProcessor { |
1070 public: | 1070 public: |
1071 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); | 1071 GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); |
1072 | 1072 |
1073 void onEmitCode(EmitArgs&, GrGPArgs*) SK_OVERRIDE; | 1073 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
1074 | 1074 |
1075 static inline void GenKey(const GrGeometryProcessor&, | 1075 static inline void GenKey(const GrGeometryProcessor&, |
1076 const GrBatchTracker&, | 1076 const GrBatchTracker&, |
1077 const GrGLCaps&, | 1077 const GrGLCaps&, |
1078 GrProcessorKeyBuilder*); | 1078 GrProcessorKeyBuilder*); |
1079 | 1079 |
1080 virtual void setData(const GrGLProgramDataManager&, | 1080 virtual void setData(const GrGLProgramDataManager&, |
1081 const GrPrimitiveProcessor&, | 1081 const GrPrimitiveProcessor&, |
1082 const GrBatchTracker&) SK_OVERRIDE; | 1082 const GrBatchTracker&) override; |
1083 | 1083 |
1084 private: | 1084 private: |
1085 GrColor fColor; | 1085 GrColor fColor; |
1086 UniformHandle fColorUniform; | 1086 UniformHandle fColorUniform; |
1087 typedef GrGLGeometryProcessor INHERITED; | 1087 typedef GrGLGeometryProcessor INHERITED; |
1088 }; | 1088 }; |
1089 | 1089 |
1090 GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&, | 1090 GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&, |
1091 const GrBatchTracker&) { | 1091 const GrBatchTracker&) { |
1092 fColor = GrColor_ILLEGAL; | 1092 fColor = GrColor_ILLEGAL; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 switch (cap) { | 1257 switch (cap) { |
1258 case kRound_DashCap: | 1258 case kRound_DashCap: |
1259 return DashingCircleEffect::Create(color, edgeType, localMatrix); | 1259 return DashingCircleEffect::Create(color, edgeType, localMatrix); |
1260 case kNonRound_DashCap: | 1260 case kNonRound_DashCap: |
1261 return DashingLineEffect::Create(color, edgeType, localMatrix); | 1261 return DashingLineEffect::Create(color, edgeType, localMatrix); |
1262 default: | 1262 default: |
1263 SkFAIL("Unexpected dashed cap."); | 1263 SkFAIL("Unexpected dashed cap."); |
1264 } | 1264 } |
1265 return NULL; | 1265 return NULL; |
1266 } | 1266 } |
OLD | NEW |