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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 return *this; | 67 return *this; |
68 } | 68 } |
69 | 69 |
70 bool Path::operator==(const Path& other) const | 70 bool Path::operator==(const Path& other) const |
71 { | 71 { |
72 return m_path == other.m_path; | 72 return m_path == other.m_path; |
73 } | 73 } |
74 | 74 |
75 bool Path::contains(const FloatPoint& point) const | 75 bool Path::contains(const FloatPoint& point) const |
76 { | 76 { |
77 return SkPathContainsPoint(m_path, point, m_path.getFillType()); | 77 return m_path.contains(WebCoreFloatToSkScalar(point.x()), WebCoreFloatToSkSc alar(point.y())); |
78 } | 78 } |
79 | 79 |
80 bool Path::contains(const FloatPoint& point, WindRule rule) const | 80 bool Path::contains(const FloatPoint& point, WindRule rule) const |
81 { | 81 { |
82 return SkPathContainsPoint(m_path, point, WebCoreWindRuleToSkFillType(rule)) ; | 82 SkPath::FillType previousFillType = m_path.getFillType(); |
83 const_cast<SkPath&>(m_path).setFillType(WebCoreWindRuleToSkFillType(rule)); | |
fs
2015/12/18 15:43:44
Yes, this is pretty horrendous...
f(malita)
2015/12/18 15:56:22
How about something like
if (WebCoreWindRuleToS
fs
2015/12/18 16:48:02
Yes, maybe that's a reasonable trade-off - hopeful
| |
84 bool isInside = m_path.contains(WebCoreFloatToSkScalar(point.x()), WebCoreFl oatToSkScalar(point.y())); | |
85 const_cast<SkPath&>(m_path).setFillType(previousFillType); | |
86 return isInside; | |
83 } | 87 } |
84 | 88 |
85 // FIXME: this method ignores the CTM and may yield inaccurate results for large scales. | 89 // FIXME: this method ignores the CTM and may yield inaccurate results for large scales. |
86 SkPath Path::strokePath(const StrokeData& strokeData) const | 90 SkPath Path::strokePath(const StrokeData& strokeData) const |
87 { | 91 { |
88 SkPaint paint; | 92 SkPaint paint; |
89 strokeData.setupPaint(&paint); | 93 strokeData.setupPaint(&paint); |
90 | 94 |
91 // Skia stroke resolution scale. This is multiplied by 4 internally | 95 // Skia stroke resolution scale. This is multiplied by 4 internally |
92 // (i.e. 1.0 corresponds to 1/4 pixel res). | 96 // (i.e. 1.0 corresponds to 1/4 pixel res). |
93 static const SkScalar kResScale = 0.3f; | 97 static const SkScalar kResScale = 0.3f; |
94 | 98 |
95 SkPath strokePath; | 99 SkPath strokePath; |
96 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); | 100 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); |
97 | 101 |
98 return strokePath; | 102 return strokePath; |
99 } | 103 } |
100 | 104 |
101 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const | 105 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const |
102 { | 106 { |
103 return SkPathContainsPoint(strokePath(strokeData), point, SkPath::kWinding_F illType); | 107 return strokePath(strokeData).contains(WebCoreFloatToSkScalar(point.x()), We bCoreFloatToSkScalar(point.y())); |
104 } | 108 } |
105 | 109 |
106 FloatRect Path::boundingRect() const | 110 FloatRect Path::boundingRect() const |
107 { | 111 { |
108 return m_path.getBounds(); | 112 return m_path.getBounds(); |
109 } | 113 } |
110 | 114 |
111 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const | 115 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const |
112 { | 116 { |
113 return strokePath(strokeData).getBounds(); | 117 return strokePath(strokeData).getBounds(); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 | 492 |
489 #if ENABLE(ASSERT) | 493 #if ENABLE(ASSERT) |
490 bool ellipseIsRenderable(float startAngle, float endAngle) | 494 bool ellipseIsRenderable(float startAngle, float endAngle) |
491 { | 495 { |
492 return (std::abs(endAngle - startAngle) < twoPiFloat) | 496 return (std::abs(endAngle - startAngle) < twoPiFloat) |
493 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); | 497 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); |
494 } | 498 } |
495 #endif | 499 #endif |
496 | 500 |
497 } // namespace blink | 501 } // namespace blink |
OLD | NEW |