| 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 |
| 28 if (fGeometryProcessor->hasVertexColor()) { | 28 out->setKnownFourComponents(fGeometryProcessor->color()); |
| 29 out->setUnknownFourComponents(); | |
| 30 } else { | |
| 31 out->setKnownFourComponents(fGeometryProcessor->color()); | |
| 32 } | |
| 33 } | 29 } |
| 34 | 30 |
| 35 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 31 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 36 out->setUnknownSingleComponent(); | 32 out->setUnknownSingleComponent(); |
| 37 } | 33 } |
| 38 | 34 |
| 39 void initBatchTracker(const GrPipelineInfo& init) override { | 35 void initBatchTracker(const GrPipelineInfo& init) override { |
| 40 // Handle any color overrides | 36 // Handle any color overrides |
| 41 if (init.fColorIgnored) { | 37 if (init.fColorIgnored) { |
| 42 this->geoData(0)->fColor = GrColor_ILLEGAL; | 38 this->geoData(0)->fColor = GrColor_ILLEGAL; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool fUsesLocalCoords; | 86 bool fUsesLocalCoords; |
| 91 bool fColorIgnored; | 87 bool fColorIgnored; |
| 92 bool fCoverageIgnored; | 88 bool fCoverageIgnored; |
| 93 }; | 89 }; |
| 94 | 90 |
| 95 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; | 91 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
| 96 BatchTracker fBatch; | 92 BatchTracker fBatch; |
| 97 }; | 93 }; |
| 98 | 94 |
| 99 #endif | 95 #endif |
| OLD | NEW |