Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: src/gpu/batches/GrAAFillRectBatch.cpp

Issue 1301663002: Privatize GrBatch subclass overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@drawsonvb
Patch Set: more Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "GrAAFillRectBatch.h" 8 #include "GrAAFillRectBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 90 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
91 91
92 // setup batch properties 92 // setup batch properties
93 fBatch.fColorIgnored = !opt.readsColor(); 93 fBatch.fColorIgnored = !opt.readsColor();
94 fBatch.fColor = fGeoData[0].fColor; 94 fBatch.fColor = fGeoData[0].fColor;
95 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 95 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
96 fBatch.fCoverageIgnored = !opt.readsCoverage(); 96 fBatch.fCoverageIgnored = !opt.readsCoverage();
97 fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage(); 97 fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage();
98 } 98 }
99 99
100 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
101
102 // to avoid even the initial copy of the struct, we have a getter for the fi rst item which
103 // is used to seed the batch with its initial geometry. After seeding, the client should call
104 // init() so the Batch can initialize itself
105 Geometry* geometry() { return &fGeoData[0]; }
106 void init() {
107 const Geometry& geo = fGeoData[0];
108 this->setBounds(geo.fDevRect);
109 }
110
111 private:
112 AAFillRectBatch() {
113 this->initClassID<AAFillRectBatch<Base>>();
114
115 // Push back an initial geometry
116 fGeoData.push_back();
117 }
118
119 GrColor color() const { return fBatch.fColor; }
120 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
121 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; }
122 bool colorIgnored() const { return fBatch.fColorIgnored; }
123 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
124 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
125
100 void onPrepareDraws(Target* target) override { 126 void onPrepareDraws(Target* target) override {
101 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 127 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
102 128
103 SkAutoTUnref<const GrGeometryProcessor> gp(CreateFillRectGP(canTweakAlph aForCoverage, 129 SkAutoTUnref<const GrGeometryProcessor> gp(CreateFillRectGP(canTweakAlph aForCoverage,
104 this->viewMa trix(), 130 this->viewMa trix(),
105 this->usesLo calCoords(), 131 this->usesLo calCoords(),
106 Base::LocalC oordsType(), 132 Base::LocalC oordsType(),
107 this->covera geIgnored())); 133 this->covera geIgnored()));
108 if (!gp) { 134 if (!gp) {
109 SkDebugf("Couldn't create GrGeometryProcessor\n"); 135 SkDebugf("Couldn't create GrGeometryProcessor\n");
(...skipping 20 matching lines...) Expand all
130 for (int i = 0; i < instanceCount; i++) { 156 for (int i = 0; i < instanceCount; i++) {
131 this->generateAAFillRectGeometry(vertices, 157 this->generateAAFillRectGeometry(vertices,
132 i * kVertsPerAAFillRect * vertexStr ide, 158 i * kVertsPerAAFillRect * vertexStr ide,
133 vertexStride, 159 vertexStride,
134 fGeoData[i], 160 fGeoData[i],
135 canTweakAlphaForCoverage); 161 canTweakAlphaForCoverage);
136 } 162 }
137 helper.recordDraw(target); 163 helper.recordDraw(target);
138 } 164 }
139 165
140 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
141
142 // to avoid even the initial copy of the struct, we have a getter for the fi rst item which
143 // is used to seed the batch with its initial geometry. After seeding, the client should call
144 // init() so the Batch can initialize itself
145 Geometry* geometry() { return &fGeoData[0]; }
146 void init() {
147 const Geometry& geo = fGeoData[0];
148 this->setBounds(geo.fDevRect);
149 }
150
151
152 private:
153 AAFillRectBatch() {
154 this->initClassID<AAFillRectBatch<Base>>();
155
156 // Push back an initial geometry
157 fGeoData.push_back();
158 }
159
160 GrColor color() const { return fBatch.fColor; }
161 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
162 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; }
163 bool colorIgnored() const { return fBatch.fColorIgnored; }
164 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
165 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
166
167 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 166 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
168 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); 167 AAFillRectBatch* that = t->cast<AAFillRectBatch>();
169 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 168 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
170 that->bounds(), caps)) { 169 that->bounds(), caps)) {
171 return false; 170 return false;
172 } 171 }
173 172
174 if (!Base::CanCombineLocalCoords(this->viewMatrix(), that->viewMatrix(), 173 if (!Base::CanCombineLocalCoords(this->viewMatrix(), that->viewMatrix(),
175 this->usesLocalCoords())) { 174 this->usesLocalCoords())) {
176 return false; 175 return false;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 453 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
455 GrColor color = GrRandomColor(random); 454 GrColor color = GrRandomColor(random);
456 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 455 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
457 SkMatrix localMatrix = GrTest::TestMatrix(random); 456 SkMatrix localMatrix = GrTest::TestMatrix(random);
458 SkRect rect = GrTest::TestRect(random); 457 SkRect rect = GrTest::TestRect(random);
459 SkRect devRect = GrTest::TestRect(random); 458 SkRect devRect = GrTest::TestRect(random);
460 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct); 459 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct);
461 } 460 }
462 461
463 #endif 462 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698