Chromium Code Reviews| Index: ui/gfx/path_mac.mm |
| diff --git a/ui/gfx/path_mac.mm b/ui/gfx/path_mac.mm |
| index 109f80741f4099ceea697953ac425e92719ed7de..711759469c23da01618581b0cdc3e0a5d5265ab1 100644 |
| --- a/ui/gfx/path_mac.mm |
| +++ b/ui/gfx/path_mac.mm |
| @@ -4,8 +4,6 @@ |
| #import "ui/gfx/path_mac.h" |
| -#import <Cocoa/Cocoa.h> |
| - |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/gfx/path.h" |
| @@ -122,4 +120,42 @@ NSBezierPath* CreateNSBezierPathFromSkPath(const SkPath& path) { |
| return result; |
| } |
| +base::ScopedCFTypeRef<CGPathRef> CreateCGPathFromNSBezierPath( |
|
karandeepb
2016/02/24 04:27:18
This is slightly inspired from https://developer.a
tapted
2016/02/24 05:05:03
I think you can do
#import "third_party/google_to
karandeepb
2016/02/25 03:31:06
Done. Weird that the src folder doesn't show up on
|
| + NSBezierPath* path) { |
| + base::ScopedCFTypeRef<CGMutablePathRef> result(CGPathCreateMutable()); |
| + NSPoint points[3]; |
| + bool path_closed = true; |
| + for (int i = 0; i < [path elementCount]; i++) { |
| + switch ([path elementAtIndex:i associatedPoints:points]) { |
| + case NSMoveToBezierPathElement: |
| + CGPathMoveToPoint(result, nullptr, points[0].x, points[0].y); |
| + break; |
| + |
| + case NSLineToBezierPathElement: |
| + CGPathAddLineToPoint(result, nullptr, points[0].x, points[0].y); |
| + path_closed = false; |
| + break; |
| + |
| + case NSCurveToBezierPathElement: |
| + CGPathAddCurveToPoint(result, nullptr, points[0].x, points[0].y, |
| + points[1].x, points[1].y, points[2].x, |
| + points[2].y); |
| + path_closed = false; |
| + break; |
| + |
| + case NSClosePathBezierPathElement: |
| + CGPathCloseSubpath(result); |
| + path_closed = true; |
| + break; |
| + } |
| + } |
| + |
| + // For valid hit detection, path must be closed. |
| + if (!path_closed) |
| + CGPathCloseSubpath(result); |
| + |
| + // Return immutable copy of result. |
| + return base::ScopedCFTypeRef<CGPathRef>(CGPathCreateCopy(result)); |
| +} |
| + |
| } // namespace gfx |