OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "ui/gfx/path.h" | |
6 | |
7 #include <gdk/gdk.h> | |
8 | |
9 #include "base/command_line.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 | |
12 #error "The GTK+ port will be deleted later this week. If you are seeing this, y
ou are trying to compile it. Please check your gyp flags for 'use_aura=0' and re
move them." | |
13 | |
14 namespace gfx { | |
15 | |
16 GdkRegion* Path::CreateNativeRegion() const { | |
17 int point_count = getPoints(NULL, 0); | |
18 if (point_count <= 1) { | |
19 // NOTE: ideally this would return gdk_empty_region, but that returns a | |
20 // region with nothing in it. | |
21 return NULL; | |
22 } | |
23 | |
24 scoped_ptr<SkPoint[]> points(new SkPoint[point_count]); | |
25 getPoints(points.get(), point_count); | |
26 | |
27 scoped_ptr<GdkPoint[]> gdk_points(new GdkPoint[point_count]); | |
28 for (int i = 0; i < point_count; ++i) { | |
29 gdk_points[i].x = SkScalarRoundToInt(points[i].fX); | |
30 gdk_points[i].y = SkScalarRoundToInt(points[i].fY); | |
31 } | |
32 | |
33 return gdk_region_polygon(gdk_points.get(), point_count, GDK_EVEN_ODD_RULE); | |
34 } | |
35 | |
36 // static | |
37 NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) { | |
38 GdkRegion* copy = gdk_region_copy(r1); | |
39 gdk_region_intersect(copy, r2); | |
40 return copy; | |
41 } | |
42 | |
43 // static | |
44 NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) { | |
45 GdkRegion* copy = gdk_region_copy(r1); | |
46 gdk_region_union(copy, r2); | |
47 return copy; | |
48 } | |
49 | |
50 // static | |
51 NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) { | |
52 GdkRegion* copy = gdk_region_copy(r1); | |
53 gdk_region_subtract(copy, r2); | |
54 return copy; | |
55 } | |
56 | |
57 } // namespace gfx | |
OLD | NEW |