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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 *vert += kLineSegNumVertices; | 611 *vert += kLineSegNumVertices; |
612 } | 612 } |
613 | 613 |
614 /////////////////////////////////////////////////////////////////////////////// | 614 /////////////////////////////////////////////////////////////////////////////// |
615 | 615 |
616 bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const
{ | 616 bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const
{ |
617 if (!args.fAntiAlias) { | 617 if (!args.fAntiAlias) { |
618 return false; | 618 return false; |
619 } | 619 } |
620 | 620 |
621 if (!IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, nullptr)
) { | 621 if (!IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullptr))
{ |
622 return false; | 622 return false; |
623 } | 623 } |
624 | 624 |
| 625 // We don't currently handle dashing in this class though perhaps we should. |
| 626 if (args.fStyle->pathEffect()) { |
| 627 return false; |
| 628 } |
| 629 |
625 if (SkPath::kLine_SegmentMask == args.fPath->getSegmentMasks() || | 630 if (SkPath::kLine_SegmentMask == args.fPath->getSegmentMasks() || |
626 args.fShaderCaps->shaderDerivativeSupport()) { | 631 args.fShaderCaps->shaderDerivativeSupport()) { |
627 return true; | 632 return true; |
628 } | 633 } |
629 return false; | 634 return false; |
630 } | 635 } |
631 | 636 |
632 template <class VertexType> | 637 template <class VertexType> |
633 bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
tices, int vCount) | 638 bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
tices, int vCount) |
634 { | 639 { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 firstVertex, kQuadNumVertices, kIdxsPerQuad, coni
cCount, | 937 firstVertex, kQuadNumVertices, kIdxsPerQuad, coni
cCount, |
933 kQuadsNumInIdxBuffer); | 938 kQuadsNumInIdxBuffer); |
934 target->draw(conicGP, mesh); | 939 target->draw(conicGP, mesh); |
935 } | 940 } |
936 } | 941 } |
937 } | 942 } |
938 | 943 |
939 static GrDrawBatch* create_hairline_batch(GrColor color, | 944 static GrDrawBatch* create_hairline_batch(GrColor color, |
940 const SkMatrix& viewMatrix, | 945 const SkMatrix& viewMatrix, |
941 const SkPath& path, | 946 const SkPath& path, |
942 const GrStrokeInfo& stroke, | 947 const GrStyle& style, |
943 const SkIRect& devClipBounds) { | 948 const SkIRect& devClipBounds) { |
944 SkScalar hairlineCoverage; | 949 SkScalar hairlineCoverage; |
945 uint8_t newCoverage = 0xff; | 950 uint8_t newCoverage = 0xff; |
946 if (GrPathRenderer::IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairli
neCoverage)) { | 951 if (GrPathRenderer::IsStrokeHairlineOrEquivalent(style, viewMatrix, &hairlin
eCoverage)) { |
947 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); | 952 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); |
948 } | 953 } |
949 | 954 |
950 AAHairlineBatch::Geometry geometry; | 955 AAHairlineBatch::Geometry geometry; |
951 geometry.fColor = color; | 956 geometry.fColor = color; |
952 geometry.fCoverage = newCoverage; | 957 geometry.fCoverage = newCoverage; |
953 geometry.fViewMatrix = viewMatrix; | 958 geometry.fViewMatrix = viewMatrix; |
954 geometry.fPath = path; | 959 geometry.fPath = path; |
955 geometry.fDevClipBounds = devClipBounds; | 960 geometry.fDevClipBounds = devClipBounds; |
956 | 961 |
957 return AAHairlineBatch::Create(geometry); | 962 return AAHairlineBatch::Create(geometry); |
958 } | 963 } |
959 | 964 |
960 bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { | 965 bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { |
961 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrAAHairlinePathRen
derer::onDrawPath"); | 966 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrAAHairlinePathRen
derer::onDrawPath"); |
962 SkIRect devClipBounds; | 967 SkIRect devClipBounds; |
963 GrRenderTarget* rt = args.fPipelineBuilder->getRenderTarget(); | 968 GrRenderTarget* rt = args.fPipelineBuilder->getRenderTarget(); |
964 args.fPipelineBuilder->clip().getConservativeBounds(rt->width(), rt->height(
), &devClipBounds); | 969 args.fPipelineBuilder->clip().getConservativeBounds(rt->width(), rt->height(
), &devClipBounds); |
965 | 970 |
966 SkAutoTUnref<GrDrawBatch> batch(create_hairline_batch(args.fColor, *args.fVi
ewMatrix, *args.fPath, | 971 SkAutoTUnref<GrDrawBatch> batch(create_hairline_batch(args.fColor, *args.fVi
ewMatrix, *args.fPath, |
967 *args.fStroke, devClip
Bounds)); | 972 *args.fStyle, devClipB
ounds)); |
968 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); | 973 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); |
969 | 974 |
970 return true; | 975 return true; |
971 } | 976 } |
972 | 977 |
973 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 978 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
974 | 979 |
975 #ifdef GR_TEST_UTILS | 980 #ifdef GR_TEST_UTILS |
976 | 981 |
977 DRAW_BATCH_TEST_DEFINE(AAHairlineBatch) { | 982 DRAW_BATCH_TEST_DEFINE(AAHairlineBatch) { |
978 GrColor color = GrRandomColor(random); | 983 GrColor color = GrRandomColor(random); |
979 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 984 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
980 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | |
981 SkPath path = GrTest::TestPath(random); | 985 SkPath path = GrTest::TestPath(random); |
982 SkIRect devClipBounds; | 986 SkIRect devClipBounds; |
983 devClipBounds.setEmpty(); | 987 devClipBounds.setEmpty(); |
984 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 988 return create_hairline_batch(color, viewMatrix, path, GrStyle::SimpleHairlin
e(), devClipBounds); |
985 } | 989 } |
986 | 990 |
987 #endif | 991 #endif |
OLD | NEW |