| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrStrokePathRenderer.h" | 8 #include "GrStrokePathRenderer.h" |
| 9 | 9 |
| 10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 res.x() < GrMin(x3, x4) || res.x() > GrMax(x3, x4) || | 47 res.x() < GrMin(x3, x4) || res.x() > GrMax(x3, x4) || |
| 48 res.y() < GrMin(y1, y2) || res.y() > GrMax(y1, y2) || | 48 res.y() < GrMin(y1, y2) || res.y() > GrMax(y1, y2) || |
| 49 res.y() < GrMin(y3, y4) || res.y() > GrMax(y3, y4)) ? | 49 res.y() < GrMin(y3, y4) || res.y() > GrMax(y3, y4)) ? |
| 50 kOut_IntersectionType : kIn_IntersectionType; | 50 kOut_IntersectionType : kIn_IntersectionType; |
| 51 } | 51 } |
| 52 | 52 |
| 53 GrStrokePathRenderer::GrStrokePathRenderer() { | 53 GrStrokePathRenderer::GrStrokePathRenderer() { |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool GrStrokePathRenderer::canDrawPath(const SkPath& path, | 56 bool GrStrokePathRenderer::canDrawPath(const SkPath& path, |
| 57 const SkStrokeRec& stroke, | 57 const GrStrokeInfo& stroke, |
| 58 const GrDrawTarget* target, | 58 const GrDrawTarget* target, |
| 59 bool antiAlias) const { | 59 bool antiAlias) const { |
| 60 // FIXME : put the proper condition once GrDrawTarget::isOpaque is implement
ed | 60 // FIXME : put the proper condition once GrDrawTarget::isOpaque is implement
ed |
| 61 const bool isOpaque = true; // target->isOpaque(); | 61 const bool isOpaque = true; // target->isOpaque(); |
| 62 | 62 |
| 63 // FIXME : remove this requirement once we have AA circles and implement the | 63 // FIXME : remove this requirement once we have AA circles and implement the |
| 64 // circle joins/caps appropriately in the ::onDrawPath() function. | 64 // circle joins/caps appropriately in the ::onDrawPath() function. |
| 65 const bool requiresAACircle = (stroke.getCap() == SkPaint::kRound_Cap) || | 65 const bool requiresAACircle = (stroke.getCap() == SkPaint::kRound_Cap) || |
| 66 (stroke.getJoin() == SkPaint::kRound_Join); | 66 (stroke.getJoin() == SkPaint::kRound_Join); |
| 67 | 67 |
| 68 // Indices being stored in uint16, we don't want to overflow the indices cap
acity | 68 // Indices being stored in uint16, we don't want to overflow the indices cap
acity |
| 69 static const int maxVBSize = 1 << 16; | 69 static const int maxVBSize = 1 << 16; |
| 70 const int maxNbVerts = (path.countPoints() + 1) * 5; | 70 const int maxNbVerts = (path.countPoints() + 1) * 5; |
| 71 | 71 |
| 72 // Check that the path contains no curved lines, only straight lines | 72 // Check that the path contains no curved lines, only straight lines |
| 73 static const uint32_t unsupportedMask = SkPath::kQuad_SegmentMask | SkPath::
kCubic_SegmentMask; | 73 static const uint32_t unsupportedMask = SkPath::kQuad_SegmentMask | SkPath::
kCubic_SegmentMask; |
| 74 | 74 |
| 75 // Must not be filled nor hairline nor semi-transparent | 75 // Must not be filled nor hairline nor semi-transparent |
| 76 // Note : May require a check to path.isConvex() if AA is supported | 76 // Note : May require a check to path.isConvex() if AA is supported |
| 77 return ((stroke.getStyle() == SkStrokeRec::kStroke_Style) && (maxNbVerts < m
axVBSize) && | 77 return ((stroke.getStrokeRec()->getStyle() == SkStrokeRec::kStroke_Style) && |
| 78 !path.isInverseFillType() && isOpaque && !requiresAACircle && !antiA
lias && | 78 (maxNbVerts < maxVBSize) && !path.isInverseFillType() && isOpaque && |
| 79 ((path.getSegmentMasks() & unsupportedMask) == 0)); | 79 !requiresAACircle && !antiAlias && ((path.getSegmentMasks() & unsupp
ortedMask) == 0)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool GrStrokePathRenderer::onDrawPath(const SkPath& origPath, | 82 bool GrStrokePathRenderer::onDrawPath(const SkPath& origPath, |
| 83 const SkStrokeRec& stroke, | 83 const GrStrokeInfo& stroke, |
| 84 GrDrawTarget* target, | 84 GrDrawTarget* target, |
| 85 bool antiAlias) { | 85 bool antiAlias) { |
| 86 if (origPath.isEmpty()) { | 86 if (origPath.isEmpty()) { |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 SkScalar width = stroke.getWidth(); | 90 SkScalar width = stroke.getWidth(); |
| 91 if (width <= 0) { | 91 if (width <= 0) { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (vCount > 0) { | 291 if (vCount > 0) { |
| 292 target->drawIndexed(kTriangles_GrPrimitiveType, | 292 target->drawIndexed(kTriangles_GrPrimitiveType, |
| 293 0, // start vertex | 293 0, // start vertex |
| 294 0, // start index | 294 0, // start index |
| 295 vCount, | 295 vCount, |
| 296 iCount); | 296 iCount); |
| 297 } | 297 } |
| 298 | 298 |
| 299 return true; | 299 return true; |
| 300 } | 300 } |
| OLD | NEW |