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

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

Issue 2167183002: Minor change to Ganesh path renderers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 }; 406 };
407 407
408 BatchTracker fBatch; 408 BatchTracker fBatch;
409 SkSTArray<1, Geometry, true> fGeoData; 409 SkSTArray<1, Geometry, true> fGeoData;
410 410
411 typedef GrVertexBatch INHERITED; 411 typedef GrVertexBatch INHERITED;
412 }; 412 };
413 413
414 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, 414 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext,
415 const GrPaint& paint, 415 const GrPaint& paint,
416 const GrUserStencilSettings* userSt encilSettings, 416 const GrUserStencilSettings& userSt encilSettings,
417 const GrClip& clip, 417 const GrClip& clip,
418 const SkMatrix& viewMatrix, 418 const SkMatrix& viewMatrix,
419 const GrShape& shape, 419 const GrShape& shape,
420 bool stencilOnly) { 420 bool stencilOnly) {
421 SkPath path; 421 SkPath path;
422 shape.asPath(&path); 422 shape.asPath(&path);
423 423
424 SkScalar hairlineCoverage; 424 SkScalar hairlineCoverage;
425 uint8_t newCoverage = 0xff; 425 uint8_t newCoverage = 0xff;
426 bool isHairline = false; 426 bool isHairline = false;
427 if (IsStrokeHairlineOrEquivalent(shape.style(), viewMatrix, &hairlineCoverag e)) { 427 if (IsStrokeHairlineOrEquivalent(shape.style(), viewMatrix, &hairlineCoverag e)) {
428 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); 428 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
429 isHairline = true; 429 isHairline = true;
430 } else { 430 } else {
431 SkASSERT(shape.style().isSimpleFill()); 431 SkASSERT(shape.style().isSimpleFill());
432 } 432 }
433 433
434 int passCount = 0; 434 int passCount = 0;
435 const GrUserStencilSettings* passes[3]; 435 const GrUserStencilSettings* passes[3];
436 GrPipelineBuilder::DrawFace drawFace[3]; 436 GrPipelineBuilder::DrawFace drawFace[3];
437 bool reverse = false; 437 bool reverse = false;
438 bool lastPassIsBounds; 438 bool lastPassIsBounds;
439 439
440 if (isHairline) { 440 if (isHairline) {
441 passCount = 1; 441 passCount = 1;
442 if (stencilOnly) { 442 if (stencilOnly) {
443 passes[0] = &gDirectToStencil; 443 passes[0] = &gDirectToStencil;
444 } else { 444 } else {
445 passes[0] = userStencilSettings; 445 passes[0] = &userStencilSettings;
446 } 446 }
447 lastPassIsBounds = false; 447 lastPassIsBounds = false;
448 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 448 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
449 } else { 449 } else {
450 if (single_pass_shape(shape)) { 450 if (single_pass_shape(shape)) {
451 passCount = 1; 451 passCount = 1;
452 if (stencilOnly) { 452 if (stencilOnly) {
453 passes[0] = &gDirectToStencil; 453 passes[0] = &gDirectToStencil;
454 } else { 454 } else {
455 passes[0] = userStencilSettings; 455 passes[0] = &userStencilSettings;
456 } 456 }
457 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 457 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
458 lastPassIsBounds = false; 458 lastPassIsBounds = false;
459 } else { 459 } else {
460 switch (path.getFillType()) { 460 switch (path.getFillType()) {
461 case SkPath::kInverseEvenOdd_FillType: 461 case SkPath::kInverseEvenOdd_FillType:
462 reverse = true; 462 reverse = true;
463 // fallthrough 463 // fallthrough
464 case SkPath::kEvenOdd_FillType: 464 case SkPath::kEvenOdd_FillType:
465 passes[0] = &gEOStencilPass; 465 passes[0] = &gEOStencilPass;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 return !args.fAntiAlias && 584 return !args.fAntiAlias &&
585 (args.fShape->style().isSimpleFill() || 585 (args.fShape->style().isSimpleFill() ||
586 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr)); 586 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr));
587 } 587 }
588 588
589 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { 589 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) {
590 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 590 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
591 "GrDefaultPathRenderer::onDrawPath"); 591 "GrDefaultPathRenderer::onDrawPath");
592 return this->internalDrawPath(args.fDrawContext, 592 return this->internalDrawPath(args.fDrawContext,
593 *args.fPaint, 593 *args.fPaint,
594 args.fUserStencilSettings, 594 *args.fUserStencilSettings,
595 *args.fClip, 595 *args.fClip,
596 *args.fViewMatrix, 596 *args.fViewMatrix,
597 *args.fShape, 597 *args.fShape,
598 false); 598 false);
599 } 599 }
600 600
601 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { 601 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
602 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 602 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
603 "GrDefaultPathRenderer::onStencilPath"); 603 "GrDefaultPathRenderer::onStencilPath");
604 SkASSERT(!args.fShape->inverseFilled()); 604 SkASSERT(!args.fShape->inverseFilled());
605 605
606 GrPaint paint; 606 GrPaint paint;
607 paint.setXPFactory(GrDisableColorXPFactory::Make()); 607 paint.setXPFactory(GrDisableColorXPFactory::Make());
608 paint.setAntiAlias(args.fIsAA); 608 paint.setAntiAlias(args.fIsAA);
609 609
610 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip, 610 this->internalDrawPath(args.fDrawContext, paint, GrUserStencilSettings::kUnu sed, *args.fClip,
611 *args.fViewMatrix, *args.fShape, true); 611 *args.fViewMatrix, *args.fShape, true);
612 } 612 }
613 613
614 //////////////////////////////////////////////////////////////////////////////// /////////////////// 614 //////////////////////////////////////////////////////////////////////////////// ///////////////////
615 615
616 #ifdef GR_TEST_UTILS 616 #ifdef GR_TEST_UTILS
617 617
618 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) { 618 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) {
619 GrColor color = GrRandomColor(random); 619 GrColor color = GrRandomColor(random);
620 SkMatrix viewMatrix = GrTest::TestMatrix(random); 620 SkMatrix viewMatrix = GrTest::TestMatrix(random);
621 621
622 // For now just hairlines because the other types of draws require two batch es. 622 // For now just hairlines because the other types of draws require two batch es.
623 // TODO we should figure out a way to combine the stencil and cover steps in to one batch 623 // TODO we should figure out a way to combine the stencil and cover steps in to one batch
624 GrStyle style(SkStrokeRec::kHairline_InitStyle); 624 GrStyle style(SkStrokeRec::kHairline_InitStyle);
625 SkPath path = GrTest::TestPath(random); 625 SkPath path = GrTest::TestPath(random);
626 626
627 // Compute srcSpaceTol 627 // Compute srcSpaceTol
628 SkRect bounds = path.getBounds(); 628 SkRect bounds = path.getBounds();
629 SkScalar tol = GrPathUtils::kDefaultTolerance; 629 SkScalar tol = GrPathUtils::kDefaultTolerance;
630 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou nds); 630 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou nds);
631 631
632 viewMatrix.mapRect(&bounds); 632 viewMatrix.mapRect(&bounds);
633 uint8_t coverage = GrRandomCoverage(random); 633 uint8_t coverage = GrRandomCoverage(random);
634 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds); 634 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds);
635 } 635 }
636 636
637 #endif 637 #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