OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 210 } |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 class DefaultPathBatch : public GrBatch { | 214 class DefaultPathBatch : public GrBatch { |
215 public: | 215 public: |
216 struct Geometry { | 216 struct Geometry { |
217 GrColor fColor; | 217 GrColor fColor; |
218 SkPath fPath; | 218 SkPath fPath; |
219 SkScalar fTolerance; | 219 SkScalar fTolerance; |
220 SkDEBUGCODE(SkRect fDevBounds;) | |
221 }; | 220 }; |
222 | 221 |
223 static GrBatch* Create(const Geometry& geometry, uint8_t coverage, const SkM
atrix& viewMatrix, | 222 static GrBatch* Create(const Geometry& geometry, uint8_t coverage, const SkM
atrix& viewMatrix, |
224 bool isHairline) { | 223 bool isHairline, const SkRect& devBounds) { |
225 return SkNEW_ARGS(DefaultPathBatch, (geometry, coverage, viewMatrix, isH
airline)); | 224 return SkNEW_ARGS(DefaultPathBatch, (geometry, coverage, viewMatrix, isH
airline, |
| 225 devBounds)); |
226 } | 226 } |
227 | 227 |
228 const char* name() const override { return "DefaultPathBatch"; } | 228 const char* name() const override { return "DefaultPathBatch"; } |
229 | 229 |
230 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 230 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
231 // When this is called on a batch, there is only one geometry bundle | 231 // When this is called on a batch, there is only one geometry bundle |
232 out->setKnownFourComponents(fGeoData[0].fColor); | 232 out->setKnownFourComponents(fGeoData[0].fColor); |
233 } | 233 } |
234 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 234 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
235 out->setKnownSingleComponent(this->coverage()); | 235 out->setKnownSingleComponent(this->coverage()); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 386 |
387 // put back reserves | 387 // put back reserves |
388 batchTarget->putBackIndices((size_t)(maxIndices - indexOffset)); | 388 batchTarget->putBackIndices((size_t)(maxIndices - indexOffset)); |
389 batchTarget->putBackVertices((size_t)(maxVertices - vertexOffset), (size
_t)vertexStride); | 389 batchTarget->putBackVertices((size_t)(maxVertices - vertexOffset), (size
_t)vertexStride); |
390 } | 390 } |
391 | 391 |
392 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 392 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
393 | 393 |
394 private: | 394 private: |
395 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, | 395 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, |
396 bool isHairline) { | 396 bool isHairline, const SkRect& devBounds) { |
397 this->initClassID<DefaultPathBatch>(); | 397 this->initClassID<DefaultPathBatch>(); |
398 fBatch.fCoverage = coverage; | 398 fBatch.fCoverage = coverage; |
399 fBatch.fIsHairline = isHairline; | 399 fBatch.fIsHairline = isHairline; |
400 fBatch.fViewMatrix = viewMatrix; | 400 fBatch.fViewMatrix = viewMatrix; |
401 fGeoData.push_back(geometry); | 401 fGeoData.push_back(geometry); |
| 402 |
| 403 this->setBounds(devBounds); |
402 } | 404 } |
403 | 405 |
404 bool onCombineIfPossible(GrBatch* t) override { | 406 bool onCombineIfPossible(GrBatch* t) override { |
405 DefaultPathBatch* that = t->cast<DefaultPathBatch>(); | 407 DefaultPathBatch* that = t->cast<DefaultPathBatch>(); |
406 | 408 |
407 if (this->color() != that->color()) { | 409 if (this->color() != that->color()) { |
408 return false; | 410 return false; |
409 } | 411 } |
410 | 412 |
411 if (this->coverage() != that->coverage()) { | 413 if (this->coverage() != that->coverage()) { |
412 return false; | 414 return false; |
413 } | 415 } |
414 | 416 |
415 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 417 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
416 return false; | 418 return false; |
417 } | 419 } |
418 | 420 |
419 if (this->isHairline() != that->isHairline()) { | 421 if (this->isHairline() != that->isHairline()) { |
420 return false; | 422 return false; |
421 } | 423 } |
422 | 424 |
423 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 425 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 426 this->joinBounds(that->bounds()); |
424 return true; | 427 return true; |
425 } | 428 } |
426 | 429 |
427 bool createGeom(void* vertices, | 430 bool createGeom(void* vertices, |
428 size_t vertexOffset, | 431 size_t vertexOffset, |
429 void* indices, | 432 void* indices, |
430 size_t indexOffset, | 433 size_t indexOffset, |
431 int* vertexCnt, | 434 int* vertexCnt, |
432 int* indexCnt, | 435 int* indexCnt, |
433 const SkPath& path, | 436 const SkPath& path, |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 target->drawRect(pipelineBuilder, color, viewM, bounds, NULL, &local
Matrix); | 700 target->drawRect(pipelineBuilder, color, viewM, bounds, NULL, &local
Matrix); |
698 } else { | 701 } else { |
699 if (passCount > 1) { | 702 if (passCount > 1) { |
700 pipelineBuilder->setDisableColorXPFactory(); | 703 pipelineBuilder->setDisableColorXPFactory(); |
701 } | 704 } |
702 | 705 |
703 DefaultPathBatch::Geometry geometry; | 706 DefaultPathBatch::Geometry geometry; |
704 geometry.fColor = color; | 707 geometry.fColor = color; |
705 geometry.fPath = path; | 708 geometry.fPath = path; |
706 geometry.fTolerance = srcSpaceTol; | 709 geometry.fTolerance = srcSpaceTol; |
707 SkDEBUGCODE(geometry.fDevBounds = devBounds;) | |
708 | 710 |
709 SkAutoTUnref<GrBatch> batch(DefaultPathBatch::Create(geometry, newCo
verage, viewMatrix, | 711 SkAutoTUnref<GrBatch> batch(DefaultPathBatch::Create(geometry, newCo
verage, viewMatrix, |
710 isHairline)); | 712 isHairline, dev
Bounds)); |
711 | 713 |
712 target->drawBatch(pipelineBuilder, batch, &devBounds); | 714 target->drawBatch(pipelineBuilder, batch); |
713 } | 715 } |
714 } | 716 } |
715 return true; | 717 return true; |
716 } | 718 } |
717 | 719 |
718 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, | 720 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, |
719 const GrPipelineBuilder* pipelineBuilder
, | 721 const GrPipelineBuilder* pipelineBuilder
, |
720 const SkMatrix& viewMatrix, | 722 const SkMatrix& viewMatrix, |
721 const SkPath& path, | 723 const SkPath& path, |
722 const GrStrokeInfo& stroke, | 724 const GrStrokeInfo& stroke, |
(...skipping 22 matching lines...) Expand all Loading... |
745 | 747 |
746 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, | 748 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
747 GrPipelineBuilder* pipelineBuilder, | 749 GrPipelineBuilder* pipelineBuilder, |
748 const SkMatrix& viewMatrix, | 750 const SkMatrix& viewMatrix, |
749 const SkPath& path, | 751 const SkPath& path, |
750 const GrStrokeInfo& stroke) { | 752 const GrStrokeInfo& stroke) { |
751 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); | 753 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
752 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); | 754 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
753 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); | 755 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); |
754 } | 756 } |
OLD | NEW |