1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gfx/path.h"
9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h"
14 GdkRegion
* Path::CreateNativeRegion() const {
15 int point_count
= getPoints(NULL
, 0);
16 if (point_count
<= 1) {
17 // NOTE: ideally this would return gdk_empty_region, but that returns a
18 // region with nothing in it.
22 scoped_ptr
<SkPoint
[]> points(new SkPoint
[point_count
]);
23 getPoints(points
.get(), point_count
);
25 scoped_ptr
<GdkPoint
[]> gdk_points(new GdkPoint
[point_count
]);
26 for (int i
= 0; i
< point_count
; ++i
) {
27 gdk_points
[i
].x
= SkScalarRound(points
[i
].fX
);
28 gdk_points
[i
].y
= SkScalarRound(points
[i
].fY
);
31 return gdk_region_polygon(gdk_points
.get(), point_count
, GDK_EVEN_ODD_RULE
);
35 NativeRegion
Path::IntersectRegions(NativeRegion r1
, NativeRegion r2
) {
36 GdkRegion
* copy
= gdk_region_copy(r1
);
37 gdk_region_intersect(copy
, r2
);
42 NativeRegion
Path::CombineRegions(NativeRegion r1
, NativeRegion r2
) {
43 GdkRegion
* copy
= gdk_region_copy(r1
);
44 gdk_region_union(copy
, r2
);
49 NativeRegion
Path::SubtractRegion(NativeRegion r1
, NativeRegion r2
) {
50 GdkRegion
* copy
= gdk_region_copy(r1
);
51 gdk_region_subtract(copy
, r2
);