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