[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ui / gfx / path_win.cc
blobe6a915b3306968b8133475aa68d16a613d8a2545
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 "base/win/scoped_gdi_object.h"
9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/gfx/path.h"
12 namespace gfx {
14 HRGN CreateHRGNFromSkRegion(const SkRegion& region) {
15 base::win::ScopedRegion temp(::CreateRectRgn(0, 0, 0, 0));
16 base::win::ScopedRegion result(::CreateRectRgn(0, 0, 0, 0));
18 for (SkRegion::Iterator i(region); !i.done(); i.next()) {
19 const SkIRect& rect = i.rect();
20 ::SetRectRgn(temp, rect.left(), rect.top(), rect.right(), rect.bottom());
21 ::CombineRgn(result, result, temp, RGN_OR);
24 return result.release();
27 HRGN CreateHRGNFromSkPath(const SkPath& path) {
28 SkRegion clip_region;
29 clip_region.setRect(path.getBounds().round());
30 SkRegion region;
31 region.setPath(path, clip_region);
32 return CreateHRGNFromSkRegion(region);
35 } // namespace gfx