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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 init.getOverrideColorIfSet(&this->geoData(0)->fColor); | 40 init.getOverrideColorIfSet(&this->geoData(0)->fColor); |
41 | 41 |
42 // setup batch properties | 42 // setup batch properties |
43 fBatch.fColorIgnored = !init.readsColor(); | 43 fBatch.fColorIgnored = !init.readsColor(); |
44 fBatch.fColor = this->geoData(0)->fColor; | 44 fBatch.fColor = this->geoData(0)->fColor; |
45 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 45 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
46 fBatch.fCoverageIgnored = !init.readsCoverage(); | 46 fBatch.fCoverageIgnored = !init.readsCoverage(); |
47 } | 47 } |
48 | 48 |
49 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 49 void generateGeometry(GrBatchTarget* batchTarget) override { |
50 batchTarget->initDraw(fGeometryProcessor, pipeline); | 50 batchTarget->initDraw(fGeometryProcessor, this->pipeline()); |
51 | 51 |
52 this->onGenerateGeometry(batchTarget, pipeline); | 52 this->onGenerateGeometry(batchTarget); |
53 } | 53 } |
54 | 54 |
55 protected: | 55 protected: |
56 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { | 56 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { |
57 fGeometryProcessor.reset(SkRef(gp)); | 57 fGeometryProcessor.reset(SkRef(gp)); |
58 | 58 |
59 this->setBounds(bounds); | 59 this->setBounds(bounds); |
60 } | 60 } |
61 | 61 |
62 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } | 62 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } |
63 | 63 |
64 private: | 64 private: |
65 virtual Geometry* geoData(int index) = 0; | 65 virtual Geometry* geoData(int index) = 0; |
66 virtual const Geometry* geoData(int index) const = 0; | 66 virtual const Geometry* geoData(int index) const = 0; |
67 | 67 |
68 bool onCombineIfPossible(GrBatch* t) override { | 68 bool onCombineIfPossible(GrBatch* t) override { |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline
* pipeline) = 0; | 72 virtual void onGenerateGeometry(GrBatchTarget* batchTarget) = 0; |
73 | 73 |
74 struct BatchTracker { | 74 struct BatchTracker { |
75 GrColor fColor; | 75 GrColor fColor; |
76 bool fUsesLocalCoords; | 76 bool fUsesLocalCoords; |
77 bool fColorIgnored; | 77 bool fColorIgnored; |
78 bool fCoverageIgnored; | 78 bool fCoverageIgnored; |
79 }; | 79 }; |
80 | 80 |
81 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; | 81 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
82 BatchTracker fBatch; | 82 BatchTracker fBatch; |
83 }; | 83 }; |
84 | 84 |
85 #endif | 85 #endif |
OLD | NEW |