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_win.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "ui/gfx/path.h"
12 HRGN
CreateHRGNFromSkPath(const SkPath
& path
) {
13 int point_count
= path
.getPoints(NULL
, 0);
14 scoped_ptr
<SkPoint
[]> points(new SkPoint
[point_count
]);
15 path
.getPoints(points
.get(), point_count
);
16 scoped_ptr
<POINT
[]> windows_points(new POINT
[point_count
]);
17 for (int i
= 0; i
< point_count
; ++i
) {
18 windows_points
[i
].x
= SkScalarRound(points
[i
].fX
);
19 windows_points
[i
].y
= SkScalarRound(points
[i
].fY
);
22 return ::CreatePolygonRgn(windows_points
.get(), point_count
, ALTERNATE
);
25 // See path_aura.cc for Aura definition of these methods:
26 #if !defined(USE_AURA)
28 NativeRegion
Path::CreateNativeRegion() const {
29 return CreateHRGNFromSkPath(*this);
33 NativeRegion
Path::IntersectRegions(NativeRegion r1
, NativeRegion r2
) {
34 HRGN dest
= CreateRectRgn(0, 0, 1, 1);
35 CombineRgn(dest
, r1
, r2
, RGN_AND
);
40 NativeRegion
Path::CombineRegions(NativeRegion r1
, NativeRegion r2
) {
41 HRGN dest
= CreateRectRgn(0, 0, 1, 1);
42 CombineRgn(dest
, r1
, r2
, RGN_OR
);
47 NativeRegion
Path::SubtractRegion(NativeRegion r1
, NativeRegion r2
) {
48 HRGN dest
= CreateRectRgn(0, 0, 1, 1);
49 CombineRgn(dest
, r1
, r2
, RGN_DIFF
);