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

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

Issue 2006643005: Start on replacing path+style with shape in patherenderer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase after breaking out more Created 4 years, 6 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/GrDefaultPathRenderer.h ('k') | src/gpu/batches/GrMSAAPathRenderer.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 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 "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 16 matching lines...) Expand all
27 bool stencilWrapOpsSupport) 27 bool stencilWrapOpsSupport)
28 : fSeparateStencil(separateStencilSupport) 28 : fSeparateStencil(separateStencilSupport)
29 , fStencilWrapOps(stencilWrapOpsSupport) { 29 , fStencilWrapOps(stencilWrapOpsSupport) {
30 } 30 }
31 31
32 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
33 // Helpers for drawPath 33 // Helpers for drawPath
34 34
35 #define STENCIL_OFF 0 // Always disable stencil (even when needed) 35 #define STENCIL_OFF 0 // Always disable stencil (even when needed)
36 36
37 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok e) { 37 static inline bool single_pass_shape(const GrShape& shape) {
38 #if STENCIL_OFF 38 #if STENCIL_OFF
39 return true; 39 return true;
40 #else 40 #else
41 if (!stroke.isHairlineStyle() && !path.isInverseFillType()) { 41 if (!shape.style().couldBeHairline() && !shape.inverseFilled()) {
42 return path.isConvex(); 42 return shape.knownToBeConvex();
43 } 43 }
44 return false; 44 return false;
45 #endif 45 #endif
46 } 46 }
47 47
48 GrPathRenderer::StencilSupport 48 GrPathRenderer::StencilSupport
49 GrDefaultPathRenderer::onGetStencilSupport(const SkPath& path) const { 49 GrDefaultPathRenderer::onGetStencilSupport(const GrShape& shape) const {
50 if (single_pass_path(path, SkStrokeRec(SkStrokeRec::kFill_InitStyle))) { 50 if (single_pass_shape(shape)) {
51 return GrPathRenderer::kNoRestriction_StencilSupport; 51 return GrPathRenderer::kNoRestriction_StencilSupport;
52 } else { 52 } else {
53 return GrPathRenderer::kStencilOnly_StencilSupport; 53 return GrPathRenderer::kStencilOnly_StencilSupport;
54 } 54 }
55 } 55 }
56 56
57 static inline void append_countour_edge_indices(bool hairLine, 57 static inline void append_countour_edge_indices(bool hairLine,
58 uint16_t fanCenterIdx, 58 uint16_t fanCenterIdx,
59 uint16_t edgeV0Idx, 59 uint16_t edgeV0Idx,
60 uint16_t** indices) { 60 uint16_t** indices) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 typedef GrVertexBatch INHERITED; 416 typedef GrVertexBatch INHERITED;
417 }; 417 };
418 418
419 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, 419 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext,
420 const GrPaint& paint, 420 const GrPaint& paint,
421 const GrUserStencilSettings* userSt encilSettings, 421 const GrUserStencilSettings* userSt encilSettings,
422 const GrClip& clip, 422 const GrClip& clip,
423 GrColor color, 423 GrColor color,
424 const SkMatrix& viewMatrix, 424 const SkMatrix& viewMatrix,
425 const SkPath& path, 425 const GrShape& shape,
426 const GrStyle& origStyle,
427 bool stencilOnly) { 426 bool stencilOnly) {
428 const GrStyle* style = &origStyle; 427 SkPath path;
428 shape.asPath(&path);
429 429
430 SkScalar hairlineCoverage; 430 SkScalar hairlineCoverage;
431 uint8_t newCoverage = 0xff; 431 uint8_t newCoverage = 0xff;
432 bool isHairline = false; 432 bool isHairline = false;
433 if (IsStrokeHairlineOrEquivalent(*style, viewMatrix, &hairlineCoverage)) { 433 if (IsStrokeHairlineOrEquivalent(shape.style(), viewMatrix, &hairlineCoverag e)) {
434 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); 434 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
435 style = &GrStyle::SimpleHairline();
436 isHairline = true; 435 isHairline = true;
437 } else { 436 } else {
438 SkASSERT(style->isSimpleFill()); 437 SkASSERT(shape.style().isSimpleFill());
439 } 438 }
440 439
441 int passCount = 0; 440 int passCount = 0;
442 const GrUserStencilSettings* passes[3]; 441 const GrUserStencilSettings* passes[3];
443 GrPipelineBuilder::DrawFace drawFace[3]; 442 GrPipelineBuilder::DrawFace drawFace[3];
444 bool reverse = false; 443 bool reverse = false;
445 bool lastPassIsBounds; 444 bool lastPassIsBounds;
446 445
447 if (isHairline) { 446 if (isHairline) {
448 passCount = 1; 447 passCount = 1;
449 if (stencilOnly) { 448 if (stencilOnly) {
450 passes[0] = &gDirectToStencil; 449 passes[0] = &gDirectToStencil;
451 } else { 450 } else {
452 passes[0] = nullptr; 451 passes[0] = nullptr;
453 } 452 }
454 lastPassIsBounds = false; 453 lastPassIsBounds = false;
455 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 454 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
456 } else { 455 } else {
457 if (single_pass_path(path, style->strokeRec())) { 456 if (single_pass_shape(shape)) {
458 passCount = 1; 457 passCount = 1;
459 if (stencilOnly) { 458 if (stencilOnly) {
460 passes[0] = &gDirectToStencil; 459 passes[0] = &gDirectToStencil;
461 } else { 460 } else {
462 passes[0] = nullptr; 461 passes[0] = nullptr;
463 } 462 }
464 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 463 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
465 lastPassIsBounds = false; 464 lastPassIsBounds = false;
466 } else { 465 } else {
467 switch (path.getFillType()) { 466 switch (path.getFillType()) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 592
594 drawContext->drawBatch(pipelineBuilder, clip, batch); 593 drawContext->drawBatch(pipelineBuilder, clip, batch);
595 } 594 }
596 } 595 }
597 return true; 596 return true;
598 } 597 }
599 598
600 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { 599 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
601 // this class can draw any path with any simple fill style but doesn't do an y anti-aliasing. 600 // this class can draw any path with any simple fill style but doesn't do an y anti-aliasing.
602 return !args.fAntiAlias && 601 return !args.fAntiAlias &&
603 (args.fStyle->isSimpleFill() || IsStrokeHairlineOrEquivalent(*args.fS tyle, 602 (args.fShape->style().isSimpleFill() ||
604 *args.fV iewMatrix, 603 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr));
605 nullptr) );
606 } 604 }
607 605
608 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { 606 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) {
609 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 607 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
610 "GrDefaultPathRenderer::onDrawPath"); 608 "GrDefaultPathRenderer::onDrawPath");
611 return this->internalDrawPath(args.fDrawContext, 609 return this->internalDrawPath(args.fDrawContext,
612 *args.fPaint, 610 *args.fPaint,
613 args.fUserStencilSettings, 611 args.fUserStencilSettings,
614 *args.fClip, 612 *args.fClip,
615 args.fColor, 613 args.fColor,
616 *args.fViewMatrix, 614 *args.fViewMatrix,
617 *args.fPath, 615 *args.fShape,
618 *args.fStyle,
619 false); 616 false);
620 } 617 }
621 618
622 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { 619 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
623 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 620 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
624 "GrDefaultPathRenderer::onStencilPath"); 621 "GrDefaultPathRenderer::onStencilPath");
625 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); 622 SkASSERT(!args.fShape->inverseFilled());
626 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
627 623
628 GrPaint paint; 624 GrPaint paint;
629 paint.setXPFactory(GrDisableColorXPFactory::Make()); 625 paint.setXPFactory(GrDisableColorXPFactory::Make());
630 paint.setAntiAlias(args.fIsAA); 626 paint.setAntiAlias(args.fIsAA);
631 627
632 this->internalDrawPath(args.fDrawContext, 628 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip,
633 paint, 629 GrColor_WHITE, *args.fViewMatrix, *args.fShape, true) ;
634 &GrUserStencilSettings::kUnused,
635 *args.fClip,
636 GrColor_WHITE,
637 *args.fViewMatrix,
638 *args.fPath,
639 GrStyle::SimpleFill(),
640 true);
641 } 630 }
642 631
643 //////////////////////////////////////////////////////////////////////////////// /////////////////// 632 //////////////////////////////////////////////////////////////////////////////// ///////////////////
644 633
645 #ifdef GR_TEST_UTILS 634 #ifdef GR_TEST_UTILS
646 635
647 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) { 636 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) {
648 GrColor color = GrRandomColor(random); 637 GrColor color = GrRandomColor(random);
649 SkMatrix viewMatrix = GrTest::TestMatrix(random); 638 SkMatrix viewMatrix = GrTest::TestMatrix(random);
650 639
(...skipping 11 matching lines...) Expand all
662 geometry.fColor = color; 651 geometry.fColor = color;
663 geometry.fPath = path; 652 geometry.fPath = path;
664 geometry.fTolerance = srcSpaceTol; 653 geometry.fTolerance = srcSpaceTol;
665 654
666 viewMatrix.mapRect(&bounds); 655 viewMatrix.mapRect(&bounds);
667 uint8_t coverage = GrRandomCoverage(random); 656 uint8_t coverage = GrRandomCoverage(random);
668 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds ); 657 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds );
669 } 658 }
670 659
671 #endif 660 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDefaultPathRenderer.h ('k') | src/gpu/batches/GrMSAAPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698