OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 #ifdef SK_SCALAR_IS_FLOAT | 170 #ifdef SK_SCALAR_IS_FLOAT |
171 #ifdef SK_DEBUG | 171 #ifdef SK_DEBUG |
172 // This is an example of why we need to pin the result computed in | 172 // This is an example of why we need to pin the result computed in |
173 // sect_with_horizontal. If we didn't explicitly pin, is_between_unsorted would | 173 // sect_with_horizontal. If we didn't explicitly pin, is_between_unsorted would |
174 // fail. | 174 // fail. |
175 // | 175 // |
176 static void sect_with_horizontal_test_for_pin_results() { | 176 static void sect_with_horizontal_test_for_pin_results() { |
177 const SkPoint pts[] = { | 177 const SkPoint pts[] = { |
178 { -540000, -720000 }, | 178 { -540000, -720000 }, |
179 { SkFloatToScalar(-9.10000017e-05f), SkFloatToScalar(9.99999996e-13f) } | 179 { -9.10000017e-05f, 9.99999996e-13f } |
180 }; | 180 }; |
181 float x = sect_with_horizontal(pts, 0); | 181 float x = sect_with_horizontal(pts, 0); |
182 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX)); | 182 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX)); |
183 } | 183 } |
184 #endif | 184 #endif |
185 #endif | 185 #endif |
186 | 186 |
187 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, | 187 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, |
188 SkPoint lines[]) { | 188 SkPoint lines[]) { |
189 #ifdef SK_SCALAR_IS_FLOAT | 189 #ifdef SK_SCALAR_IS_FLOAT |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (reverse) { | 288 if (reverse) { |
289 // copy the pts in reverse order to maintain winding order | 289 // copy the pts in reverse order to maintain winding order |
290 for (int i = 0; i <= lineCount; i++) { | 290 for (int i = 0; i <= lineCount; i++) { |
291 lines[lineCount - i] = result[i]; | 291 lines[lineCount - i] = result[i]; |
292 } | 292 } |
293 } else { | 293 } else { |
294 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); | 294 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); |
295 } | 295 } |
296 return lineCount; | 296 return lineCount; |
297 } | 297 } |
OLD | NEW |