OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
3 * 2006 Rob Buis <buis@kde.org> | 3 * 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); | 108 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); |
109 | 109 |
110 return strokePath; | 110 return strokePath; |
111 } | 111 } |
112 | 112 |
113 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData)
const | 113 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData)
const |
114 { | 114 { |
115 return strokePath(strokeData).contains(WebCoreFloatToSkScalar(point.x()), We
bCoreFloatToSkScalar(point.y())); | 115 return strokePath(strokeData).contains(WebCoreFloatToSkScalar(point.x()), We
bCoreFloatToSkScalar(point.y())); |
116 } | 116 } |
117 | 117 |
118 FloatRect Path::boundingRect() const | 118 namespace { |
| 119 |
| 120 FloatRect pathBounds(const SkPath& path, Path::BoundsType boundsType) |
119 { | 121 { |
120 return m_path.getBounds(); | 122 SkRect bounds; |
| 123 if (boundsType == Path::BoundsType::Conservative |
| 124 || !TightBounds(path, &bounds) |
| 125 || bounds.isEmpty()) // workaround for https://bugs.chromium.org/p/skia/
issues/detail?id=5555 |
| 126 return path.getBounds(); |
| 127 |
| 128 DCHECK_EQ(boundsType, Path::BoundsType::Exact); |
| 129 return bounds; |
121 } | 130 } |
122 | 131 |
123 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const | 132 } // anonymous ns |
| 133 |
| 134 // TODO(fmalita): evaluate returning exact bounds in all cases. |
| 135 FloatRect Path::boundingRect(BoundsType boundsType) const |
124 { | 136 { |
125 return strokePath(strokeData).getBounds(); | 137 return pathBounds(m_path, boundsType); |
| 138 } |
| 139 |
| 140 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData, BoundsType boun
dsType) const |
| 141 { |
| 142 return pathBounds(strokePath(strokeData), boundsType); |
126 } | 143 } |
127 | 144 |
128 static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int
count) | 145 static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int
count) |
129 { | 146 { |
130 for (int i = 0; i < count; i++) { | 147 for (int i = 0; i < count; i++) { |
131 dst[i].setX(SkScalarToFloat(src[i].fX)); | 148 dst[i].setX(SkScalarToFloat(src[i].fX)); |
132 dst[i].setY(SkScalarToFloat(src[i].fY)); | 149 dst[i].setY(SkScalarToFloat(src[i].fY)); |
133 } | 150 } |
134 return dst; | 151 return dst; |
135 } | 152 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 537 |
521 #if ENABLE(ASSERT) | 538 #if ENABLE(ASSERT) |
522 bool ellipseIsRenderable(float startAngle, float endAngle) | 539 bool ellipseIsRenderable(float startAngle, float endAngle) |
523 { | 540 { |
524 return (std::abs(endAngle - startAngle) < twoPiFloat) | 541 return (std::abs(endAngle - startAngle) < twoPiFloat) |
525 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); | 542 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); |
526 } | 543 } |
527 #endif | 544 #endif |
528 | 545 |
529 } // namespace blink | 546 } // namespace blink |
OLD | NEW |