blob: e217447309af4239ce451ee26a30e2acdda979d7 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]71c6ea92012-09-17 19:33:135#include "ui/gfx/path_win.h"
initial.commit09911bf2008-07-26 23:55:296
danakj25c52c32016-04-12 21:51:087#include <memory>
8
[email protected]21ed140d2013-11-08 06:08:359#include "base/win/scoped_gdi_object.h"
10#include "third_party/skia/include/core/SkRegion.h"
[email protected]71c6ea92012-09-17 19:33:1311#include "ui/gfx/path.h"
initial.commit09911bf2008-07-26 23:55:2912
13namespace gfx {
14
[email protected]21ed140d2013-11-08 06:08:3515HRGN CreateHRGNFromSkRegion(const SkRegion& region) {
16 base::win::ScopedRegion temp(::CreateRectRgn(0, 0, 0, 0));
17 base::win::ScopedRegion result(::CreateRectRgn(0, 0, 0, 0));
18
19 for (SkRegion::Iterator i(region); !i.done(); i.next()) {
20 const SkIRect& rect = i.rect();
anpol280746c2015-12-18 08:39:0321 ::SetRectRgn(temp.get(),
22 rect.left(), rect.top(), rect.right(), rect.bottom());
23 ::CombineRgn(result.get(), result.get(), temp.get(), RGN_OR);
[email protected]21ed140d2013-11-08 06:08:3524 }
25
26 return result.release();
27}
28
[email protected]71c6ea92012-09-17 19:33:1329HRGN CreateHRGNFromSkPath(const SkPath& path) {
alex-ac2cb37ad82014-11-13 18:03:2930 SkRegion clip_region;
31 clip_region.setRect(path.getBounds().round());
32 SkRegion region;
33 region.setPath(path, clip_region);
34 return CreateHRGNFromSkRegion(region);
initial.commit09911bf2008-07-26 23:55:2935}
36
[email protected]42b4c092009-03-02 11:24:0337} // namespace gfx