| 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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 BatchTracker fBatch; | 414 BatchTracker fBatch; |
| 415 SkSTArray<1, Geometry, true> fGeoData; | 415 SkSTArray<1, Geometry, true> fGeoData; |
| 416 | 416 |
| 417 typedef GrVertexBatch INHERITED; | 417 typedef GrVertexBatch INHERITED; |
| 418 }; | 418 }; |
| 419 | 419 |
| 420 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, | 420 bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, |
| 421 GrPipelineBuilder* pipelineBuilder, | 421 GrPipelineBuilder* pipelineBuilder, |
| 422 const GrClip& clip, |
| 422 GrColor color, | 423 GrColor color, |
| 423 const SkMatrix& viewMatrix, | 424 const SkMatrix& viewMatrix, |
| 424 const SkPath& path, | 425 const SkPath& path, |
| 425 const GrStyle& origStyle, | 426 const GrStyle& origStyle, |
| 426 bool stencilOnly) { | 427 bool stencilOnly) { |
| 427 const GrStyle* style = &origStyle; | 428 const GrStyle* style = &origStyle; |
| 428 | 429 |
| 429 SkScalar hairlineCoverage; | 430 SkScalar hairlineCoverage; |
| 430 uint8_t newCoverage = 0xff; | 431 uint8_t newCoverage = 0xff; |
| 431 bool isHairline = false; | 432 bool isHairline = false; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 } | 567 } |
| 567 } | 568 } |
| 568 } else { | 569 } else { |
| 569 bounds = path.getBounds(); | 570 bounds = path.getBounds(); |
| 570 } | 571 } |
| 571 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : | 572 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : |
| 572 v
iewMatrix; | 573 v
iewMatrix; |
| 573 SkAutoTUnref<GrDrawBatch> batch( | 574 SkAutoTUnref<GrDrawBatch> batch( |
| 574 GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nu
llptr, | 575 GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nu
llptr, |
| 575 &localMatrix)); | 576 &localMatrix)); |
| 576 target->drawBatch(*pipelineBuilder, batch); | 577 target->drawBatch(*pipelineBuilder, clip, batch); |
| 577 } else { | 578 } else { |
| 578 if (passCount > 1) { | 579 if (passCount > 1) { |
| 579 pipelineBuilder->setDisableColorXPFactory(); | 580 pipelineBuilder->setDisableColorXPFactory(); |
| 580 } | 581 } |
| 581 | 582 |
| 582 DefaultPathBatch::Geometry geometry; | 583 DefaultPathBatch::Geometry geometry; |
| 583 geometry.fColor = color; | 584 geometry.fColor = color; |
| 584 geometry.fPath = path; | 585 geometry.fPath = path; |
| 585 geometry.fTolerance = srcSpaceTol; | 586 geometry.fTolerance = srcSpaceTol; |
| 586 | 587 |
| 587 SkAutoTUnref<GrDrawBatch> batch(DefaultPathBatch::Create(geometry, n
ewCoverage, | 588 SkAutoTUnref<GrDrawBatch> batch(DefaultPathBatch::Create(geometry, n
ewCoverage, |
| 588 viewMatrix,
isHairline, | 589 viewMatrix,
isHairline, |
| 589 devBounds))
; | 590 devBounds))
; |
| 590 | 591 |
| 591 target->drawBatch(*pipelineBuilder, batch); | 592 target->drawBatch(*pipelineBuilder, clip, batch); |
| 592 } | 593 } |
| 593 } | 594 } |
| 594 return true; | 595 return true; |
| 595 } | 596 } |
| 596 | 597 |
| 597 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 598 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
| 598 // this class can draw any path with any simple fill style but doesn't do an
y anti-aliasing. | 599 // this class can draw any path with any simple fill style but doesn't do an
y anti-aliasing. |
| 599 return !args.fAntiAlias && | 600 return !args.fAntiAlias && |
| 600 (args.fStyle->isSimpleFill() || IsStrokeHairlineOrEquivalent(*args.fS
tyle, | 601 (args.fStyle->isSimpleFill() || IsStrokeHairlineOrEquivalent(*args.fS
tyle, |
| 601 *args.fV
iewMatrix, | 602 *args.fV
iewMatrix, |
| 602 nullptr)
); | 603 nullptr)
); |
| 603 } | 604 } |
| 604 | 605 |
| 605 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { | 606 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 606 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrDefaultPathRende
rer::onDrawPath"); | 607 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrDefaultPathRende
rer::onDrawPath"); |
| 607 return this->internalDrawPath(args.fTarget, | 608 return this->internalDrawPath(args.fTarget, |
| 608 args.fPipelineBuilder, | 609 args.fPipelineBuilder, |
| 610 *args.fClip, |
| 609 args.fColor, | 611 args.fColor, |
| 610 *args.fViewMatrix, | 612 *args.fViewMatrix, |
| 611 *args.fPath, | 613 *args.fPath, |
| 612 *args.fStyle, | 614 *args.fStyle, |
| 613 false); | 615 false); |
| 614 } | 616 } |
| 615 | 617 |
| 616 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { | 618 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { |
| 617 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrDefaultPathRender
er::onStencilPath"); | 619 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrDefaultPathRender
er::onStencilPath"); |
| 618 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); | 620 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); |
| 619 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); | 621 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); |
| 620 this->internalDrawPath(args.fTarget, args.fPipelineBuilder, GrColor_WHITE, *
args.fViewMatrix, | 622 this->internalDrawPath(args.fTarget, args.fPipelineBuilder, *args.fClip, GrC
olor_WHITE, |
| 621 *args.fPath, GrStyle::SimpleFill(), true); | 623 *args.fViewMatrix, *args.fPath, GrStyle::SimpleFill()
, true); |
| 622 } | 624 } |
| 623 | 625 |
| 624 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 626 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 625 | 627 |
| 626 #ifdef GR_TEST_UTILS | 628 #ifdef GR_TEST_UTILS |
| 627 | 629 |
| 628 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) { | 630 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) { |
| 629 GrColor color = GrRandomColor(random); | 631 GrColor color = GrRandomColor(random); |
| 630 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 632 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 631 | 633 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 643 geometry.fColor = color; | 645 geometry.fColor = color; |
| 644 geometry.fPath = path; | 646 geometry.fPath = path; |
| 645 geometry.fTolerance = srcSpaceTol; | 647 geometry.fTolerance = srcSpaceTol; |
| 646 | 648 |
| 647 viewMatrix.mapRect(&bounds); | 649 viewMatrix.mapRect(&bounds); |
| 648 uint8_t coverage = GrRandomCoverage(random); | 650 uint8_t coverage = GrRandomCoverage(random); |
| 649 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 651 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
| 650 } | 652 } |
| 651 | 653 |
| 652 #endif | 654 #endif |
| OLD | NEW |