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
3 // found in the LICENSE file.
5 #include "ui/gfx/path_x11.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/path.h"
14 Region
CreateRegionFromSkPath(const SkPath
& path
) {
15 int point_count
= path
.getPoints(NULL
, 0);
16 scoped_ptr
<SkPoint
[]> points(new SkPoint
[point_count
]);
17 path
.getPoints(points
.get(), point_count
);
18 scoped_ptr
<XPoint
[]> x11_points(new XPoint
[point_count
]);
19 for (int i
= 0; i
< point_count
; ++i
) {
20 x11_points
[i
].x
= SkScalarRound(points
[i
].fX
);
21 x11_points
[i
].y
= SkScalarRound(points
[i
].fY
);
24 return XPolygonRegion(x11_points
.get(), point_count
, EvenOddRule
);