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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 return false; | 166 return false; |
167 #endif | 167 #endif |
168 } | 168 } |
169 | 169 |
170 GrPathRenderer::StencilSupport | 170 GrPathRenderer::StencilSupport |
171 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 171 GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
172 const GrPipelineBuilder*, | 172 const GrPipelineBuilder*, |
173 const SkPath& path, | 173 const SkPath& path, |
174 const GrStrokeInfo& stroke) const { | 174 const GrStrokeInfo& stroke) const { |
175 if (single_pass_path(path, stroke.getStrokeRec())) { | 175 if (single_pass_path(path, stroke)) { |
176 return GrPathRenderer::kNoRestriction_StencilSupport; | 176 return GrPathRenderer::kNoRestriction_StencilSupport; |
177 } else { | 177 } else { |
178 return GrPathRenderer::kStencilOnly_StencilSupport; | 178 return GrPathRenderer::kStencilOnly_StencilSupport; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 static inline void append_countour_edge_indices(bool hairLine, | 182 static inline void append_countour_edge_indices(bool hairLine, |
183 uint16_t fanCenterIdx, | 183 uint16_t fanCenterIdx, |
184 uint16_t edgeV0Idx, | 184 uint16_t edgeV0Idx, |
185 uint16_t** indices) { | 185 uint16_t** indices) { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 const SkPath& path, | 540 const SkPath& path, |
541 const GrStrokeInfo& origStroke, | 541 const GrStrokeInfo& origStroke, |
542 bool stencilOnly) { | 542 bool stencilOnly) { |
543 SkTCopyOnFirstWrite<GrStrokeInfo> stroke(origStroke); | 543 SkTCopyOnFirstWrite<GrStrokeInfo> stroke(origStroke); |
544 | 544 |
545 SkScalar hairlineCoverage; | 545 SkScalar hairlineCoverage; |
546 uint8_t newCoverage = 0xff; | 546 uint8_t newCoverage = 0xff; |
547 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { | 547 if (IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, &hairlineCoverage)) { |
548 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); | 548 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); |
549 | 549 |
550 if (!stroke->getStrokeRec().isHairlineStyle()) { | 550 if (!stroke->isHairlineStyle()) { |
551 stroke.writable()->getStrokeRecPtr()->setHairlineStyle(); | 551 stroke.writable()->setHairlineStyle(); |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 const bool isHairline = stroke->getStrokeRec().isHairlineStyle(); | 555 const bool isHairline = stroke->isHairlineStyle(); |
556 | 556 |
557 // Save the current xp on the draw state so we can reset it if needed | 557 // Save the current xp on the draw state so we can reset it if needed |
558 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(pipelineBuilder->getXP
Factory())); | 558 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(pipelineBuilder->getXP
Factory())); |
559 // face culling doesn't make sense here | 559 // face culling doesn't make sense here |
560 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace()
); | 560 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace()
); |
561 | 561 |
562 int passCount = 0; | 562 int passCount = 0; |
563 const GrStencilSettings* passes[3]; | 563 const GrStencilSettings* passes[3]; |
564 GrPipelineBuilder::DrawFace drawFace[3]; | 564 GrPipelineBuilder::DrawFace drawFace[3]; |
565 bool reverse = false; | 565 bool reverse = false; |
566 bool lastPassIsBounds; | 566 bool lastPassIsBounds; |
567 | 567 |
568 if (isHairline) { | 568 if (isHairline) { |
569 passCount = 1; | 569 passCount = 1; |
570 if (stencilOnly) { | 570 if (stencilOnly) { |
571 passes[0] = &gDirectToStencil; | 571 passes[0] = &gDirectToStencil; |
572 } else { | 572 } else { |
573 passes[0] = NULL; | 573 passes[0] = NULL; |
574 } | 574 } |
575 lastPassIsBounds = false; | 575 lastPassIsBounds = false; |
576 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; | 576 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; |
577 } else { | 577 } else { |
578 if (single_pass_path(path, stroke->getStrokeRec())) { | 578 if (single_pass_path(path, *stroke)) { |
579 passCount = 1; | 579 passCount = 1; |
580 if (stencilOnly) { | 580 if (stencilOnly) { |
581 passes[0] = &gDirectToStencil; | 581 passes[0] = &gDirectToStencil; |
582 } else { | 582 } else { |
583 passes[0] = NULL; | 583 passes[0] = NULL; |
584 } | 584 } |
585 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; | 585 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; |
586 lastPassIsBounds = false; | 586 lastPassIsBounds = false; |
587 } else { | 587 } else { |
588 switch (path.getFillType()) { | 588 switch (path.getFillType()) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 geometry.fColor = color; | 766 geometry.fColor = color; |
767 geometry.fPath = path; | 767 geometry.fPath = path; |
768 geometry.fTolerance = srcSpaceTol; | 768 geometry.fTolerance = srcSpaceTol; |
769 | 769 |
770 viewMatrix.mapRect(&bounds); | 770 viewMatrix.mapRect(&bounds); |
771 uint8_t coverage = GrRandomCoverage(random); | 771 uint8_t coverage = GrRandomCoverage(random); |
772 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 772 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
773 } | 773 } |
774 | 774 |
775 #endif | 775 #endif |
OLD | NEW |