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.
4
5#include "ui/gfx/path_x11.h"
6
7#include <X11/Xutil.h>
8
9#include "base/memory/scoped_ptr.h"
10#include "ui/gfx/path.h"
11
12namespace gfx {
13
14Region 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);
22  }
23
24  return XPolygonRegion(x11_points.get(), point_count, EvenOddRule);
25}
26
27}  // namespace gfx
28