| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "third_party/skia/include/core/SkRegion.h" | |
| 9 | |
| 10 namespace gfx { | |
| 11 | |
| 12 SkRegion* Path::CreateNativeRegion() const { | |
| 13 // Create a clip region that contains |this| path. | |
| 14 const SkRect bounds = getBounds(); | |
| 15 SkIRect ibounds; | |
| 16 bounds.round(&ibounds); | |
| 17 SkRegion clip_region; | |
| 18 clip_region.setRect(ibounds); | |
| 19 | |
| 20 SkRegion* region = new SkRegion; | |
| 21 region->setPath(*this, clip_region); | |
| 22 return region; | |
| 23 } | |
| 24 | |
| 25 // static | |
| 26 NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) { | |
| 27 SkRegion* new_region = new SkRegion; | |
| 28 new_region->op(*r1, *r2, SkRegion::kIntersect_Op); | |
| 29 return new_region; | |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) { | |
| 34 SkRegion* new_region = new SkRegion; | |
| 35 new_region->op(*r1, *r2, SkRegion::kUnion_Op); | |
| 36 return new_region; | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) { | |
| 41 SkRegion* new_region = new SkRegion; | |
| 42 new_region->op(*r1, *r2, SkRegion::kDifference_Op); | |
| 43 return new_region; | |
| 44 } | |
| 45 | |
| 46 } // namespace gfx | |
| OLD | NEW |