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

Side by Side Diff: src/core/SkLineClipper.cpp

Issue 2250353004: move private test for sect_with_horizontal into unittests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clarify name of test Created 4 years, 4 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 | « no previous file | tests/PathTest.cpp » ('j') | 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 "SkLineClipper.h" 8 #include "SkLineClipper.h"
9 9
10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) { 10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 static bool is_between_unsorted(SkScalar value, 150 static bool is_between_unsorted(SkScalar value,
151 SkScalar limit0, SkScalar limit1) { 151 SkScalar limit0, SkScalar limit1) {
152 if (limit0 < limit1) { 152 if (limit0 < limit1) {
153 return limit0 <= value && value <= limit1; 153 return limit0 <= value && value <= limit1;
154 } else { 154 } else {
155 return limit1 <= value && value <= limit0; 155 return limit1 <= value && value <= limit0;
156 } 156 }
157 } 157 }
158 #endif 158 #endif
159 159
160 #ifdef SK_DEBUG
161 // This is an example of why we need to pin the result computed in
162 // sect_with_horizontal. If we didn't explicitly pin, is_between_unsorted would
163 // fail.
164 //
165 static void sect_with_horizontal_test_for_pin_results() {
166 const SkPoint pts[] = {
167 { -540000, -720000 },
168 { -9.10000017e-05f, 9.99999996e-13f }
169 };
170 float x = sect_with_horizontal(pts, 0);
171 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX));
172 }
173 #endif
174
175 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, SkPoint lin es[], 160 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, SkPoint lin es[],
176 bool canCullToTheRight) { 161 bool canCullToTheRight) {
177
178 #ifdef SK_DEBUG
179 {
180 static bool gOnce;
181 if (!gOnce) {
182 sect_with_horizontal_test_for_pin_results();
183 gOnce = true;
184 }
185 }
186 #endif
187
188 int index0, index1; 162 int index0, index1;
189 163
190 if (pts[0].fY < pts[1].fY) { 164 if (pts[0].fY < pts[1].fY) {
191 index0 = 0; 165 index0 = 0;
192 index1 = 1; 166 index1 = 1;
193 } else { 167 } else {
194 index0 = 1; 168 index0 = 1;
195 index1 = 0; 169 index1 = 0;
196 } 170 }
197 171
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (reverse) { 252 if (reverse) {
279 // copy the pts in reverse order to maintain winding order 253 // copy the pts in reverse order to maintain winding order
280 for (int i = 0; i <= lineCount; i++) { 254 for (int i = 0; i <= lineCount; i++) {
281 lines[lineCount - i] = result[i]; 255 lines[lineCount - i] = result[i];
282 } 256 }
283 } else { 257 } else {
284 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); 258 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint));
285 } 259 }
286 return lineCount; 260 return lineCount;
287 } 261 }
OLDNEW
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698