Chromium Code Reviews| 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 #include "GrVertexBuffer.h" | 12 #include "GrVertexBuffer.h" |
| 13 | 13 |
| 14 /* | 14 /* |
| 15 * A simple batch only for testing purposes which actually doesn't batch at all, but can fit into | 15 * A simple batch only for testing purposes which actually doesn't batch at all, but can fit into |
| 16 * the batch pipeline and generate arbitrary geometry | 16 * the batch pipeline and generate arbitrary geometry |
| 17 */ | 17 */ |
| 18 class GrTestBatch : public GrBatch { | 18 class GrTestBatch : public GrBatch { |
| 19 public: | 19 public: |
| 20 struct Geometry { | 20 struct Geometry { |
| 21 GrColor fColor; | 21 GrColor fColor; |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 virtual const char* name() const override = 0; | 24 virtual const char* name() const override = 0; |
| 25 | 25 |
| 26 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 26 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 27 // When this is called on a batch, there is only one geometry bundle | 27 // When this is called on a batch, there is only one geometry bundle |
|
robertphillips
2015/05/13 20:33:50
Use a getColor accessor ?
| |
| 28 out->setKnownFourComponents(fGeometryProcessor->color()); | 28 out->setKnownFourComponents(this->geoData(0)->fColor); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 31 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 32 out->setUnknownSingleComponent(); | 32 out->setUnknownSingleComponent(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void initBatchTracker(const GrPipelineInfo& init) override { | 35 void initBatchTracker(const GrPipelineInfo& init) override { |
| 36 // Handle any color overrides | 36 // Handle any color overrides |
| 37 if (init.fColorIgnored) { | 37 if (init.fColorIgnored) { |
| 38 this->geoData(0)->fColor = GrColor_ILLEGAL; | 38 this->geoData(0)->fColor = GrColor_ILLEGAL; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 67 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { | 67 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { |
| 68 fGeometryProcessor.reset(SkRef(gp)); | 68 fGeometryProcessor.reset(SkRef(gp)); |
| 69 | 69 |
| 70 this->setBounds(bounds); | 70 this->setBounds(bounds); |
| 71 } | 71 } |
| 72 | 72 |
| 73 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce ssor; } | 73 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce ssor; } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 virtual Geometry* geoData(int index) = 0; | 76 virtual Geometry* geoData(int index) = 0; |
| 77 virtual const Geometry* geoData(int index) const = 0; | |
| 77 | 78 |
| 78 bool onCombineIfPossible(GrBatch* t) override { | 79 bool onCombineIfPossible(GrBatch* t) override { |
| 79 return false; | 80 return false; |
| 80 } | 81 } |
| 81 | 82 |
| 82 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline * pipeline) = 0; | 83 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline * pipeline) = 0; |
| 83 | 84 |
| 84 struct BatchTracker { | 85 struct BatchTracker { |
| 85 GrColor fColor; | 86 GrColor fColor; |
| 86 bool fUsesLocalCoords; | 87 bool fUsesLocalCoords; |
| 87 bool fColorIgnored; | 88 bool fColorIgnored; |
| 88 bool fCoverageIgnored; | 89 bool fCoverageIgnored; |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; | 92 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
| 92 BatchTracker fBatch; | 93 BatchTracker fBatch; |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 #endif | 96 #endif |
| OLD | NEW |