| 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 "GrAAHairLinePathRenderer.h" | 8 #include "GrAAHairLinePathRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 for (int i = 0; i < kLineSegNumVertices; ++i) { | 609 for (int i = 0; i < kLineSegNumVertices; ++i) { |
| 610 (*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax); | 610 (*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax); |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 | 613 |
| 614 *vert += kLineSegNumVertices; | 614 *vert += kLineSegNumVertices; |
| 615 } | 615 } |
| 616 | 616 |
| 617 /////////////////////////////////////////////////////////////////////////////// | 617 /////////////////////////////////////////////////////////////////////////////// |
| 618 | 618 |
| 619 bool GrAAHairLinePathRenderer::canDrawPath(const GrDrawTarget* target, | 619 bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const
{ |
| 620 const GrPipelineBuilder* pipelineBuil
der, | 620 if (!args.fAntiAlias) { |
| 621 const SkMatrix& viewMatrix, | |
| 622 const SkPath& path, | |
| 623 const GrStrokeInfo& stroke, | |
| 624 bool antiAlias) const { | |
| 625 if (!antiAlias) { | |
| 626 return false; | 621 return false; |
| 627 } | 622 } |
| 628 | 623 |
| 629 if (!IsStrokeHairlineOrEquivalent(stroke, viewMatrix, NULL)) { | 624 if (!IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, NULL)) { |
| 630 return false; | 625 return false; |
| 631 } | 626 } |
| 632 | 627 |
| 633 if (SkPath::kLine_SegmentMask == path.getSegmentMasks() || | 628 if (SkPath::kLine_SegmentMask == args.fPath->getSegmentMasks() || |
| 634 target->caps()->shaderCaps()->shaderDerivativeSupport()) { | 629 args.fTarget->caps()->shaderCaps()->shaderDerivativeSupport()) { |
| 635 return true; | 630 return true; |
| 636 } | 631 } |
| 637 return false; | 632 return false; |
| 638 } | 633 } |
| 639 | 634 |
| 640 template <class VertexType> | 635 template <class VertexType> |
| 641 bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
tices, int vCount) | 636 bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
tices, int vCount) |
| 642 { | 637 { |
| 643 SkRect tolDevBounds = devBounds; | 638 SkRect tolDevBounds = devBounds; |
| 644 // The bounds ought to be tight, but in perspective the below code runs the
verts | 639 // The bounds ought to be tight, but in perspective the below code runs the
verts |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 AAHairlineBatch::Geometry geometry; | 962 AAHairlineBatch::Geometry geometry; |
| 968 geometry.fColor = color; | 963 geometry.fColor = color; |
| 969 geometry.fCoverage = newCoverage; | 964 geometry.fCoverage = newCoverage; |
| 970 geometry.fViewMatrix = viewMatrix; | 965 geometry.fViewMatrix = viewMatrix; |
| 971 geometry.fPath = path; | 966 geometry.fPath = path; |
| 972 geometry.fDevClipBounds = devClipBounds; | 967 geometry.fDevClipBounds = devClipBounds; |
| 973 | 968 |
| 974 return AAHairlineBatch::Create(geometry); | 969 return AAHairlineBatch::Create(geometry); |
| 975 } | 970 } |
| 976 | 971 |
| 977 bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target, | 972 bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 978 GrPipelineBuilder* pipelineBuilder, | |
| 979 GrColor color, | |
| 980 const SkMatrix& viewMatrix, | |
| 981 const SkPath& path, | |
| 982 const GrStrokeInfo& stroke, | |
| 983 bool) { | |
| 984 SkIRect devClipBounds; | 973 SkIRect devClipBounds; |
| 985 pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarg
et(), | 974 args.fPipelineBuilder->clip().getConservativeBounds(args.fPipelineBuilder->g
etRenderTarget(), |
| 986 &devClipBounds); | 975 &devClipBounds); |
| 987 | 976 |
| 988 SkAutoTUnref<GrBatch> batch(create_hairline_batch(color, viewMatrix, path, s
troke, | 977 SkAutoTUnref<GrBatch> batch(create_hairline_batch(args.fColor, *args.fViewMa
trix, *args.fPath, |
| 989 devClipBounds)); | 978 *args.fStroke, devClipBoun
ds)); |
| 990 target->drawBatch(*pipelineBuilder, batch); | 979 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); |
| 991 | 980 |
| 992 return true; | 981 return true; |
| 993 } | 982 } |
| 994 | 983 |
| 995 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 984 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 996 | 985 |
| 997 #ifdef GR_TEST_UTILS | 986 #ifdef GR_TEST_UTILS |
| 998 | 987 |
| 999 BATCH_TEST_DEFINE(AAHairlineBatch) { | 988 BATCH_TEST_DEFINE(AAHairlineBatch) { |
| 1000 GrColor color = GrRandomColor(random); | 989 GrColor color = GrRandomColor(random); |
| 1001 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 1002 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
| 1003 SkPath path = GrTest::TestPath(random); | 992 SkPath path = GrTest::TestPath(random); |
| 1004 SkIRect devClipBounds; | 993 SkIRect devClipBounds; |
| 1005 devClipBounds.setEmpty(); | 994 devClipBounds.setEmpty(); |
| 1006 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
| 1007 } | 996 } |
| 1008 | 997 |
| 1009 #endif | 998 #endif |
| OLD | NEW |