| 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 GrTInstanceBatch_DEFINED | 8 #ifndef GrTInstanceBatch_DEFINED |
| 9 #define GrTInstanceBatch_DEFINED | 9 #define GrTInstanceBatch_DEFINED |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void init() { | 70 void init() { |
| 71 const Geometry& geo = fGeoData[0]; | 71 const Geometry& geo = fGeoData[0]; |
| 72 Impl::SetBounds(geo, &fBounds); | 72 Impl::SetBounds(geo, &fBounds); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void updateBoundsAfterAppend() { | 75 void updateBoundsAfterAppend() { |
| 76 const Geometry& geo = fGeoData.back(); | 76 const Geometry& geo = fGeoData.back(); |
| 77 Impl::UpdateBoundsAfterAppend(geo, &fBounds); | 77 Impl::UpdateBoundsAfterAppend(geo, &fBounds); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool appendIfPossible(const Geometry& geo) { |
| 81 const Geometry& mine = fGeoData.back(); |
| 82 if (Impl::CanCombine(mine, geo, fOpts)) { |
| 83 fGeoData.push_back(geo); |
| 84 this->updateBoundsAfterAppend(); |
| 85 return true; |
| 86 } else { |
| 87 return false; |
| 88 } |
| 89 |
| 90 } |
| 91 |
| 80 private: | 92 private: |
| 81 GrTInstanceBatch() : INHERITED(ClassID()) {} | 93 GrTInstanceBatch() : INHERITED(ClassID()) {} |
| 82 | 94 |
| 83 void onPrepareDraws(Target* target) override { | 95 void onPrepareDraws(Target* target) override { |
| 84 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), fOpts)); | 96 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), fOpts)); |
| 85 if (!gp) { | 97 if (!gp) { |
| 86 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 98 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
| 87 return; | 99 return; |
| 88 } | 100 } |
| 89 | 101 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return true; | 147 return true; |
| 136 } | 148 } |
| 137 | 149 |
| 138 GrPipelineOptimizations fOpts; | 150 GrPipelineOptimizations fOpts; |
| 139 SkSTArray<1, Geometry, true> fGeoData; | 151 SkSTArray<1, Geometry, true> fGeoData; |
| 140 | 152 |
| 141 typedef GrVertexBatch INHERITED; | 153 typedef GrVertexBatch INHERITED; |
| 142 }; | 154 }; |
| 143 | 155 |
| 144 #endif | 156 #endif |
| OLD | NEW |