OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/path_x11.h" | 5 #include "ui/gfx/path_x11.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include <memory> |
| 12 |
12 #include "third_party/skia/include/core/SkRegion.h" | 13 #include "third_party/skia/include/core/SkRegion.h" |
13 #include "ui/gfx/path.h" | 14 #include "ui/gfx/path.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 | 17 |
17 Region CreateRegionFromSkRegion(const SkRegion& region) { | 18 Region CreateRegionFromSkRegion(const SkRegion& region) { |
18 Region result = XCreateRegion(); | 19 Region result = XCreateRegion(); |
19 | 20 |
20 for (SkRegion::Iterator i(region); !i.done(); i.next()) { | 21 for (SkRegion::Iterator i(region); !i.done(); i.next()) { |
21 XRectangle rect; | 22 XRectangle rect; |
22 rect.x = i.rect().x(); | 23 rect.x = i.rect().x(); |
23 rect.y = i.rect().y(); | 24 rect.y = i.rect().y(); |
24 rect.width = i.rect().width(); | 25 rect.width = i.rect().width(); |
25 rect.height = i.rect().height(); | 26 rect.height = i.rect().height(); |
26 XUnionRectWithRegion(&rect, result, result); | 27 XUnionRectWithRegion(&rect, result, result); |
27 } | 28 } |
28 | 29 |
29 return result; | 30 return result; |
30 } | 31 } |
31 | 32 |
32 Region CreateRegionFromSkPath(const SkPath& path) { | 33 Region CreateRegionFromSkPath(const SkPath& path) { |
33 int point_count = path.getPoints(NULL, 0); | 34 int point_count = path.getPoints(NULL, 0); |
34 scoped_ptr<SkPoint[]> points(new SkPoint[point_count]); | 35 std::unique_ptr<SkPoint[]> points(new SkPoint[point_count]); |
35 path.getPoints(points.get(), point_count); | 36 path.getPoints(points.get(), point_count); |
36 scoped_ptr<XPoint[]> x11_points(new XPoint[point_count]); | 37 std::unique_ptr<XPoint[]> x11_points(new XPoint[point_count]); |
37 for (int i = 0; i < point_count; ++i) { | 38 for (int i = 0; i < point_count; ++i) { |
38 x11_points[i].x = SkScalarRoundToInt(points[i].fX); | 39 x11_points[i].x = SkScalarRoundToInt(points[i].fX); |
39 x11_points[i].y = SkScalarRoundToInt(points[i].fY); | 40 x11_points[i].y = SkScalarRoundToInt(points[i].fY); |
40 } | 41 } |
41 | 42 |
42 return XPolygonRegion(x11_points.get(), point_count, EvenOddRule); | 43 return XPolygonRegion(x11_points.get(), point_count, EvenOddRule); |
43 } | 44 } |
44 | 45 |
45 } // namespace gfx | 46 } // namespace gfx |
OLD | NEW |