| 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" |
| 11 #include "GrBatchTest.h" | 11 #include "GrBatchTest.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDefaultGeoProcFactory.h" | 13 #include "GrDefaultGeoProcFactory.h" |
| 14 #include "GrMesh.h" | 14 #include "GrMesh.h" |
| 15 #include "GrPathUtils.h" | 15 #include "GrPathUtils.h" |
| 16 #include "GrPipelineBuilder.h" | |
| 17 #include "SkGeometry.h" | 16 #include "SkGeometry.h" |
| 18 #include "SkString.h" | 17 #include "SkString.h" |
| 19 #include "SkStrokeRec.h" | 18 #include "SkStrokeRec.h" |
| 20 #include "SkTLazy.h" | 19 #include "SkTLazy.h" |
| 21 #include "SkTraceEvent.h" | 20 #include "SkTraceEvent.h" |
| 22 | 21 |
| 23 #include "batches/GrRectBatchFactory.h" | 22 #include "batches/GrRectBatchFactory.h" |
| 24 #include "batches/GrVertexBatch.h" | 23 #include "batches/GrVertexBatch.h" |
| 25 | 24 |
| 26 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, | 25 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } else { | 547 } else { |
| 549 bounds = path.getBounds(); | 548 bounds = path.getBounds(); |
| 550 } | 549 } |
| 551 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : | 550 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : |
| 552 v
iewMatrix; | 551 v
iewMatrix; |
| 553 SkAutoTUnref<GrDrawBatch> batch( | 552 SkAutoTUnref<GrDrawBatch> batch( |
| 554 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM,
bounds, nullptr, | 553 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM,
bounds, nullptr, |
| 555 &localMatrix)); | 554 &localMatrix)); |
| 556 | 555 |
| 557 SkASSERT(GrDrawFace::kBoth == drawFace[p]); | 556 SkASSERT(GrDrawFace::kBoth == drawFace[p]); |
| 558 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 557 drawContext->drawBatch(paint, clip, *passes[p], batch, drawFace[p]); |
| 559 pipelineBuilder.setDrawFace(drawFace[p]); | |
| 560 pipelineBuilder.setUserStencil(passes[p]); | |
| 561 | |
| 562 drawContext->drawBatch(pipelineBuilder, clip, batch); | |
| 563 } else { | 558 } else { |
| 564 SkAutoTUnref<GrDrawBatch> batch(new DefaultPathBatch(paint.getColor(
), path, | 559 SkAutoTUnref<GrDrawBatch> batch(new DefaultPathBatch(paint.getColor(
), path, |
| 565 srcSpaceTol, | 560 srcSpaceTol, |
| 566 newCoverage, vi
ewMatrix, | 561 newCoverage, vi
ewMatrix, |
| 567 isHairline, dev
Bounds)); | 562 isHairline, dev
Bounds)); |
| 568 | 563 |
| 569 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 564 SkTCopyOnFirstWrite<GrPaint> newPaint(paint); |
| 570 pipelineBuilder.setDrawFace(drawFace[p]); | |
| 571 pipelineBuilder.setUserStencil(passes[p]); | |
| 572 if (passCount > 1) { | 565 if (passCount > 1) { |
| 573 pipelineBuilder.setDisableColorXPFactory(); | 566 newPaint.writable()->setXPFactory(GrDisableColorXPFactory::Make(
)); |
| 574 } | 567 } |
| 575 | 568 |
| 576 drawContext->drawBatch(pipelineBuilder, clip, batch); | 569 drawContext->drawBatch(*newPaint, clip, *passes[p], batch, drawFace[
p]); |
| 577 } | 570 } |
| 578 } | 571 } |
| 579 return true; | 572 return true; |
| 580 } | 573 } |
| 581 | 574 |
| 582 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 575 bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
| 583 // this class can draw any path with any simple fill style but doesn't do an
y anti-aliasing. | 576 // this class can draw any path with any simple fill style but doesn't do an
y anti-aliasing. |
| 584 return !args.fAntiAlias && | 577 return !args.fAntiAlias && |
| 585 (args.fShape->style().isSimpleFill() || | 578 (args.fShape->style().isSimpleFill() || |
| 586 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix
, nullptr)); | 579 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix
, nullptr)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 SkRect bounds = path.getBounds(); | 621 SkRect bounds = path.getBounds(); |
| 629 SkScalar tol = GrPathUtils::kDefaultTolerance; | 622 SkScalar tol = GrPathUtils::kDefaultTolerance; |
| 630 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou
nds); | 623 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou
nds); |
| 631 | 624 |
| 632 viewMatrix.mapRect(&bounds); | 625 viewMatrix.mapRect(&bounds); |
| 633 uint8_t coverage = GrRandomCoverage(random); | 626 uint8_t coverage = GrRandomCoverage(random); |
| 634 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix,
true, bounds); | 627 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix,
true, bounds); |
| 635 } | 628 } |
| 636 | 629 |
| 637 #endif | 630 #endif |
| OLD | NEW |