| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/path_win.h" | 5 #include "ui/gfx/path_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/win/scoped_gdi_object.h" | 10 #include "base/win/scoped_gdi_object.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 std::transform(rects, rects + region_data->rdh.nCount, | 35 std::transform(rects, rects + region_data->rdh.nCount, |
| 36 sk_rects.begin(), skia::RECTToSkIRect); | 36 sk_rects.begin(), skia::RECTToSkIRect); |
| 37 | 37 |
| 38 return sk_rects; | 38 return sk_rects; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // Test that rectangle with round corners stil has round corners after | 43 // Test that rectangle with round corners stil has round corners after |
| 44 // converting from SkPath to the HRGN. | 44 // converting from SkPath to the HRGN. |
| 45 // FIXME: this test is fragile (it depends on rrect rasterization impl) |
| 45 TEST(CreateHRGNFromSkPathTest, RoundCornerTest) { | 46 TEST(CreateHRGNFromSkPathTest, RoundCornerTest) { |
| 46 const SkIRect rects[] = { | 47 const SkIRect rects[] = { |
| 47 { 17, 0, 33, 1}, | 48 { 16, 0, 34, 1 }, |
| 48 { 12, 1, 38, 2}, | 49 { 12, 1, 38, 2 }, |
| 49 { 11, 2, 39, 3}, | 50 { 10, 2, 40, 3 }, |
| 50 { 9, 3, 41, 4}, | 51 { 9, 3, 41, 4 }, |
| 51 { 8, 4, 42, 5}, | 52 { 7, 4, 43, 5 }, |
| 52 { 6, 5, 44, 6}, | 53 { 6, 5, 44, 6 }, |
| 53 { 5, 6, 45, 8}, | 54 { 5, 6, 45, 7 }, |
| 54 { 4, 8, 46, 9}, | 55 { 4, 7, 45, 8 }, |
| 55 { 3, 9, 47, 11}, | 56 { 4, 8, 46, 9 }, |
| 56 { 2, 11, 48, 12}, | 57 { 3, 9, 47, 10 }, |
| 57 { 1, 12, 49, 17}, | 58 { 2, 10, 47, 11 }, |
| 58 { 0, 17, 50, 33}, | 59 { 2, 11, 48, 12 }, |
| 59 { 1, 33, 49, 38}, | 60 { 1, 12, 49, 16 }, |
| 60 { 2, 38, 48, 39}, | 61 { 0, 16, 50, 34 }, |
| 61 { 3, 39, 47, 41}, | 62 { 1, 34, 49, 38 }, |
| 62 { 4, 41, 46, 42}, | 63 { 2, 38, 48, 39 }, |
| 63 { 5, 42, 45, 44}, | 64 { 2, 39, 47, 40 }, |
| 64 { 6, 44, 44, 45}, | 65 { 3, 40, 47, 41 }, |
| 65 { 8, 45, 42, 46}, | 66 { 4, 41, 46, 42 }, |
| 66 { 9, 46, 41, 47}, | 67 { 4, 42, 45, 43 }, |
| 67 { 11, 47, 39, 48}, | 68 { 5, 43, 45, 44 }, |
| 68 { 12, 48, 38, 49}, | 69 { 6, 44, 44, 45 }, |
| 69 { 17, 49, 33, 50}, | 70 { 8, 45, 42, 46 }, |
| 71 { 9, 46, 41, 47 }, |
| 72 { 11, 47, 39, 48 }, |
| 73 { 12, 48, 38, 49 }, |
| 74 { 16, 49, 34, 50 }, |
| 70 }; | 75 }; |
| 71 | 76 |
| 72 Path path; | 77 Path path; |
| 73 SkRRect rrect; | 78 SkRRect rrect; |
| 74 rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20); | 79 rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20); |
| 75 path.addRRect(rrect); | 80 path.addRRect(rrect); |
| 76 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); | 81 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); |
| 77 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region); | 82 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region); |
| 78 EXPECT_EQ(arraysize(rects), region_rects.size()); | 83 EXPECT_EQ(arraysize(rects), region_rects.size()); |
| 79 for (size_t i = 0; i < arraysize(rects) && i < region_rects.size(); ++i) | 84 for (size_t i = 0; i < arraysize(rects) && i < region_rects.size(); ++i) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 102 // Check that empty region is returned for empty path. | 107 // Check that empty region is returned for empty path. |
| 103 TEST(CreateHRGNFromSkPathTest, EmptyPath) { | 108 TEST(CreateHRGNFromSkPathTest, EmptyPath) { |
| 104 Path path; | 109 Path path; |
| 105 base::win::ScopedRegion empty_region(::CreateRectRgn(0, 0, 0, 0)); | 110 base::win::ScopedRegion empty_region(::CreateRectRgn(0, 0, 0, 0)); |
| 106 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); | 111 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); |
| 107 EXPECT_TRUE(::EqualRgn(empty_region, region)); | 112 EXPECT_TRUE(::EqualRgn(empty_region, region)); |
| 108 } | 113 } |
| 109 | 114 |
| 110 } // namespace gfx | 115 } // namespace gfx |
| 111 | 116 |
| OLD | NEW |