| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return path.isConvex(); | 163 return path.isConvex(); |
| 164 } | 164 } |
| 165 return false; | 165 return false; |
| 166 #endif | 166 #endif |
| 167 } | 167 } |
| 168 | 168 |
| 169 GrPathRenderer::StencilSupport | 169 GrPathRenderer::StencilSupport |
| 170 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 170 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
| 171 const GrPipelineBuilder*, | 171 const GrPipelineBuilder*, |
| 172 const SkPath& path, | 172 const SkPath& path, |
| 173 const SkStrokeRec& stroke) const { | 173 const GrStrokeInfo& stroke) const { |
| 174 if (single_pass_path(path, stroke)) { | 174 if (single_pass_path(path, stroke.getStrokeRec())) { |
| 175 return GrPathRenderer::kNoRestriction_StencilSupport; | 175 return GrPathRenderer::kNoRestriction_StencilSupport; |
| 176 } else { | 176 } else { |
| 177 return GrPathRenderer::kStencilOnly_StencilSupport; | 177 return GrPathRenderer::kStencilOnly_StencilSupport; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 static inline void append_countour_edge_indices(bool hairLine, | 181 static inline void append_countour_edge_indices(bool hairLine, |
| 182 uint16_t fanCenterIdx, | 182 uint16_t fanCenterIdx, |
| 183 uint16_t edgeV0Idx, | 183 uint16_t edgeV0Idx, |
| 184 uint16_t** indices) { | 184 uint16_t** indices) { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 BatchTracker fBatch; | 539 BatchTracker fBatch; |
| 540 SkSTArray<1, Geometry, true> fGeoData; | 540 SkSTArray<1, Geometry, true> fGeoData; |
| 541 }; | 541 }; |
| 542 | 542 |
| 543 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, | 543 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, |
| 544 GrPipelineBuilder* pipelineBuilder, | 544 GrPipelineBuilder* pipelineBuilder, |
| 545 GrColor color, | 545 GrColor color, |
| 546 const SkMatrix& viewMatrix, | 546 const SkMatrix& viewMatrix, |
| 547 const SkPath& path, | 547 const SkPath& path, |
| 548 const SkStrokeRec& origStroke, | 548 const GrStrokeInfo& origStroke, |
| 549 bool stencilOnly) { | 549 bool stencilOnly) { |
| 550 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); | 550 SkTCopyOnFirstWrite<GrStrokeInfo> stroke(origStroke); |
| 551 | 551 |
| 552 SkScalar hairlineCoverage; | 552 SkScalar hairlineCoverage; |
| 553 uint8_t newCoverage = 0xff; | 553 uint8_t newCoverage = 0xff; |
| 554 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { | 554 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { |
| 555 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); | 555 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); |
| 556 | 556 |
| 557 if (!stroke->isHairlineStyle()) { | 557 if (!stroke->getStrokeRec().isHairlineStyle()) { |
| 558 stroke.writable()->setHairlineStyle(); | 558 stroke.writable()->getStrokeRecPtr()->setHairlineStyle(); |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 | 561 |
| 562 const bool isHairline = stroke->isHairlineStyle(); | 562 const bool isHairline = stroke->getStrokeRec().isHairlineStyle(); |
| 563 | 563 |
| 564 // Save the current xp on the draw state so we can reset it if needed | 564 // Save the current xp on the draw state so we can reset it if needed |
| 565 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(pipelineBuilder->getXP
Factory())); | 565 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(pipelineBuilder->getXP
Factory())); |
| 566 // face culling doesn't make sense here | 566 // face culling doesn't make sense here |
| 567 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace()
); | 567 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace()
); |
| 568 | 568 |
| 569 int passCount = 0; | 569 int passCount = 0; |
| 570 const GrStencilSettings* passes[3]; | 570 const GrStencilSettings* passes[3]; |
| 571 GrPipelineBuilder::DrawFace drawFace[3]; | 571 GrPipelineBuilder::DrawFace drawFace[3]; |
| 572 bool reverse = false; | 572 bool reverse = false; |
| 573 bool lastPassIsBounds; | 573 bool lastPassIsBounds; |
| 574 | 574 |
| 575 if (isHairline) { | 575 if (isHairline) { |
| 576 passCount = 1; | 576 passCount = 1; |
| 577 if (stencilOnly) { | 577 if (stencilOnly) { |
| 578 passes[0] = &gDirectToStencil; | 578 passes[0] = &gDirectToStencil; |
| 579 } else { | 579 } else { |
| 580 passes[0] = NULL; | 580 passes[0] = NULL; |
| 581 } | 581 } |
| 582 lastPassIsBounds = false; | 582 lastPassIsBounds = false; |
| 583 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; | 583 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; |
| 584 } else { | 584 } else { |
| 585 if (single_pass_path(path, *stroke)) { | 585 if (single_pass_path(path, stroke->getStrokeRec())) { |
| 586 passCount = 1; | 586 passCount = 1; |
| 587 if (stencilOnly) { | 587 if (stencilOnly) { |
| 588 passes[0] = &gDirectToStencil; | 588 passes[0] = &gDirectToStencil; |
| 589 } else { | 589 } else { |
| 590 passes[0] = NULL; | 590 passes[0] = NULL; |
| 591 } | 591 } |
| 592 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; | 592 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; |
| 593 lastPassIsBounds = false; | 593 lastPassIsBounds = false; |
| 594 } else { | 594 } else { |
| 595 switch (path.getFillType()) { | 595 switch (path.getFillType()) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 target->drawBatch(pipelineBuilder, batch, &devBounds); | 712 target->drawBatch(pipelineBuilder, batch, &devBounds); |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 return true; | 715 return true; |
| 716 } | 716 } |
| 717 | 717 |
| 718 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, | 718 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, |
| 719 const GrPipelineBuilder* pipelineBuilder
, | 719 const GrPipelineBuilder* pipelineBuilder
, |
| 720 const SkMatrix& viewMatrix, | 720 const SkMatrix& viewMatrix, |
| 721 const SkPath& path, | 721 const SkPath& path, |
| 722 const SkStrokeRec& stroke, | 722 const GrStrokeInfo& stroke, |
| 723 bool antiAlias) const { | 723 bool antiAlias) const { |
| 724 // this class can draw any path with any fill but doesn't do any anti-aliasi
ng. | 724 // this class can draw any path with any fill but doesn't do any anti-aliasi
ng. |
| 725 return !antiAlias && (stroke.isFillStyle() || IsStrokeHairlineOrEquivalent(s
troke, | 725 return !antiAlias && (stroke.isFillStyle() || IsStrokeHairlineOrEquivalent(s
troke, |
| 726 v
iewMatrix, | 726 v
iewMatrix, |
| 727 N
ULL)); | 727 N
ULL)); |
| 728 } | 728 } |
| 729 | 729 |
| 730 bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target, | 730 bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target, |
| 731 GrPipelineBuilder* pipelineBuilder, | 731 GrPipelineBuilder* pipelineBuilder, |
| 732 GrColor color, | 732 GrColor color, |
| 733 const SkMatrix& viewMatrix, | 733 const SkMatrix& viewMatrix, |
| 734 const SkPath& path, | 734 const SkPath& path, |
| 735 const SkStrokeRec& stroke, | 735 const GrStrokeInfo& stroke, |
| 736 bool antiAlias) { | 736 bool antiAlias) { |
| 737 return this->internalDrawPath(target, | 737 return this->internalDrawPath(target, |
| 738 pipelineBuilder, | 738 pipelineBuilder, |
| 739 color, | 739 color, |
| 740 viewMatrix, | 740 viewMatrix, |
| 741 path, | 741 path, |
| 742 stroke, | 742 stroke, |
| 743 false); | 743 false); |
| 744 } | 744 } |
| 745 | 745 |
| 746 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, | 746 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
| 747 GrPipelineBuilder* pipelineBuilder, | 747 GrPipelineBuilder* pipelineBuilder, |
| 748 const SkMatrix& viewMatrix, | 748 const SkMatrix& viewMatrix, |
| 749 const SkPath& path, | 749 const SkPath& path, |
| 750 const SkStrokeRec& stroke) { | 750 const GrStrokeInfo& stroke) { |
| 751 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); | 751 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
| 752 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); | 752 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
| 753 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); | 753 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); |
| 754 } | 754 } |
| OLD | NEW |