| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef GrAAStrokeRectBatch_DEFINED | 8 #ifndef GrAAStrokeRectBatch_DEFINED |
| 9 #define GrAAStrokeRectBatch_DEFINED | 9 #define GrAAStrokeRectBatch_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
| 13 #include "GrVertexBatch.h" | 13 #include "GrVertexBatch.h" |
| 14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
| 15 #include "SkRect.h" | 15 #include "SkRect.h" |
| 16 | 16 |
| 17 class GrResourceProvider; |
| 18 |
| 17 class GrAAStrokeRectBatch : public GrVertexBatch { | 19 class GrAAStrokeRectBatch : public GrVertexBatch { |
| 18 public: | 20 public: |
| 19 // TODO support AA rotated stroke rects by copying around view matrices | 21 // TODO support AA rotated stroke rects by copying around view matrices |
| 20 struct Geometry { | 22 struct Geometry { |
| 21 GrColor fColor; | 23 GrColor fColor; |
| 22 SkRect fDevOutside; | 24 SkRect fDevOutside; |
| 23 SkRect fDevOutsideAssist; | 25 SkRect fDevOutsideAssist; |
| 24 SkRect fDevInside; | 26 SkRect fDevInside; |
| 25 bool fMiterStroke; | 27 bool fMiterStroke; |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix) { | 30 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix) { |
| 29 return SkNEW_ARGS(GrAAStrokeRectBatch, (geometry, viewMatrix)); | 31 return SkNEW_ARGS(GrAAStrokeRectBatch, (geometry, viewMatrix)); |
| 30 } | 32 } |
| 31 | 33 |
| 32 const char* name() const override { return "AAStrokeRect"; } | 34 const char* name() const override { return "AAStrokeRect"; } |
| 33 | 35 |
| 34 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 36 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 35 // When this is called on a batch, there is only one geometry bundle | 37 // When this is called on a batch, there is only one geometry bundle |
| 36 out->setKnownFourComponents(fGeoData[0].fColor); | 38 out->setKnownFourComponents(fGeoData[0].fColor); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 41 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 40 out->setUnknownSingleComponent(); | 42 out->setUnknownSingleComponent(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void initBatchTracker(const GrPipelineOptimizations&) override; | 45 void initBatchTracker(const GrPipelineOptimizations&) override; |
| 44 | 46 |
| 45 void generateGeometry(GrBatchTarget* batchTarget) override; | |
| 46 | |
| 47 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 47 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 void onPrepareDraws(Target*) override; |
| 51 |
| 50 GrAAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix) { | 52 GrAAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix) { |
| 51 this->initClassID<GrAAStrokeRectBatch>(); | 53 this->initClassID<GrAAStrokeRectBatch>(); |
| 52 fBatch.fViewMatrix = viewMatrix; | 54 fBatch.fViewMatrix = viewMatrix; |
| 53 fGeoData.push_back(geometry); | 55 fGeoData.push_back(geometry); |
| 54 | 56 |
| 55 // If we have miterstroke then we inset devOutside and outset devOutside
Assist, so we need | 57 // If we have miterstroke then we inset devOutside and outset devOutside
Assist, so we need |
| 56 // the join for proper bounds | 58 // the join for proper bounds |
| 57 fBounds = geometry.fDevOutside; | 59 fBounds = geometry.fDevOutside; |
| 58 fBounds.join(geometry.fDevOutsideAssist); | 60 fBounds.join(geometry.fDevOutsideAssist); |
| 59 } | 61 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 bool fMiterStroke; | 103 bool fMiterStroke; |
| 102 bool fCanTweakAlphaForCoverage; | 104 bool fCanTweakAlphaForCoverage; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 BatchTracker fBatch; | 107 BatchTracker fBatch; |
| 106 SkSTArray<1, Geometry, true> fGeoData; | 108 SkSTArray<1, Geometry, true> fGeoData; |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 | 111 |
| 110 #endif | 112 #endif |
| OLD | NEW |