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

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

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch 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/batches/GrAAFillRectBatch.h ('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 "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * 55 *
56 * GrDefaultGeoProcFactory::LocalCoords::Type LocalCoordsType() 56 * GrDefaultGeoProcFactory::LocalCoords::Type LocalCoordsType()
57 * 57 *
58 * bool StrideCheck(size_t vertexStride, bool canTweakAlphaForCoverage, 58 * bool StrideCheck(size_t vertexStride, bool canTweakAlphaForCoverage,
59 * bool usesLocalCoords) 59 * bool usesLocalCoords)
60 * 60 *
61 * void FillInAttributes(intptr_t startVertex, size_t vertexStride, 61 * void FillInAttributes(intptr_t startVertex, size_t vertexStride,
62 * SkPoint* fan0Position, const Geometry&) 62 * SkPoint* fan0Position, const Geometry&)
63 */ 63 */
64 template <typename Base> 64 template <typename Base>
65 class AAFillRectBatch : public GrBatch { 65 class AAFillRectBatch : public GrVertexBatch {
66 public: 66 public:
67 typedef typename Base::Geometry Geometry; 67 typedef typename Base::Geometry Geometry;
68 68
69 static AAFillRectBatch* Create() { 69 static AAFillRectBatch* Create() {
70 return SkNEW(AAFillRectBatch); 70 return SkNEW(AAFillRectBatch);
71 } 71 }
72 72
73 const char* name() const override { return "AAFillRectBatch"; } 73 const char* name() const override { return "AAFillRectBatch"; }
74 74
75 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 75 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 GrColor color() const { return fBatch.fColor; } 160 GrColor color() const { return fBatch.fColor; }
161 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } 161 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
162 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } 162 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; }
163 bool colorIgnored() const { return fBatch.fColorIgnored; } 163 bool colorIgnored() const { return fBatch.fColorIgnored; }
164 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } 164 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
165 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } 165 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
166 166
167 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 167 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
168 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipel ine(), t->bounds(), 168 AAFillRectBatch* that = t->cast<AAFillRectBatch>();
169 caps)) { 169 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
170 that->bounds(), caps)) {
170 return false; 171 return false;
171 } 172 }
172 173
173 AAFillRectBatch* that = t->cast<AAFillRectBatch>();
174 if (!Base::CanCombineLocalCoords(this->viewMatrix(), that->viewMatrix(), 174 if (!Base::CanCombineLocalCoords(this->viewMatrix(), that->viewMatrix(),
175 this->usesLocalCoords())) { 175 this->usesLocalCoords())) {
176 return false; 176 return false;
177 } 177 }
178 178
179 if (this->color() != that->color()) { 179 if (this->color() != that->color()) {
180 fBatch.fColor = GrColor_ILLEGAL; 180 fBatch.fColor = GrColor_ILLEGAL;
181 } 181 }
182 182
183 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to 183 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 SkPoint* fan0Loc = reinterpret_cast<SkPoint*>(vertices + vertexStride - sizeof(SkPoint)); 392 SkPoint* fan0Loc = reinterpret_cast<SkPoint*>(vertices + vertexStride - sizeof(SkPoint));
393 localCoordMatrix.mapPointsWithStride(fan0Loc, fan0Pos, vertexStride, 8); 393 localCoordMatrix.mapPointsWithStride(fan0Loc, fan0Pos, vertexStride, 8);
394 } 394 }
395 }; 395 };
396 396
397 typedef AAFillRectBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocalM atrix; 397 typedef AAFillRectBatch<AAFillRectBatchNoLocalMatrixImp> AAFillRectBatchNoLocalM atrix;
398 typedef AAFillRectBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatri x; 398 typedef AAFillRectBatch<AAFillRectBatchLocalMatrixImp> AAFillRectBatchLocalMatri x;
399 399
400 namespace GrAAFillRectBatch { 400 namespace GrAAFillRectBatch {
401 401
402 GrBatch* Create(GrColor color, 402 GrDrawBatch* Create(GrColor color,
403 const SkMatrix& viewMatrix, 403 const SkMatrix& viewMatrix,
404 const SkRect& rect, 404 const SkRect& rect,
405 const SkRect& devRect) { 405 const SkRect& devRect) {
406 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ; 406 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ;
407 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry(); 407 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
408 geo.fColor = color; 408 geo.fColor = color;
409 geo.fViewMatrix = viewMatrix; 409 geo.fViewMatrix = viewMatrix;
410 geo.fDevRect = devRect; 410 geo.fDevRect = devRect;
411 batch->init(); 411 batch->init();
412 return batch; 412 return batch;
413 } 413 }
414 414
415 GrBatch* Create(GrColor color, 415 GrDrawBatch* Create(GrColor color,
416 const SkMatrix& viewMatrix, 416 const SkMatrix& viewMatrix,
417 const SkMatrix& localMatrix, 417 const SkMatrix& localMatrix,
418 const SkRect& rect, 418 const SkRect& rect,
419 const SkRect& devRect) { 419 const SkRect& devRect) {
420 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create(); 420 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
421 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry(); 421 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
422 geo.fColor = color; 422 geo.fColor = color;
423 geo.fViewMatrix = viewMatrix; 423 geo.fViewMatrix = viewMatrix;
424 geo.fLocalMatrix = localMatrix; 424 geo.fLocalMatrix = localMatrix;
425 geo.fDevRect = devRect; 425 geo.fDevRect = devRect;
426 batch->init(); 426 batch->init();
427 return batch; 427 return batch;
428 } 428 }
429 429
430 }; 430 };
431 431
432 //////////////////////////////////////////////////////////////////////////////// /////////////////// 432 //////////////////////////////////////////////////////////////////////////////// ///////////////////
433 433
434 #ifdef GR_TEST_UTILS 434 #ifdef GR_TEST_UTILS
435 435
436 #include "GrBatchTest.h" 436 #include "GrBatchTest.h"
437 437
438 BATCH_TEST_DEFINE(AAFillRectBatch) { 438 DRAW_BATCH_TEST_DEFINE(AAFillRectBatch) {
439 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ; 439 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ;
440 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry(); 440 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
441 geo.fColor = GrRandomColor(random); 441 geo.fColor = GrRandomColor(random);
442 geo.fViewMatrix = GrTest::TestMatrix(random); 442 geo.fViewMatrix = GrTest::TestMatrix(random);
443 geo.fDevRect = GrTest::TestRect(random); 443 geo.fDevRect = GrTest::TestRect(random);
444 batch->init(); 444 batch->init();
445 return batch; 445 return batch;
446 } 446 }
447 447
448 BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 448 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
449 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create(); 449 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
450 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry(); 450 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
451 geo.fColor = GrRandomColor(random); 451 geo.fColor = GrRandomColor(random);
452 geo.fViewMatrix = GrTest::TestMatrix(random); 452 geo.fViewMatrix = GrTest::TestMatrix(random);
453 geo.fLocalMatrix = GrTest::TestMatrix(random); 453 geo.fLocalMatrix = GrTest::TestMatrix(random);
454 geo.fDevRect = GrTest::TestRect(random); 454 geo.fDevRect = GrTest::TestRect(random);
455 batch->init(); 455 batch->init();
456 return batch; 456 return batch;
457 } 457 }
458 458
459 #endif 459 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAFillRectBatch.h ('k') | src/gpu/batches/GrAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698