OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 8 |
9 | 9 |
10 #include "SkRegionPriv.h" | 10 #include "SkRegionPriv.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 memcpy(runs, line->firstX(), count * sizeof(SkRegion::RunType)); | 209 memcpy(runs, line->firstX(), count * sizeof(SkRegion::RunType)); |
210 runs += count; | 210 runs += count; |
211 } | 211 } |
212 *runs++ = SkRegion::kRunTypeSentinel; | 212 *runs++ = SkRegion::kRunTypeSentinel; |
213 line = line->nextScanline(); | 213 line = line->nextScanline(); |
214 } while (line < stop); | 214 } while (line < stop); |
215 SkASSERT(line == stop); | 215 SkASSERT(line == stop); |
216 *runs = SkRegion::kRunTypeSentinel; | 216 *runs = SkRegion::kRunTypeSentinel; |
217 } | 217 } |
218 | 218 |
219 static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot) { | 219 static unsigned verb_to_initial_last_index(unsigned verb) { |
220 static const uint8_t gPathVerbToInitialLastIndex[] = { | 220 static const uint8_t gPathVerbToInitialLastIndex[] = { |
221 0, // kMove_Verb | 221 0, // kMove_Verb |
222 1, // kLine_Verb | 222 1, // kLine_Verb |
223 2, // kQuad_Verb | 223 2, // kQuad_Verb |
| 224 2, // kConic_Verb |
224 3, // kCubic_Verb | 225 3, // kCubic_Verb |
225 0, // kClose_Verb | 226 0, // kClose_Verb |
226 0 // kDone_Verb | 227 0 // kDone_Verb |
227 }; | 228 }; |
| 229 SkASSERT((unsigned)verb < SK_ARRAY_COUNT(gPathVerbToInitialLastIndex)); |
| 230 return gPathVerbToInitialLastIndex[verb]; |
| 231 } |
228 | 232 |
| 233 static unsigned verb_to_max_edges(unsigned verb) { |
229 static const uint8_t gPathVerbToMaxEdges[] = { | 234 static const uint8_t gPathVerbToMaxEdges[] = { |
230 0, // kMove_Verb | 235 0, // kMove_Verb |
231 1, // kLine_Verb | 236 1, // kLine_Verb |
232 2, // kQuad_VerbB | 237 2, // kQuad_VerbB |
| 238 2, // kConic_VerbB |
233 3, // kCubic_Verb | 239 3, // kCubic_Verb |
234 0, // kClose_Verb | 240 0, // kClose_Verb |
235 0 // kDone_Verb | 241 0 // kDone_Verb |
236 }; | 242 }; |
| 243 SkASSERT((unsigned)verb < SK_ARRAY_COUNT(gPathVerbToMaxEdges)); |
| 244 return gPathVerbToMaxEdges[verb]; |
| 245 } |
237 | 246 |
| 247 |
| 248 static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot) { |
238 SkPath::Iter iter(path, true); | 249 SkPath::Iter iter(path, true); |
239 SkPoint pts[4]; | 250 SkPoint pts[4]; |
240 SkPath::Verb verb; | 251 SkPath::Verb verb; |
241 | 252 |
242 int maxEdges = 0; | 253 int maxEdges = 0; |
243 SkScalar top = SkIntToScalar(SK_MaxS16); | 254 SkScalar top = SkIntToScalar(SK_MaxS16); |
244 SkScalar bot = SkIntToScalar(SK_MinS16); | 255 SkScalar bot = SkIntToScalar(SK_MinS16); |
245 | 256 |
246 while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) { | 257 while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) { |
247 maxEdges += gPathVerbToMaxEdges[verb]; | 258 maxEdges += verb_to_max_edges(verb); |
248 | 259 |
249 int lastIndex = gPathVerbToInitialLastIndex[verb]; | 260 int lastIndex = verb_to_initial_last_index(verb); |
250 if (lastIndex > 0) { | 261 if (lastIndex > 0) { |
251 for (int i = 1; i <= lastIndex; i++) { | 262 for (int i = 1; i <= lastIndex; i++) { |
252 if (top > pts[i].fY) { | 263 if (top > pts[i].fY) { |
253 top = pts[i].fY; | 264 top = pts[i].fY; |
254 } else if (bot < pts[i].fY) { | 265 } else if (bot < pts[i].fY) { |
255 bot = pts[i].fY; | 266 bot = pts[i].fY; |
256 } | 267 } |
257 } | 268 } |
258 } else if (SkPath::kMove_Verb == verb) { | 269 } else if (SkPath::kMove_Verb == verb) { |
259 if (top > pts[0].fY) { | 270 if (top > pts[0].fY) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 #endif | 492 #endif |
482 | 493 |
483 path->incReserve(count << 1); | 494 path->incReserve(count << 1); |
484 do { | 495 do { |
485 SkASSERT(count > 1); | 496 SkASSERT(count > 1); |
486 count -= extract_path(start, stop, path); | 497 count -= extract_path(start, stop, path); |
487 } while (count > 0); | 498 } while (count > 0); |
488 | 499 |
489 return true; | 500 return true; |
490 } | 501 } |
OLD | NEW |