|
Lines 5-11
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec1
|
| 5 |
2005, 2007 Apple Inc. All Rights reserved. |
5 |
2005, 2007 Apple Inc. All Rights reserved. |
| 6 |
2007 Alp Toker <alp@atoker.com> |
6 |
2007 Alp Toker <alp@atoker.com> |
| 7 |
2008 Dirk Schulze <krit@webkit.org> |
7 |
2008 Dirk Schulze <krit@webkit.org> |
| 8 |
2011 Igalia S.L. |
8 |
2011, 2020 Igalia S.L. |
| 9 |
|
9 |
|
| 10 |
This library is free software; you can redistribute it and/or |
10 |
This library is free software; you can redistribute it and/or |
| 11 |
modify it under the terms of the GNU Library General Public |
11 |
modify it under the terms of the GNU Library General Public |
|
Lines 31-37
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec2
|
| 31 |
#include "CairoUtilities.h" |
31 |
#include "CairoUtilities.h" |
| 32 |
#include "FloatRect.h" |
32 |
#include "FloatRect.h" |
| 33 |
#include "GraphicsContextImplCairo.h" |
33 |
#include "GraphicsContextImplCairo.h" |
| 34 |
#include "PlatformPathCairo.h" |
|
|
| 35 |
#include "StrokeStyleApplier.h" |
34 |
#include "StrokeStyleApplier.h" |
| 36 |
#include <math.h> |
35 |
#include <math.h> |
| 37 |
#include <wtf/MathExtras.h> |
36 |
#include <wtf/MathExtras.h> |
|
Lines 39-78
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec3
|
| 39 |
|
38 |
|
| 40 |
namespace WebCore { |
39 |
namespace WebCore { |
| 41 |
|
40 |
|
| 42 |
Path::Path() |
41 |
Path::Path() = default; |
| 43 |
: m_path(0) |
|
|
| 44 |
{ |
| 45 |
} |
| 46 |
|
42 |
|
| 47 |
Path::~Path() |
43 |
Path::~Path() = default; |
| 48 |
{ |
44 |
|
| 49 |
if (m_path) |
45 |
Path::Path(Path&&) = default; |
| 50 |
delete m_path; |
46 |
|
| 51 |
} |
47 |
Path& Path::operator=(Path&&) = default; |
| 52 |
|
48 |
|
| 53 |
Path::Path(const Path& other) |
49 |
Path::Path(const Path& other) |
| 54 |
: m_path(0) |
|
|
| 55 |
{ |
50 |
{ |
| 56 |
if (other.isNull()) |
51 |
if (other.isNull()) |
| 57 |
return; |
52 |
return; |
| 58 |
|
53 |
|
| 59 |
cairo_t* cr = ensurePlatformPath()->context(); |
54 |
cairo_t* cr = ensureCairoPath(); |
| 60 |
auto pathCopy = cairo_copy_path(other.platformPath()->context()); |
55 |
auto pathCopy = cairo_copy_path(other.m_path.get()); |
| 61 |
cairo_append_path(cr, pathCopy); |
56 |
cairo_append_path(cr, pathCopy); |
| 62 |
cairo_path_destroy(pathCopy); |
57 |
cairo_path_destroy(pathCopy); |
| 63 |
} |
58 |
} |
| 64 |
|
|
|
| 65 |
Path::Path(Path&& other) |
| 66 |
{ |
| 67 |
m_path = other.m_path; |
| 68 |
other.m_path = nullptr; |
| 69 |
} |
| 70 |
|
59 |
|
| 71 |
PlatformPathPtr Path::ensurePlatformPath() |
60 |
cairo_t* Path::ensureCairoPath() |
| 72 |
{ |
61 |
{ |
| 73 |
if (!m_path) |
62 |
if (!m_path) |
| 74 |
m_path = new CairoPath(); |
63 |
m_path = adoptRef(cairo_create(adoptRef(cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1)).get())); |
| 75 |
return m_path; |
64 |
return m_path.get(); |
| 76 |
} |
65 |
} |
| 77 |
|
66 |
|
| 78 |
Path& Path::operator=(const Path& other) |
67 |
Path& Path::operator=(const Path& other) |
|
Lines 81-109
Path& Path::operator=(const Path& other)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec4
|
| 81 |
return *this; |
70 |
return *this; |
| 82 |
|
71 |
|
| 83 |
if (other.isNull()) { |
72 |
if (other.isNull()) { |
| 84 |
if (m_path) { |
73 |
m_path = nullptr; |
| 85 |
delete m_path; |
74 |
return *this; |
| 86 |
m_path = 0; |
|
|
| 87 |
} |
| 88 |
} else { |
| 89 |
clear(); |
| 90 |
cairo_t* cr = ensurePlatformPath()->context(); |
| 91 |
auto pathCopy = cairo_copy_path(other.platformPath()->context()); |
| 92 |
cairo_append_path(cr, pathCopy); |
| 93 |
cairo_path_destroy(pathCopy); |
| 94 |
} |
75 |
} |
| 95 |
|
76 |
|
| 96 |
return *this; |
77 |
clear(); |
| 97 |
} |
78 |
cairo_t* cr = ensureCairoPath(); |
| 98 |
|
79 |
auto pathCopy = cairo_copy_path(other.m_path.get()); |
| 99 |
Path& Path::operator=(Path&& other) |
80 |
cairo_append_path(cr, pathCopy); |
| 100 |
{ |
81 |
cairo_path_destroy(pathCopy); |
| 101 |
if (this == &other) |
82 |
|
| 102 |
return *this; |
|
|
| 103 |
if (m_path) |
| 104 |
delete m_path; |
| 105 |
m_path = other.m_path; |
| 106 |
other.m_path = nullptr; |
| 107 |
return *this; |
83 |
return *this; |
| 108 |
} |
84 |
} |
| 109 |
|
85 |
|
|
Lines 112-125
void Path::clear()
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec5
|
| 112 |
if (isNull()) |
88 |
if (isNull()) |
| 113 |
return; |
89 |
return; |
| 114 |
|
90 |
|
| 115 |
cairo_t* cr = platformPath()->context(); |
91 |
cairo_identity_matrix(m_path.get()); |
| 116 |
cairo_identity_matrix(cr); |
92 |
cairo_new_path(m_path.get()); |
| 117 |
cairo_new_path(cr); |
|
|
| 118 |
} |
93 |
} |
| 119 |
|
94 |
|
| 120 |
bool Path::isEmptySlowCase() const |
95 |
bool Path::isEmptySlowCase() const |
| 121 |
{ |
96 |
{ |
| 122 |
return !cairo_has_current_point(platformPath()->context()); |
97 |
return !cairo_has_current_point(m_path.get()); |
| 123 |
} |
98 |
} |
| 124 |
|
99 |
|
| 125 |
FloatPoint Path::currentPointSlowCase() const |
100 |
FloatPoint Path::currentPointSlowCase() const |
|
Lines 127-189
FloatPoint Path::currentPointSlowCase() const
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec6
|
| 127 |
// FIXME: Is this the correct way? |
102 |
// FIXME: Is this the correct way? |
| 128 |
double x; |
103 |
double x; |
| 129 |
double y; |
104 |
double y; |
| 130 |
cairo_get_current_point(platformPath()->context(), &x, &y); |
105 |
cairo_get_current_point(m_path.get(), &x, &y); |
| 131 |
return FloatPoint(x, y); |
106 |
return FloatPoint(x, y); |
| 132 |
} |
107 |
} |
| 133 |
|
108 |
|
| 134 |
void Path::translate(const FloatSize& p) |
109 |
void Path::translate(const FloatSize& p) |
| 135 |
{ |
110 |
{ |
| 136 |
cairo_t* cr = ensurePlatformPath()->context(); |
111 |
cairo_translate(ensureCairoPath(), -p.width(), -p.height()); |
| 137 |
cairo_translate(cr, -p.width(), -p.height()); |
|
|
| 138 |
} |
112 |
} |
| 139 |
|
113 |
|
| 140 |
void Path::moveToSlowCase(const FloatPoint& p) |
114 |
void Path::moveToSlowCase(const FloatPoint& p) |
| 141 |
{ |
115 |
{ |
| 142 |
cairo_t* cr = ensurePlatformPath()->context(); |
116 |
cairo_move_to(ensureCairoPath(), p.x(), p.y()); |
| 143 |
cairo_move_to(cr, p.x(), p.y()); |
|
|
| 144 |
} |
117 |
} |
| 145 |
|
118 |
|
| 146 |
void Path::addLineToSlowCase(const FloatPoint& p) |
119 |
void Path::addLineToSlowCase(const FloatPoint& p) |
| 147 |
{ |
120 |
{ |
| 148 |
cairo_t* cr = ensurePlatformPath()->context(); |
121 |
cairo_line_to(ensureCairoPath(), p.x(), p.y()); |
| 149 |
cairo_line_to(cr, p.x(), p.y()); |
|
|
| 150 |
} |
122 |
} |
| 151 |
|
123 |
|
| 152 |
void Path::addRect(const FloatRect& rect) |
124 |
void Path::addRect(const FloatRect& rect) |
| 153 |
{ |
125 |
{ |
| 154 |
cairo_t* cr = ensurePlatformPath()->context(); |
126 |
cairo_rectangle(ensureCairoPath(), rect.x(), rect.y(), rect.width(), rect.height()); |
| 155 |
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); |
|
|
| 156 |
} |
127 |
} |
| 157 |
|
128 |
|
| 158 |
/* |
|
|
| 159 |
* inspired by libsvg-cairo |
| 160 |
*/ |
| 161 |
void Path::addQuadCurveToSlowCase(const FloatPoint& controlPoint, const FloatPoint& point) |
129 |
void Path::addQuadCurveToSlowCase(const FloatPoint& controlPoint, const FloatPoint& point) |
| 162 |
{ |
130 |
{ |
| 163 |
cairo_t* cr = ensurePlatformPath()->context(); |
|
|
| 164 |
double x, y; |
131 |
double x, y; |
| 165 |
double x1 = controlPoint.x(); |
132 |
double x1 = controlPoint.x(); |
| 166 |
double y1 = controlPoint.y(); |
133 |
double y1 = controlPoint.y(); |
| 167 |
double x2 = point.x(); |
134 |
double x2 = point.x(); |
| 168 |
double y2 = point.y(); |
135 |
double y2 = point.y(); |
|
|
136 |
cairo_t* cr = ensureCairoPath(); |
| 169 |
cairo_get_current_point(cr, &x, &y); |
137 |
cairo_get_current_point(cr, &x, &y); |
| 170 |
cairo_curve_to(cr, |
138 |
cairo_curve_to(cr, |
| 171 |
x + 2.0 / 3.0 * (x1 - x), y + 2.0 / 3.0 * (y1 - y), |
139 |
x + 2.0 / 3.0 * (x1 - x), y + 2.0 / 3.0 * (y1 - y), |
| 172 |
x2 + 2.0 / 3.0 * (x1 - x2), y2 + 2.0 / 3.0 * (y1 - y2), |
140 |
x2 + 2.0 / 3.0 * (x1 - x2), y2 + 2.0 / 3.0 * (y1 - y2), |
| 173 |
x2, y2); |
141 |
x2, y2); |
| 174 |
} |
142 |
} |
| 175 |
|
143 |
|
| 176 |
void Path::addBezierCurveToSlowCase(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3) |
144 |
void Path::addBezierCurveToSlowCase(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3) |
| 177 |
{ |
145 |
{ |
| 178 |
cairo_t* cr = ensurePlatformPath()->context(); |
146 |
cairo_curve_to(ensureCairoPath(), controlPoint1.x(), controlPoint1.y(), |
| 179 |
cairo_curve_to(cr, controlPoint1.x(), controlPoint1.y(), |
147 |
controlPoint2.x(), controlPoint2.y(), controlPoint3.x(), controlPoint3.y()); |
| 180 |
controlPoint2.x(), controlPoint2.y(), |
|
|
| 181 |
controlPoint3.x(), controlPoint3.y()); |
| 182 |
} |
148 |
} |
| 183 |
|
149 |
|
| 184 |
void Path::addArcSlowCase(const FloatPoint& p, float r, float startAngle, float endAngle, bool anticlockwise) |
150 |
void Path::addArcSlowCase(const FloatPoint& p, float r, float startAngle, float endAngle, bool anticlockwise) |
| 185 |
{ |
151 |
{ |
| 186 |
cairo_t* cr = ensurePlatformPath()->context(); |
152 |
cairo_t* cr = ensureCairoPath(); |
| 187 |
float sweep = endAngle - startAngle; |
153 |
float sweep = endAngle - startAngle; |
| 188 |
const float twoPI = 2 * piFloat; |
154 |
const float twoPI = 2 * piFloat; |
| 189 |
if ((sweep <= -twoPI || sweep >= twoPI) |
155 |
if ((sweep <= -twoPI || sweep >= twoPI) |
|
Lines 213-229
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec7
|
| 213 |
if (isEmpty()) |
179 |
if (isEmpty()) |
| 214 |
return; |
180 |
return; |
| 215 |
|
181 |
|
| 216 |
cairo_t* cr = platformPath()->context(); |
|
|
| 217 |
|
| 218 |
double x0, y0; |
182 |
double x0, y0; |
| 219 |
cairo_get_current_point(cr, &x0, &y0); |
183 |
cairo_get_current_point(m_path.get(), &x0, &y0); |
| 220 |
FloatPoint p0(x0, y0); |
184 |
FloatPoint p0(x0, y0); |
| 221 |
|
185 |
|
| 222 |
// Draw only a straight line to p1 if any of the points are equal or the radius is zero |
186 |
// Draw only a straight line to p1 if any of the points are equal or the radius is zero |
| 223 |
// or the points are collinear (triangle that the points form has area of zero value). |
187 |
// or the points are collinear (triangle that the points form has area of zero value). |
| 224 |
if ((p1.x() == p0.x() && p1.y() == p0.y()) || (p1.x() == p2.x() && p1.y() == p2.y()) || !radius |
188 |
if ((p1.x() == p0.x() && p1.y() == p0.y()) || (p1.x() == p2.x() && p1.y() == p2.y()) || !radius |
| 225 |
|| !areaOfTriangleFormedByPoints(p0, p1, p2)) { |
189 |
|| !areaOfTriangleFormedByPoints(p0, p1, p2)) { |
| 226 |
cairo_line_to(cr, p1.x(), p1.y()); |
190 |
cairo_line_to(m_path.get(), p1.x(), p1.y()); |
| 227 |
return; |
191 |
return; |
| 228 |
} |
192 |
} |
| 229 |
|
193 |
|
|
Lines 231-241
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec8
|
| 231 |
FloatPoint p1p2((p2.x() - p1.x()),(p2.y() - p1.y())); |
195 |
FloatPoint p1p2((p2.x() - p1.x()),(p2.y() - p1.y())); |
| 232 |
float p1p0_length = std::hypot(p1p0.x(), p1p0.y()); |
196 |
float p1p0_length = std::hypot(p1p0.x(), p1p0.y()); |
| 233 |
float p1p2_length = std::hypot(p1p2.x(), p1p2.y()); |
197 |
float p1p2_length = std::hypot(p1p2.x(), p1p2.y()); |
| 234 |
|
|
|
| 235 |
double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length); |
198 |
double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length); |
| 236 |
// all points on a line logic |
199 |
// all points on a line logic |
| 237 |
if (cos_phi == -1) { |
200 |
if (cos_phi == -1) { |
| 238 |
cairo_line_to(cr, p1.x(), p1.y()); |
201 |
cairo_line_to(m_path.get(), p1.x(), p1.y()); |
| 239 |
return; |
202 |
return; |
| 240 |
} |
203 |
} |
| 241 |
if (cos_phi == 1) { |
204 |
if (cos_phi == 1) { |
|
Lines 243-249
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec9
|
| 243 |
unsigned int max_length = 65535; |
206 |
unsigned int max_length = 65535; |
| 244 |
double factor_max = max_length / p1p0_length; |
207 |
double factor_max = max_length / p1p0_length; |
| 245 |
FloatPoint ep((p0.x() + factor_max * p1p0.x()), (p0.y() + factor_max * p1p0.y())); |
208 |
FloatPoint ep((p0.x() + factor_max * p1p0.x()), (p0.y() + factor_max * p1p0.y())); |
| 246 |
cairo_line_to(cr, ep.x(), ep.y()); |
209 |
cairo_line_to(m_path.get(), ep.x(), ep.y()); |
| 247 |
return; |
210 |
return; |
| 248 |
} |
211 |
} |
| 249 |
|
212 |
|
|
Lines 283-296
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec10
|
| 283 |
if ((sa < ea) && ((ea - sa) > piDouble)) |
246 |
if ((sa < ea) && ((ea - sa) > piDouble)) |
| 284 |
anticlockwise = true; |
247 |
anticlockwise = true; |
| 285 |
|
248 |
|
| 286 |
cairo_line_to(cr, t_p1p0.x(), t_p1p0.y()); |
249 |
cairo_line_to(m_path.get(), t_p1p0.x(), t_p1p0.y()); |
| 287 |
|
250 |
|
| 288 |
addArc(p, radius, sa, ea, anticlockwise); |
251 |
addArc(p, radius, sa, ea, anticlockwise); |
| 289 |
} |
252 |
} |
| 290 |
|
253 |
|
| 291 |
void Path::addEllipse(FloatPoint point, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise) |
254 |
void Path::addEllipse(FloatPoint point, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise) |
| 292 |
{ |
255 |
{ |
| 293 |
cairo_t* cr = ensurePlatformPath()->context(); |
256 |
cairo_t* cr = ensureCairoPath(); |
| 294 |
cairo_save(cr); |
257 |
cairo_save(cr); |
| 295 |
cairo_translate(cr, point.x(), point.y()); |
258 |
cairo_translate(cr, point.x(), point.y()); |
| 296 |
cairo_rotate(cr, rotation); |
259 |
cairo_rotate(cr, rotation); |
|
Lines 306-312
void Path::addEllipse(FloatPoint point, float radiusX, float radiusY, float rota
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec11
|
| 306 |
|
269 |
|
| 307 |
void Path::addEllipse(const FloatRect& rect) |
270 |
void Path::addEllipse(const FloatRect& rect) |
| 308 |
{ |
271 |
{ |
| 309 |
cairo_t* cr = ensurePlatformPath()->context(); |
272 |
cairo_t* cr = ensureCairoPath(); |
| 310 |
cairo_save(cr); |
273 |
cairo_save(cr); |
| 311 |
float yRadius = .5 * rect.height(); |
274 |
float yRadius = .5 * rect.height(); |
| 312 |
float xRadius = .5 * rect.width(); |
275 |
float xRadius = .5 * rect.width(); |
|
Lines 325-350
void Path::addPath(const Path& path, const AffineTransform& transform)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec12
|
| 325 |
if (cairo_matrix_invert(&matrix) != CAIRO_STATUS_SUCCESS) |
288 |
if (cairo_matrix_invert(&matrix) != CAIRO_STATUS_SUCCESS) |
| 326 |
return; |
289 |
return; |
| 327 |
|
290 |
|
| 328 |
cairo_t* cr = path.platformPath()->context(); |
291 |
cairo_t* cr = path.cairoPath(); |
| 329 |
cairo_save(cr); |
292 |
cairo_save(cr); |
| 330 |
cairo_transform(cr, &matrix); |
293 |
cairo_transform(cr, &matrix); |
| 331 |
auto pathCopy = cairo_copy_path(cr); |
294 |
auto pathCopy = cairo_copy_path(cr); |
| 332 |
cairo_restore(cr); |
295 |
cairo_restore(cr); |
| 333 |
cairo_append_path(ensurePlatformPath()->context(), pathCopy); |
296 |
cairo_append_path(ensureCairoPath(), pathCopy); |
| 334 |
cairo_path_destroy(pathCopy); |
297 |
cairo_path_destroy(pathCopy); |
| 335 |
} |
298 |
} |
| 336 |
|
299 |
|
| 337 |
void Path::closeSubpath() |
300 |
void Path::closeSubpath() |
| 338 |
{ |
301 |
{ |
| 339 |
cairo_t* cr = ensurePlatformPath()->context(); |
302 |
cairo_close_path(ensureCairoPath()); |
| 340 |
cairo_close_path(cr); |
|
|
| 341 |
} |
303 |
} |
| 342 |
|
304 |
|
| 343 |
FloatRect Path::boundingRectSlowCase() const |
305 |
FloatRect Path::boundingRectSlowCase() const |
| 344 |
{ |
306 |
{ |
| 345 |
cairo_t* cr = platformPath()->context(); |
|
|
| 346 |
double x0, x1, y0, y1; |
307 |
double x0, x1, y0, y1; |
| 347 |
cairo_path_extents(cr, &x0, &y0, &x1, &y1); |
308 |
cairo_path_extents(m_path.get(), &x0, &y0, &x1, &y1); |
| 348 |
return FloatRect(x0, y0, x1 - x0, y1 - y0); |
309 |
return FloatRect(x0, y0, x1 - x0, y1 - y0); |
| 349 |
} |
310 |
} |
| 350 |
|
311 |
|
|
Lines 354-367
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec13
|
| 354 |
if (isNull()) |
315 |
if (isNull()) |
| 355 |
return FloatRect(); |
316 |
return FloatRect(); |
| 356 |
|
317 |
|
| 357 |
cairo_t* cr = platformPath()->context(); |
|
|
| 358 |
if (applier) { |
318 |
if (applier) { |
| 359 |
GraphicsContext gc(GraphicsContextImplCairo::createFactory(cr)); |
319 |
GraphicsContext gc(GraphicsContextImplCairo::createFactory(m_path.get())); |
| 360 |
applier->strokeStyle(&gc); |
320 |
applier->strokeStyle(&gc); |
| 361 |
} |
321 |
} |
| 362 |
|
322 |
|
| 363 |
double x0, x1, y0, y1; |
323 |
double x0, x1, y0, y1; |
| 364 |
cairo_stroke_extents(cr, &x0, &y0, &x1, &y1); |
324 |
cairo_stroke_extents(m_path.get(), &x0, &y0, &x1, &y1); |
| 365 |
return FloatRect(x0, y0, x1 - x0, y1 - y0); |
325 |
return FloatRect(x0, y0, x1 - x0, y1 - y0); |
| 366 |
} |
326 |
} |
| 367 |
|
327 |
|
|
Lines 369-379
bool Path::contains(const FloatPoint& point, WindRule rule) const
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec14
|
| 369 |
{ |
329 |
{ |
| 370 |
if (isNull() || !std::isfinite(point.x()) || !std::isfinite(point.y())) |
330 |
if (isNull() || !std::isfinite(point.x()) || !std::isfinite(point.y())) |
| 371 |
return false; |
331 |
return false; |
| 372 |
cairo_t* cr = platformPath()->context(); |
332 |
|
| 373 |
cairo_fill_rule_t cur = cairo_get_fill_rule(cr); |
333 |
cairo_fill_rule_t cur = cairo_get_fill_rule(m_path.get()); |
| 374 |
cairo_set_fill_rule(cr, rule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); |
334 |
cairo_set_fill_rule(m_path.get(), rule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); |
| 375 |
bool contains = cairo_in_fill(cr, point.x(), point.y()); |
335 |
bool contains = cairo_in_fill(m_path.get(), point.x(), point.y()); |
| 376 |
cairo_set_fill_rule(cr, cur); |
336 |
cairo_set_fill_rule(m_path.get(), cur); |
| 377 |
return contains; |
337 |
return contains; |
| 378 |
} |
338 |
} |
| 379 |
|
339 |
|
|
Lines 382-400
bool Path::strokeContains(StrokeStyleApplier& applier, const FloatPoint& point)
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec15
|
| 382 |
if (isNull()) |
342 |
if (isNull()) |
| 383 |
return false; |
343 |
return false; |
| 384 |
|
344 |
|
| 385 |
cairo_t* cr = platformPath()->context(); |
|
|
| 386 |
{ |
345 |
{ |
| 387 |
GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cr)); |
346 |
GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(m_path.get())); |
| 388 |
applier.strokeStyle(&graphicsContext); |
347 |
applier.strokeStyle(&graphicsContext); |
| 389 |
} |
348 |
} |
| 390 |
|
349 |
|
| 391 |
return cairo_in_stroke(cr, point.x(), point.y()); |
350 |
return cairo_in_stroke(m_path.get(), point.x(), point.y()); |
| 392 |
} |
351 |
} |
| 393 |
|
352 |
|
| 394 |
void Path::applySlowCase(const PathApplierFunction& function) const |
353 |
void Path::applySlowCase(const PathApplierFunction& function) const |
| 395 |
{ |
354 |
{ |
| 396 |
cairo_t* cr = platformPath()->context(); |
355 |
auto pathCopy = cairo_copy_path(m_path.get()); |
| 397 |
auto pathCopy = cairo_copy_path(cr); |
|
|
| 398 |
cairo_path_data_t* data; |
356 |
cairo_path_data_t* data; |
| 399 |
PathElement pathElement; |
357 |
PathElement pathElement; |
| 400 |
|
358 |
|
|
Lines 434-443
FloatRect Path::fastBoundingRectSlowCase() const
a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp_sec16
|
| 434 |
|
392 |
|
| 435 |
void Path::transform(const AffineTransform& transform) |
393 |
void Path::transform(const AffineTransform& transform) |
| 436 |
{ |
394 |
{ |
| 437 |
cairo_t* cr = ensurePlatformPath()->context(); |
|
|
| 438 |
cairo_matrix_t matrix = toCairoMatrix(transform); |
395 |
cairo_matrix_t matrix = toCairoMatrix(transform); |
| 439 |
cairo_matrix_invert(&matrix); |
396 |
cairo_matrix_invert(&matrix); |
| 440 |
cairo_transform(cr, &matrix); |
397 |
cairo_transform(ensureCairoPath(), &matrix); |
| 441 |
} |
398 |
} |
| 442 |
|
399 |
|
| 443 |
bool Path::isNull() const |
400 |
bool Path::isNull() const |