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

Unified Diff: ui/gfx/path_mac.mm

Issue 1718043003: MacViews: Clip contents for non-rectangular windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698