Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: Source/platform/graphics/Path.cpp

Issue 1144353005: [SVG] Lower stroke hit testing resolution. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: +2 mac expectations Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/graphics/Path.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool Path::operator==(const Path& other) const 64 bool Path::operator==(const Path& other) const
65 { 65 {
66 return m_path == other.m_path; 66 return m_path == other.m_path;
67 } 67 }
68 68
69 bool Path::contains(const FloatPoint& point, WindRule rule) const 69 bool Path::contains(const FloatPoint& point, WindRule rule) const
70 { 70 {
71 return SkPathContainsPoint(m_path, point, static_cast<SkPath::FillType>(rule )); 71 return SkPathContainsPoint(m_path, point, static_cast<SkPath::FillType>(rule ));
72 } 72 }
73 73
74 // FIXME: this method ignores the CTM and may yield inaccurate results for large scales.
75 SkPath Path::strokePath(const StrokeData& strokeData) const
76 {
77 SkPaint paint;
78 strokeData.setupPaint(&paint);
79
80 // Skia stroke resolution scale. This is multiplied by 4 internally
81 // (i.e. 1.0 corresponds to 1/4 pixel res).
82 static const SkScalar kResScale = 0.3f;
83
84 SkPath strokePath;
85 paint.getFillPath(m_path, &strokePath, nullptr, kResScale);
86
87 return strokePath;
88 }
89
74 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const 90 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const
75 { 91 {
76 SkPaint paint; 92 return SkPathContainsPoint(strokePath(strokeData), point, SkPath::kWinding_F illType);
77 strokeData.setupPaint(&paint);
78 SkPath strokePath;
79 paint.getFillPath(m_path, &strokePath);
80
81 return SkPathContainsPoint(strokePath, point, SkPath::kWinding_FillType);
82 } 93 }
83 94
84 FloatRect Path::boundingRect() const 95 FloatRect Path::boundingRect() const
85 { 96 {
86 return m_path.getBounds(); 97 return m_path.getBounds();
87 } 98 }
88 99
89 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const 100 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const
90 { 101 {
91 SkPaint paint; 102 return strokePath(strokeData).getBounds();
92 strokeData.setupPaint(&paint);
93 SkPath boundingPath;
94 paint.getFillPath(m_path, &boundingPath);
95
96 return boundingPath.getBounds();
97 } 103 }
98 104
99 static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int count) 105 static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int count)
100 { 106 {
101 for (int i = 0; i < count; i++) { 107 for (int i = 0; i < count; i++) {
102 dst[i].setX(SkScalarToFloat(src[i].fX)); 108 dst[i].setX(SkScalarToFloat(src[i].fX));
103 dst[i].setY(SkScalarToFloat(src[i].fY)); 109 dst[i].setY(SkScalarToFloat(src[i].fY));
104 } 110 }
105 return dst; 111 return dst;
106 } 112 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 512
507 #if ENABLE(ASSERT) 513 #if ENABLE(ASSERT)
508 bool ellipseIsRenderable(float startAngle, float endAngle) 514 bool ellipseIsRenderable(float startAngle, float endAngle)
509 { 515 {
510 return (std::abs(endAngle - startAngle) < twoPiFloat) 516 return (std::abs(endAngle - startAngle) < twoPiFloat)
511 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); 517 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat);
512 } 518 }
513 #endif 519 #endif
514 520
515 } // namespace blink 521 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698