| 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 GrTestBatch_DEFINED | 8 #ifndef GrTestBatch_DEFINED |
| 9 #define GrTestBatch_DEFINED | 9 #define GrTestBatch_DEFINED |
| 10 | 10 |
| 11 #include "GrBatch.h" | 11 #include "GrBatch.h" |
| 12 | 12 |
| 13 /* | 13 /* |
| 14 * A simple batch only for testing purposes which actually doesn't batch at all,
but can fit into | 14 * A simple batch only for testing purposes which actually doesn't batch at all,
but can fit into |
| 15 * the batch pipeline and generate arbitrary geometry | 15 * the batch pipeline and generate arbitrary geometry |
| 16 */ | 16 */ |
| 17 class GrTestBatch : public GrBatch { | 17 class GrTestBatch : public GrBatch { |
| 18 public: | 18 public: |
| 19 struct Geometry { | 19 struct Geometry { |
| 20 GrColor fColor; | 20 GrColor fColor; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 virtual const char* name() const override = 0; | 23 virtual const char* name() const override = 0; |
| 24 | 24 |
| 25 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 25 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 26 // When this is called on a batch, there is only one geometry bundle | 26 // When this is called on a batch, there is only one geometry bundle |
| 27 if (fHasVertexColor) { | 27 if (fGeometryProcessor->hasVertexColor()) { |
| 28 out->setUnknownFourComponents(); | 28 out->setUnknownFourComponents(); |
| 29 } else { | 29 } else { |
| 30 out->setKnownFourComponents(fGeometryProcessor->color()); | 30 out->setKnownFourComponents(fGeometryProcessor->color()); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 34 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 35 out->setUnknownSingleComponent(); | 35 out->setUnknownSingleComponent(); |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 init.fColorIgnored = fBatch.fColorIgnored; | 60 init.fColorIgnored = fBatch.fColorIgnored; |
| 61 init.fOverrideColor = GrColor_ILLEGAL; | 61 init.fOverrideColor = GrColor_ILLEGAL; |
| 62 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 62 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 63 init.fUsesLocalCoords = fBatch.fUsesLocalCoords; | 63 init.fUsesLocalCoords = fBatch.fUsesLocalCoords; |
| 64 fGeometryProcessor->initBatchTracker(batchTarget->currentBatchTracker(),
init); | 64 fGeometryProcessor->initBatchTracker(batchTarget->currentBatchTracker(),
init); |
| 65 | 65 |
| 66 this->onGenerateGeometry(batchTarget, pipeline); | 66 this->onGenerateGeometry(batchTarget, pipeline); |
| 67 } | 67 } |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 GrTestBatch(const GrGeometryProcessor* gp, bool hasVertexColor = false) | 70 GrTestBatch(const GrGeometryProcessor* gp) { |
| 71 : fHasVertexColor(hasVertexColor) { | |
| 72 fGeometryProcessor.reset(SkRef(gp)); | 71 fGeometryProcessor.reset(SkRef(gp)); |
| 73 } | 72 } |
| 74 | 73 |
| 75 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } | 74 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 virtual Geometry* geoData(int index) = 0; | 77 virtual Geometry* geoData(int index) = 0; |
| 79 | 78 |
| 80 bool onCombineIfPossible(GrBatch* t) override { | 79 bool onCombineIfPossible(GrBatch* t) override { |
| 81 return false; | 80 return false; |
| 82 } | 81 } |
| 83 | 82 |
| 84 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline
* pipeline) = 0; | 83 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline
* pipeline) = 0; |
| 85 | 84 |
| 86 struct BatchTracker { | 85 struct BatchTracker { |
| 87 GrColor fColor; | 86 GrColor fColor; |
| 88 bool fUsesLocalCoords; | 87 bool fUsesLocalCoords; |
| 89 bool fColorIgnored; | 88 bool fColorIgnored; |
| 90 bool fCoverageIgnored; | 89 bool fCoverageIgnored; |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 bool fHasVertexColor; | |
| 94 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; | 92 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
| 95 BatchTracker fBatch; | 93 BatchTracker fBatch; |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 #endif | 96 #endif |
| OLD | NEW |