Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1726)

Side by Side Diff: tests/PathTest.cpp

Issue 2175923002: Fix misdetection of rectangles in SkPath::IsSimpleClosedRect. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <cmath> 8 #include <cmath>
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGeometry.h" 10 #include "SkGeometry.h"
(...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 path2.reset(); 2087 path2.reset();
2088 path2.addRect(swapRect, dir, start); 2088 path2.addRect(swapRect, dir, start);
2089 check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapS tarts[start]); 2089 check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapS tarts[start]);
2090 swapRect = testRect; 2090 swapRect = testRect;
2091 SkTSwap(swapRect.fTop, swapRect.fBottom); 2091 SkTSwap(swapRect.fTop, swapRect.fBottom);
2092 path2.reset(); 2092 path2.reset();
2093 path2.addRect(swapRect, dir, start); 2093 path2.addRect(swapRect, dir, start);
2094 check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapS tarts[start]); 2094 check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapS tarts[start]);
2095 } 2095 }
2096 } 2096 }
2097 // down, up, left, close
2098 path.reset();
2099 path.moveTo(1, 1);
2100 path.lineTo(1, 2);
2101 path.lineTo(1, 1);
2102 path.lineTo(0, 1);
2103 SkRect rect;
2104 SkPath::Direction dir;
2105 unsigned start;
2106 path.close();
2107 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2108 // right, left, up, close
2109 path.reset();
2110 path.moveTo(1, 1);
2111 path.lineTo(2, 1);
2112 path.lineTo(1, 1);
2113 path.lineTo(1, 0);
2114 path.close();
2115 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2116 // parallelogram with horizontal edges
2117 path.reset();
2118 path.moveTo(1, 0);
2119 path.lineTo(3, 0);
2120 path.lineTo(2, 1);
2121 path.lineTo(0, 1);
2122 path.close();
2123 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2124 // parallelogram with vertical edges
2125 path.reset();
2126 path.moveTo(0, 1);
2127 path.lineTo(0, 3);
2128 path.lineTo(1, 2);
2129 path.lineTo(1, 0);
2130 path.close();
2131 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2132
2097 } 2133 }
2098 2134
2099 static void test_isNestedFillRects(skiatest::Reporter* reporter) { 2135 static void test_isNestedFillRects(skiatest::Reporter* reporter) {
2100 // passing tests (all moveTo / lineTo... 2136 // passing tests (all moveTo / lineTo...
2101 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW 2137 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW
2102 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; 2138 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}};
2103 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; 2139 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}};
2104 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; 2140 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}};
2105 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW 2141 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW
2106 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; 2142 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}};
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 PathTest_Private::TestPathTo(reporter); 4378 PathTest_Private::TestPathTo(reporter);
4343 PathRefTest_Private::TestPathRef(reporter); 4379 PathRefTest_Private::TestPathRef(reporter);
4344 PathTest_Private::TestPathrefListeners(reporter); 4380 PathTest_Private::TestPathrefListeners(reporter);
4345 test_dump(reporter); 4381 test_dump(reporter);
4346 test_path_crbug389050(reporter); 4382 test_path_crbug389050(reporter);
4347 test_path_crbugskia2820(reporter); 4383 test_path_crbugskia2820(reporter);
4348 test_skbug_3469(reporter); 4384 test_skbug_3469(reporter);
4349 test_skbug_3239(reporter); 4385 test_skbug_3239(reporter);
4350 test_bounds_crbug_513799(reporter); 4386 test_bounds_crbug_513799(reporter);
4351 } 4387 }
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698