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

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

Issue 1301203002: Revert "fill rect batch refactor into separate batches" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | src/gpu/batches/GrBWFillRectBatch.cpp » ('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 "GrColor.h" 10 #include "GrColor.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 // Common functions 184 // Common functions
185 class AAFillRectBatchBase { 185 class AAFillRectBatchBase {
186 public: 186 public:
187 static const int kVertsPerInstance = kVertsPerAAFillRect; 187 static const int kVertsPerInstance = kVertsPerAAFillRect;
188 static const int kIndicesPerInstance = kIndicesPerAAFillRect; 188 static const int kIndicesPerInstance = kIndicesPerAAFillRect;
189 189
190 static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* rp) { 190 inline static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* rp) {
191 return get_index_buffer(rp); 191 return get_index_buffer(rp);
192 } 192 }
193
194 template <class Geometry>
195 static void SetBounds(const Geometry& geo, SkRect* outBounds) {
196 *outBounds = geo.fDevRect;
197 }
198 }; 193 };
199 194
200 class AAFillRectBatchNoLocalMatrixImp : public AAFillRectBatchBase { 195 class AAFillRectBatchNoLocalMatrixImp : public AAFillRectBatchBase {
201 public: 196 public:
202 struct Geometry { 197 struct Geometry {
203 SkMatrix fViewMatrix; 198 SkMatrix fViewMatrix;
204 SkRect fRect; 199 SkRect fRect;
205 SkRect fDevRect; 200 SkRect fDevRect;
206 GrColor fColor; 201 GrColor fColor;
207 }; 202 };
208 203
209 static const char* Name() { return "AAFillRectBatchNoLocalMatrix"; } 204 inline static const char* Name() { return "AAFillRectBatchNoLocalMatrix"; }
210 205
211 static bool CanCombine(const Geometry& mine, const Geometry& theirs, 206 inline static bool CanCombine(const Geometry& mine, const Geometry& theirs,
212 const GrPipelineOptimizations& opts) { 207 const GrPipelineOptimizations& opts) {
213 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses 208 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses
214 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix 209 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix
215 // using vertex attributes in these cases, but haven't investigated that 210 // using vertex attributes in these cases, but haven't investigated that
216 return !opts.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs. fViewMatrix); 211 return !opts.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs. fViewMatrix);
217 } 212 }
218 213
219 static const GrGeometryProcessor* CreateGP(const Geometry& geo, 214 inline static const GrGeometryProcessor* CreateGP(const Geometry& geo,
220 const GrPipelineOptimizations& op ts) { 215 const GrPipelineOptimizati ons& opts) {
221 const GrGeometryProcessor* gp = 216 const GrGeometryProcessor* gp =
222 create_fill_rect_gp(geo.fViewMatrix, opts, 217 create_fill_rect_gp(geo.fViewMatrix, opts,
223 GrDefaultGeoProcFactory::LocalCoords::kUsePo sition_Type); 218 GrDefaultGeoProcFactory::LocalCoords::kUsePo sition_Type);
224 219
225 SkASSERT(opts.canTweakAlphaForCoverage() ? 220 SkASSERT(opts.canTweakAlphaForCoverage() ?
226 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::Positi onColorAttr) : 221 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::Positi onColorAttr) :
227 gp->getVertexStride() == 222 gp->getVertexStride() ==
228 sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAt tr)); 223 sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAt tr));
229 return gp; 224 return gp;
230 } 225 }
231 226
232 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry & geo, 227 inline static void Tesselate(intptr_t vertices, size_t vertexStride, const G eometry& geo,
233 const GrPipelineOptimizations& opts) { 228 const GrPipelineOptimizations& opts) {
234 generate_aa_fill_rect_geometry(vertices, vertexStride, 229 generate_aa_fill_rect_geometry(vertices, vertexStride,
235 geo.fColor, geo.fViewMatrix, geo.fRect, g eo.fDevRect, opts, 230 geo.fColor, geo.fViewMatrix, geo.fRect, g eo.fDevRect, opts,
236 NULL); 231 NULL);
237 } 232 }
238 }; 233 };
239 234
240 class AAFillRectBatchLocalMatrixImp : public AAFillRectBatchBase { 235 class AAFillRectBatchLocalMatrixImp : public AAFillRectBatchBase {
241 public: 236 public:
242 struct Geometry { 237 struct Geometry {
243 SkMatrix fViewMatrix; 238 SkMatrix fViewMatrix;
244 SkMatrix fLocalMatrix; 239 SkMatrix fLocalMatrix;
245 SkRect fRect; 240 SkRect fRect;
246 SkRect fDevRect; 241 SkRect fDevRect;
247 GrColor fColor; 242 GrColor fColor;
248 }; 243 };
249 244
250 static const char* Name() { return "AAFillRectBatchLocalMatrix"; } 245 inline static const char* Name() { return "AAFillRectBatchLocalMatrix"; }
251 246
252 static bool CanCombine(const Geometry& mine, const Geometry& theirs, 247 inline static bool CanCombine(const Geometry& mine, const Geometry& theirs,
253 const GrPipelineOptimizations&) { 248 const GrPipelineOptimizations&) {
254 return true; 249 return true;
255 } 250 }
256 251
257 static const GrGeometryProcessor* CreateGP(const Geometry& geo, 252 inline static const GrGeometryProcessor* CreateGP(const Geometry& geo,
258 const GrPipelineOptimizations& op ts) { 253 const GrPipelineOptimizati ons& opts) {
259 const GrGeometryProcessor* gp = 254 const GrGeometryProcessor* gp =
260 create_fill_rect_gp(geo.fViewMatrix, opts, 255 create_fill_rect_gp(geo.fViewMatrix, opts,
261 GrDefaultGeoProcFactory::LocalCoords::kHasEx plicit_Type); 256 GrDefaultGeoProcFactory::LocalCoords::kHasEx plicit_Type);
262 257
263 SkASSERT(opts.canTweakAlphaForCoverage() ? 258 SkASSERT(opts.canTweakAlphaForCoverage() ?
264 gp->getVertexStride() == 259 gp->getVertexStride() ==
265 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Attr) : 260 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Attr) :
266 gp->getVertexStride() == 261 gp->getVertexStride() ==
267 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Coverage)); 262 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord Coverage));
268 return gp; 263 return gp;
269 } 264 }
270 265
271 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry & geo, 266 inline static void Tesselate(intptr_t vertices, size_t vertexStride, const G eometry& geo,
272 const GrPipelineOptimizations& opts) { 267 const GrPipelineOptimizations& opts) {
273 generate_aa_fill_rect_geometry(vertices, vertexStride, 268 generate_aa_fill_rect_geometry(vertices, vertexStride,
274 geo.fColor, geo.fViewMatrix, geo.fRect, g eo.fDevRect, opts, 269 geo.fColor, geo.fViewMatrix, geo.fRect, g eo.fDevRect, opts,
275 &geo.fLocalMatrix); 270 &geo.fLocalMatrix);
276 } 271 }
277 }; 272 };
278 273
279 typedef GrTInstanceBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocal Matrix; 274 typedef GrTInstanceBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocal Matrix;
280 typedef GrTInstanceBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatr ix; 275 typedef GrTInstanceBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatr ix;
281 276
282 namespace GrAAFillRectBatch { 277 namespace GrAAFillRectBatch {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 325 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
331 GrColor color = GrRandomColor(random); 326 GrColor color = GrRandomColor(random);
332 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 327 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
333 SkMatrix localMatrix = GrTest::TestMatrix(random); 328 SkMatrix localMatrix = GrTest::TestMatrix(random);
334 SkRect rect = GrTest::TestRect(random); 329 SkRect rect = GrTest::TestRect(random);
335 SkRect devRect = GrTest::TestRect(random); 330 SkRect devRect = GrTest::TestRect(random);
336 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct); 331 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct);
337 } 332 }
338 333
339 #endif 334 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/batches/GrBWFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698