| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 SkString dumpInfo() const override { | 53 SkString dumpInfo() const override { |
| 54 SkString str; | 54 SkString str; |
| 55 for (int i = 0; i < fGeoData.count(); ++i) { | 55 for (int i = 0; i < fGeoData.count(); ++i) { |
| 56 str.append(Impl::DumpInfo(fGeoData[i], i)); | 56 str.append(Impl::DumpInfo(fGeoData[i], i)); |
| 57 } | 57 } |
| 58 str.append(INHERITED::dumpInfo()); | 58 str.append(INHERITED::dumpInfo()); |
| 59 return str; | 59 return str; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void computePipelineOptimizations(GrInitInvariantOutput* color, | 62 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 63 GrInitInvariantOutput* coverage, | 63 GrInitInvariantOutput* coverage, |
| 64 GrBatchToXPOverrides* overrides) const ove
rride { | 64 GrBatchToXPOverrides* overrides) const ove
rride { |
| 65 // When this is called on a batch, there is only one geometry bundle | 65 // When this is called on a batch, there is only one geometry bundle |
| 66 color->setKnownFourComponents(fGeoData[0].fColor); | 66 color->setKnownFourComponents(fGeoData[0].fColor); |
| 67 Impl::InitInvariantOutputCoverage(coverage); | 67 Impl::InitInvariantOutputCoverage(coverage); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 70 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 71 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 71 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 72 fOverrides = overrides; | 72 fOverrides = overrides; |
| 73 } | 73 } |
| 74 | 74 |
| 75 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 75 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 76 | 76 |
| 77 // After seeding, the client should call init() so the Batch can initialize
itself | 77 // After seeding, the client should call init() so the Batch can initialize
itself |
| 78 void init() { | 78 void init() { |
| 79 const Geometry& geo = fGeoData[0]; | 79 const Geometry& geo = fGeoData[0]; |
| 80 Impl::SetBounds(geo, &fBounds); | 80 Impl::SetBounds(geo, &fBounds); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void updateBoundsAfterAppend() { | 83 void updateBoundsAfterAppend() { |
| 84 const Geometry& geo = fGeoData.back(); | 84 const Geometry& geo = fGeoData.back(); |
| 85 Impl::UpdateBoundsAfterAppend(geo, &fBounds); | 85 Impl::UpdateBoundsAfterAppend(geo, &fBounds); |
| 86 } | 86 } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 GrTInstanceBatch() : INHERITED(ClassID()) {} | 89 GrTInstanceBatch() : INHERITED(ClassID()) {} |
| 90 | 90 |
| 91 void onPrepareDraws(Target* target) const override { | 91 void onPrepareDraws(Target* target) const override { |
| 92 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), | 92 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), |
| 93 fOverrides)); | 93 fOverrides)); |
| 94 if (!gp) { | 94 if (!gp) { |
| 95 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 95 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| 99 target->initDraw(gp); | 99 target->initDraw(gp); |
| 100 | 100 |
| 101 size_t vertexStride = gp->getVertexStride(); | 101 size_t vertexStride = gp->getVertexStride(); |
| 102 int instanceCount = fGeoData.count(); | 102 int instanceCount = fGeoData.count(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 GrXPOverridesForBatch fOverrides; | 147 GrXPOverridesForBatch fOverrides; |
| 148 SkSTArray<1, Geometry, true> fGeoData; | 148 SkSTArray<1, Geometry, true> fGeoData; |
| 149 | 149 |
| 150 typedef GrVertexBatch INHERITED; | 150 typedef GrVertexBatch INHERITED; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 #endif | 153 #endif |
| OLD | NEW |