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" |
11 #include "GrBatchTarget.h" | 11 #include "GrBatchTarget.h" |
12 #include "GrBufferAllocPool.h" | 12 #include "GrBufferAllocPool.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrDefaultGeoProcFactory.h" | 14 #include "GrDefaultGeoProcFactory.h" |
15 #include "GrPathUtils.h" | 15 #include "GrPathUtils.h" |
16 #include "GrPipelineBuilder.h" | 16 #include "GrPipelineBuilder.h" |
| 17 #include "GrStrokeInfo.h" |
17 #include "SkGeometry.h" | 18 #include "SkGeometry.h" |
18 #include "SkString.h" | 19 #include "SkString.h" |
19 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
20 #include "SkTLazy.h" | 21 #include "SkTLazy.h" |
21 #include "SkTraceEvent.h" | 22 #include "SkTraceEvent.h" |
22 | 23 |
23 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, | 24 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
24 bool stencilWrapOpsSupport) | 25 bool stencilWrapOpsSupport) |
25 : fSeparateStencil(separateStencilSupport) | 26 : fSeparateStencil(separateStencilSupport) |
26 , fStencilWrapOps(stencilWrapOpsSupport) { | 27 , fStencilWrapOps(stencilWrapOpsSupport) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return path.isConvex(); | 164 return path.isConvex(); |
164 } | 165 } |
165 return false; | 166 return false; |
166 #endif | 167 #endif |
167 } | 168 } |
168 | 169 |
169 GrPathRenderer::StencilSupport | 170 GrPathRenderer::StencilSupport |
170 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 171 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
171 const GrPipelineBuilder*, | 172 const GrPipelineBuilder*, |
172 const SkPath& path, | 173 const SkPath& path, |
173 const SkStrokeRec& stroke) const { | 174 const GrStrokeInfo& stroke) const { |
174 if (single_pass_path(path, stroke)) { | 175 if (single_pass_path(path, stroke.getStrokeRec())) { |
175 return GrPathRenderer::kNoRestriction_StencilSupport; | 176 return GrPathRenderer::kNoRestriction_StencilSupport; |
176 } else { | 177 } else { |
177 return GrPathRenderer::kStencilOnly_StencilSupport; | 178 return GrPathRenderer::kStencilOnly_StencilSupport; |
178 } | 179 } |
179 } | 180 } |
180 | 181 |
181 static inline void append_countour_edge_indices(bool hairLine, | 182 static inline void append_countour_edge_indices(bool hairLine, |
182 uint16_t fanCenterIdx, | 183 uint16_t fanCenterIdx, |
183 uint16_t edgeV0Idx, | 184 uint16_t edgeV0Idx, |
184 uint16_t** indices) { | 185 uint16_t** indices) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 539 |
539 BatchTracker fBatch; | 540 BatchTracker fBatch; |
540 SkSTArray<1, Geometry, true> fGeoData; | 541 SkSTArray<1, Geometry, true> fGeoData; |
541 }; | 542 }; |
542 | 543 |
543 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, | 544 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, |
544 GrPipelineBuilder* pipelineBuilder, | 545 GrPipelineBuilder* pipelineBuilder, |
545 GrColor color, | 546 GrColor color, |
546 const SkMatrix& viewMatrix, | 547 const SkMatrix& viewMatrix, |
547 const SkPath& path, | 548 const SkPath& path, |
548 const SkStrokeRec& origStroke, | 549 const GrStrokeInfo& origStroke, |
549 bool stencilOnly) { | 550 bool stencilOnly) { |
550 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); | 551 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke.getStrokeRec()); |
551 | 552 |
552 SkScalar hairlineCoverage; | 553 SkScalar hairlineCoverage; |
553 uint8_t newCoverage = 0xff; | 554 uint8_t newCoverage = 0xff; |
554 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { | 555 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { |
555 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); | 556 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); |
556 | 557 |
557 if (!stroke->isHairlineStyle()) { | 558 if (!stroke->isHairlineStyle()) { |
558 stroke.writable()->setHairlineStyle(); | 559 stroke.writable()->setHairlineStyle(); |
559 } | 560 } |
560 } | 561 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 target->drawBatch(pipelineBuilder, batch, &devBounds); | 713 target->drawBatch(pipelineBuilder, batch, &devBounds); |
713 } | 714 } |
714 } | 715 } |
715 return true; | 716 return true; |
716 } | 717 } |
717 | 718 |
718 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, | 719 bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target, |
719 const GrPipelineBuilder* pipelineBuilder
, | 720 const GrPipelineBuilder* pipelineBuilder
, |
720 const SkMatrix& viewMatrix, | 721 const SkMatrix& viewMatrix, |
721 const SkPath& path, | 722 const SkPath& path, |
722 const SkStrokeRec& stroke, | 723 const GrStrokeInfo& stroke, |
723 bool antiAlias) const { | 724 bool antiAlias) const { |
724 // this class can draw any path with any fill but doesn't do any anti-aliasi
ng. | 725 // 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, | 726 return !antiAlias && (stroke.getStrokeRec().isFillStyle() || |
726 v
iewMatrix, | 727 IsStrokeHairlineOrEquivalent(stroke.getStrokeRec(), vi
ewMatrix, NULL)); |
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 |