OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrTessellatingPathRenderer.h" | 8 #include "GrTessellatingPathRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 fHead = newV; | 348 fHead = newV; |
349 } | 349 } |
350 return done; | 350 return done; |
351 } | 351 } |
352 | 352 |
353 void* emit(void* data) { | 353 void* emit(void* data) { |
354 Vertex* first = fHead; | 354 Vertex* first = fHead; |
355 Vertex* v = first->fNext; | 355 Vertex* v = first->fNext; |
356 while (v != fTail) { | 356 while (v != fTail) { |
357 SkASSERT(v && v->fPrev && v->fNext); | 357 SkASSERT(v && v->fPrev && v->fNext); |
358 #ifdef SK_DEBUG | |
359 validate(); | |
360 #endif | |
361 Vertex* prev = v->fPrev; | 358 Vertex* prev = v->fPrev; |
362 Vertex* curr = v; | 359 Vertex* curr = v; |
363 Vertex* next = v->fNext; | 360 Vertex* next = v->fNext; |
364 double ax = static_cast<double>(curr->fPoint.fX) - prev->fPoint.
fX; | 361 double ax = static_cast<double>(curr->fPoint.fX) - prev->fPoint.
fX; |
365 double ay = static_cast<double>(curr->fPoint.fY) - prev->fPoint.
fY; | 362 double ay = static_cast<double>(curr->fPoint.fY) - prev->fPoint.
fY; |
366 double bx = static_cast<double>(next->fPoint.fX) - curr->fPoint.
fX; | 363 double bx = static_cast<double>(next->fPoint.fX) - curr->fPoint.
fX; |
367 double by = static_cast<double>(next->fPoint.fY) - curr->fPoint.
fY; | 364 double by = static_cast<double>(next->fPoint.fY) - curr->fPoint.
fY; |
368 if (ax * by - ay * bx >= 0.0) { | 365 if (ax * by - ay * bx >= 0.0) { |
369 data = emit_triangle(prev, curr, next, data); | 366 data = emit_triangle(prev, curr, next, data); |
370 v->fPrev->fNext = v->fNext; | 367 v->fPrev->fNext = v->fNext; |
371 v->fNext->fPrev = v->fPrev; | 368 v->fNext->fPrev = v->fPrev; |
372 if (v->fPrev == first) { | 369 if (v->fPrev == first) { |
373 v = v->fNext; | 370 v = v->fNext; |
374 } else { | 371 } else { |
375 v = v->fPrev; | 372 v = v->fPrev; |
376 } | 373 } |
377 } else { | 374 } else { |
378 v = v->fNext; | 375 v = v->fNext; |
379 SkASSERT(v != fTail); | |
380 } | 376 } |
381 } | 377 } |
382 return data; | 378 return data; |
383 } | 379 } |
384 | |
385 #ifdef SK_DEBUG | |
386 void validate() { | |
387 int winding = sweep_lt(fHead->fPoint, fTail->fPoint) ? 1 : -1; | |
388 Vertex* top = winding < 0 ? fTail : fHead; | |
389 Vertex* bottom = winding < 0 ? fHead : fTail; | |
390 Edge e(top, bottom, winding); | |
391 for (Vertex* v = fHead->fNext; v != fTail; v = v->fNext) { | |
392 if (fSide == kRight_Side) { | |
393 SkASSERT(!e.isRightOf(v)); | |
394 } else if (fSide == Poly::kLeft_Side) { | |
395 SkASSERT(!e.isLeftOf(v)); | |
396 } | |
397 } | |
398 } | |
399 #endif | |
400 }; | 380 }; |
401 Poly* addVertex(Vertex* v, Side side, SkChunkAlloc& alloc) { | 381 Poly* addVertex(Vertex* v, Side side, SkChunkAlloc& alloc) { |
402 LOG("addVertex() to %d at %g (%g, %g), %s side\n", fID, v->fID, v->fPoin
t.fX, v->fPoint.fY, | 382 LOG("addVertex() to %d at %g (%g, %g), %s side\n", fID, v->fID, v->fPoin
t.fX, v->fPoint.fY, |
403 side == kLeft_Side ? "left" : side == kRight_Side ? "right" : "ne
ither"); | 383 side == kLeft_Side ? "left" : side == kRight_Side ? "right" : "ne
ither"); |
404 Poly* partner = fPartner; | 384 Poly* partner = fPartner; |
405 Poly* poly = this; | 385 Poly* poly = this; |
406 if (partner) { | 386 if (partner) { |
407 fPartner = partner->fPartner = NULL; | 387 fPartner = partner->fPartner = NULL; |
408 } | 388 } |
409 if (!fActive) { | 389 if (!fActive) { |
410 fActive = ALLOC_NEW(MonotonePoly, (), alloc); | 390 fActive = ALLOC_NEW(MonotonePoly, (), alloc); |
411 } | 391 } |
412 if (fActive->addVertex(v, side, alloc)) { | 392 if (fActive->addVertex(v, side, alloc)) { |
413 #ifdef SK_DEBUG | |
414 fActive->validate(); | |
415 #endif | |
416 if (fTail) { | 393 if (fTail) { |
417 fActive->fPrev = fTail; | 394 fActive->fPrev = fTail; |
418 fTail->fNext = fActive; | 395 fTail->fNext = fActive; |
419 fTail = fActive; | 396 fTail = fActive; |
420 } else { | 397 } else { |
421 fHead = fTail = fActive; | 398 fHead = fTail = fActive; |
422 } | 399 } |
423 if (partner) { | 400 if (partner) { |
424 partner->addVertex(v, side, alloc); | 401 partner->addVertex(v, side, alloc); |
425 poly = partner; | 402 poly = partner; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 447 } |
471 | 448 |
472 Poly* new_poly(Poly** head, Vertex* v, int winding, SkChunkAlloc& alloc) { | 449 Poly* new_poly(Poly** head, Vertex* v, int winding, SkChunkAlloc& alloc) { |
473 Poly* poly = ALLOC_NEW(Poly, (winding), alloc); | 450 Poly* poly = ALLOC_NEW(Poly, (winding), alloc); |
474 poly->addVertex(v, Poly::kNeither_Side, alloc); | 451 poly->addVertex(v, Poly::kNeither_Side, alloc); |
475 poly->fNext = *head; | 452 poly->fNext = *head; |
476 *head = poly; | 453 *head = poly; |
477 return poly; | 454 return poly; |
478 } | 455 } |
479 | 456 |
480 #ifdef SK_DEBUG | |
481 void validate_edges(Edge* head) { | |
482 for (Edge* e = head; e != NULL; e = e->fRight) { | |
483 SkASSERT(e->fTop != e->fBottom); | |
484 if (e->fLeft) { | |
485 SkASSERT(e->fLeft->fRight == e); | |
486 if (sweep_gt(e->fTop->fPoint, e->fLeft->fTop->fPoint)) { | |
487 SkASSERT(e->fLeft->isLeftOf(e->fTop)); | |
488 } | |
489 if (sweep_lt(e->fBottom->fPoint, e->fLeft->fBottom->fPoint)) { | |
490 SkASSERT(e->fLeft->isLeftOf(e->fBottom)); | |
491 } | |
492 } else { | |
493 SkASSERT(e == head); | |
494 } | |
495 if (e->fRight) { | |
496 SkASSERT(e->fRight->fLeft == e); | |
497 if (sweep_gt(e->fTop->fPoint, e->fRight->fTop->fPoint)) { | |
498 SkASSERT(e->fRight->isRightOf(e->fTop)); | |
499 } | |
500 if (sweep_lt(e->fBottom->fPoint, e->fRight->fBottom->fPoint)) { | |
501 SkASSERT(e->fRight->isRightOf(e->fBottom)); | |
502 } | |
503 } | |
504 } | |
505 } | |
506 | |
507 void validate_connectivity(Vertex* v) { | |
508 for (Edge* e = v->fFirstEdgeAbove; e != NULL; e = e->fNextEdgeAbove) { | |
509 SkASSERT(e->fBottom == v); | |
510 if (e->fPrevEdgeAbove) { | |
511 SkASSERT(e->fPrevEdgeAbove->fNextEdgeAbove == e); | |
512 SkASSERT(e->fPrevEdgeAbove->isLeftOf(e->fTop)); | |
513 } else { | |
514 SkASSERT(e == v->fFirstEdgeAbove); | |
515 } | |
516 if (e->fNextEdgeAbove) { | |
517 SkASSERT(e->fNextEdgeAbove->fPrevEdgeAbove == e); | |
518 SkASSERT(e->fNextEdgeAbove->isRightOf(e->fTop)); | |
519 } else { | |
520 SkASSERT(e == v->fLastEdgeAbove); | |
521 } | |
522 } | |
523 for (Edge* e = v->fFirstEdgeBelow; e != NULL; e = e->fNextEdgeBelow) { | |
524 SkASSERT(e->fTop == v); | |
525 if (e->fPrevEdgeBelow) { | |
526 SkASSERT(e->fPrevEdgeBelow->fNextEdgeBelow == e); | |
527 SkASSERT(e->fPrevEdgeBelow->isLeftOf(e->fBottom)); | |
528 } else { | |
529 SkASSERT(e == v->fFirstEdgeBelow); | |
530 } | |
531 if (e->fNextEdgeBelow) { | |
532 SkASSERT(e->fNextEdgeBelow->fPrevEdgeBelow == e); | |
533 SkASSERT(e->fNextEdgeBelow->isRightOf(e->fBottom)); | |
534 } else { | |
535 SkASSERT(e == v->fLastEdgeBelow); | |
536 } | |
537 } | |
538 } | |
539 #endif | |
540 | |
541 Vertex* append_point_to_contour(const SkPoint& p, Vertex* prev, Vertex** head, | 457 Vertex* append_point_to_contour(const SkPoint& p, Vertex* prev, Vertex** head, |
542 SkChunkAlloc& alloc) { | 458 SkChunkAlloc& alloc) { |
543 Vertex* v = ALLOC_NEW(Vertex, (p), alloc); | 459 Vertex* v = ALLOC_NEW(Vertex, (p), alloc); |
544 #if LOGGING_ENABLED | 460 #if LOGGING_ENABLED |
545 static float gID = 0.0f; | 461 static float gID = 0.0f; |
546 v->fID = gID++; | 462 v->fID = gID++; |
547 #endif | 463 #endif |
548 if (prev) { | 464 if (prev) { |
549 prev->fNext = v; | 465 prev->fNext = v; |
550 v->fPrev = prev; | 466 v->fPrev = prev; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 Edge* left; | 692 Edge* left; |
777 Edge* right; | 693 Edge* right; |
778 find_enclosing_edges(edge, *activeEdges, &left, &right); | 694 find_enclosing_edges(edge, *activeEdges, &left, &right); |
779 insert_edge(edge, left, activeEdges); | 695 insert_edge(edge, left, activeEdges); |
780 } | 696 } |
781 } | 697 } |
782 | 698 |
783 void insert_edge_above(Edge* edge, Vertex* v) { | 699 void insert_edge_above(Edge* edge, Vertex* v) { |
784 if (edge->fTop->fPoint == edge->fBottom->fPoint || | 700 if (edge->fTop->fPoint == edge->fBottom->fPoint || |
785 sweep_gt(edge->fTop->fPoint, edge->fBottom->fPoint)) { | 701 sweep_gt(edge->fTop->fPoint, edge->fBottom->fPoint)) { |
786 SkASSERT(false); | |
787 return; | 702 return; |
788 } | 703 } |
789 LOG("insert edge (%g -> %g) above vertex %g\n", edge->fTop->fID, edge->fBott
om->fID, v->fID); | 704 LOG("insert edge (%g -> %g) above vertex %g\n", edge->fTop->fID, edge->fBott
om->fID, v->fID); |
790 Edge* prev = NULL; | 705 Edge* prev = NULL; |
791 Edge* next; | 706 Edge* next; |
792 for (next = v->fFirstEdgeAbove; next; next = next->fNextEdgeAbove) { | 707 for (next = v->fFirstEdgeAbove; next; next = next->fNextEdgeAbove) { |
793 if (next->isRightOf(edge->fTop)) { | 708 if (next->isRightOf(edge->fTop)) { |
794 break; | 709 break; |
795 } | 710 } |
796 prev = next; | 711 prev = next; |
797 } | 712 } |
798 insert<Edge, &Edge::fPrevEdgeAbove, &Edge::fNextEdgeAbove>( | 713 insert<Edge, &Edge::fPrevEdgeAbove, &Edge::fNextEdgeAbove>( |
799 edge, prev, next, &v->fFirstEdgeAbove, &v->fLastEdgeAbove); | 714 edge, prev, next, &v->fFirstEdgeAbove, &v->fLastEdgeAbove); |
800 } | 715 } |
801 | 716 |
802 void insert_edge_below(Edge* edge, Vertex* v) { | 717 void insert_edge_below(Edge* edge, Vertex* v) { |
803 if (edge->fTop->fPoint == edge->fBottom->fPoint || | 718 if (edge->fTop->fPoint == edge->fBottom->fPoint || |
804 sweep_gt(edge->fTop->fPoint, edge->fBottom->fPoint)) { | 719 sweep_gt(edge->fTop->fPoint, edge->fBottom->fPoint)) { |
805 SkASSERT(false); | |
806 return; | 720 return; |
807 } | 721 } |
808 LOG("insert edge (%g -> %g) below vertex %g\n", edge->fTop->fID, edge->fBott
om->fID, v->fID); | 722 LOG("insert edge (%g -> %g) below vertex %g\n", edge->fTop->fID, edge->fBott
om->fID, v->fID); |
809 Edge* prev = NULL; | 723 Edge* prev = NULL; |
810 Edge* next; | 724 Edge* next; |
811 for (next = v->fFirstEdgeBelow; next; next = next->fNextEdgeBelow) { | 725 for (next = v->fFirstEdgeBelow; next; next = next->fNextEdgeBelow) { |
812 if (next->isRightOf(edge->fBottom)) { | 726 if (next->isRightOf(edge->fBottom)) { |
813 break; | 727 break; |
814 } | 728 } |
815 prev = next; | 729 prev = next; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 v->fID = (nextV->fID + prevV->fID) * 0.5f; | 947 v->fID = (nextV->fID + prevV->fID) * 0.5f; |
1034 #endif | 948 #endif |
1035 v->fPrev = prevV; | 949 v->fPrev = prevV; |
1036 v->fNext = nextV; | 950 v->fNext = nextV; |
1037 prevV->fNext = v; | 951 prevV->fNext = v; |
1038 nextV->fPrev = v; | 952 nextV->fPrev = v; |
1039 } | 953 } |
1040 split_edge(edge, v, activeEdges, alloc); | 954 split_edge(edge, v, activeEdges, alloc); |
1041 split_edge(other, v, activeEdges, alloc); | 955 split_edge(other, v, activeEdges, alloc); |
1042 } | 956 } |
1043 #ifdef SK_DEBUG | |
1044 validate_connectivity(v); | |
1045 #endif | |
1046 return v; | 957 return v; |
1047 } | 958 } |
1048 return NULL; | 959 return NULL; |
1049 } | 960 } |
1050 | 961 |
1051 void sanitize_contours(Vertex** contours, int contourCnt) { | 962 void sanitize_contours(Vertex** contours, int contourCnt) { |
1052 for (int i = 0; i < contourCnt; ++i) { | 963 for (int i = 0; i < contourCnt; ++i) { |
1053 SkASSERT(contours[i]); | 964 SkASSERT(contours[i]); |
1054 for (Vertex* v = contours[i];;) { | 965 for (Vertex* v = contours[i];;) { |
1055 if (coincident(v->fPrev->fPoint, v->fPoint)) { | 966 if (coincident(v->fPrev->fPoint, v->fPoint)) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 void simplify(Vertex* vertices, SkChunkAlloc& alloc) { | 1097 void simplify(Vertex* vertices, SkChunkAlloc& alloc) { |
1187 LOG("simplifying complex polygons\n"); | 1098 LOG("simplifying complex polygons\n"); |
1188 Edge* activeEdges = NULL; | 1099 Edge* activeEdges = NULL; |
1189 for (Vertex* v = vertices; v != NULL; v = v->fNext) { | 1100 for (Vertex* v = vertices; v != NULL; v = v->fNext) { |
1190 if (!v->fFirstEdgeAbove && !v->fFirstEdgeBelow) { | 1101 if (!v->fFirstEdgeAbove && !v->fFirstEdgeBelow) { |
1191 continue; | 1102 continue; |
1192 } | 1103 } |
1193 #if LOGGING_ENABLED | 1104 #if LOGGING_ENABLED |
1194 LOG("\nvertex %g: (%g,%g)\n", v->fID, v->fPoint.fX, v->fPoint.fY); | 1105 LOG("\nvertex %g: (%g,%g)\n", v->fID, v->fPoint.fX, v->fPoint.fY); |
1195 #endif | 1106 #endif |
1196 #ifdef SK_DEBUG | |
1197 validate_connectivity(v); | |
1198 #endif | |
1199 Edge* leftEnclosingEdge = NULL; | 1107 Edge* leftEnclosingEdge = NULL; |
1200 Edge* rightEnclosingEdge = NULL; | 1108 Edge* rightEnclosingEdge = NULL; |
1201 bool restartChecks; | 1109 bool restartChecks; |
1202 do { | 1110 do { |
1203 restartChecks = false; | 1111 restartChecks = false; |
1204 find_enclosing_edges(v, activeEdges, &leftEnclosingEdge, &rightEnclo
singEdge); | 1112 find_enclosing_edges(v, activeEdges, &leftEnclosingEdge, &rightEnclo
singEdge); |
1205 if (v->fFirstEdgeBelow) { | 1113 if (v->fFirstEdgeBelow) { |
1206 for (Edge* edge = v->fFirstEdgeBelow; edge != NULL; edge = edge-
>fNextEdgeBelow) { | 1114 for (Edge* edge = v->fFirstEdgeBelow; edge != NULL; edge = edge-
>fNextEdgeBelow) { |
1207 if (check_for_intersection(edge, leftEnclosingEdge, &activeE
dges, alloc)) { | 1115 if (check_for_intersection(edge, leftEnclosingEdge, &activeE
dges, alloc)) { |
1208 restartChecks = true; | 1116 restartChecks = true; |
1209 break; | 1117 break; |
1210 } | 1118 } |
1211 if (check_for_intersection(edge, rightEnclosingEdge, &active
Edges, alloc)) { | 1119 if (check_for_intersection(edge, rightEnclosingEdge, &active
Edges, alloc)) { |
1212 restartChecks = true; | 1120 restartChecks = true; |
1213 break; | 1121 break; |
1214 } | 1122 } |
1215 } | 1123 } |
1216 } else { | 1124 } else { |
1217 if (Vertex* pv = check_for_intersection(leftEnclosingEdge, right
EnclosingEdge, | 1125 if (Vertex* pv = check_for_intersection(leftEnclosingEdge, right
EnclosingEdge, |
1218 &activeEdges, alloc)) { | 1126 &activeEdges, alloc)) { |
1219 if (sweep_lt(pv->fPoint, v->fPoint)) { | 1127 if (sweep_lt(pv->fPoint, v->fPoint)) { |
1220 v = pv; | 1128 v = pv; |
1221 } | 1129 } |
1222 restartChecks = true; | 1130 restartChecks = true; |
1223 } | 1131 } |
1224 | 1132 |
1225 } | 1133 } |
1226 } while (restartChecks); | 1134 } while (restartChecks); |
1227 SkASSERT(!leftEnclosingEdge || leftEnclosingEdge->isLeftOf(v)); | |
1228 SkASSERT(!rightEnclosingEdge || rightEnclosingEdge->isRightOf(v)); | |
1229 #ifdef SK_DEBUG | |
1230 validate_edges(activeEdges); | |
1231 #endif | |
1232 for (Edge* e = v->fFirstEdgeAbove; e; e = e->fNextEdgeAbove) { | 1135 for (Edge* e = v->fFirstEdgeAbove; e; e = e->fNextEdgeAbove) { |
1233 remove_edge(e, &activeEdges); | 1136 remove_edge(e, &activeEdges); |
1234 } | 1137 } |
1235 Edge* leftEdge = leftEnclosingEdge; | 1138 Edge* leftEdge = leftEnclosingEdge; |
1236 for (Edge* e = v->fFirstEdgeBelow; e; e = e->fNextEdgeBelow) { | 1139 for (Edge* e = v->fFirstEdgeBelow; e; e = e->fNextEdgeBelow) { |
1237 insert_edge(e, leftEdge, &activeEdges); | 1140 insert_edge(e, leftEdge, &activeEdges); |
1238 leftEdge = e; | 1141 leftEdge = e; |
1239 } | 1142 } |
1240 v->fProcessed = true; | 1143 v->fProcessed = true; |
1241 } | 1144 } |
1242 } | 1145 } |
1243 | 1146 |
1244 // Stage 5: Tessellate the simplified mesh into monotone polygons. | 1147 // Stage 5: Tessellate the simplified mesh into monotone polygons. |
1245 | 1148 |
1246 Poly* tessellate(Vertex* vertices, SkChunkAlloc& alloc) { | 1149 Poly* tessellate(Vertex* vertices, SkChunkAlloc& alloc) { |
1247 LOG("tessellating simple polygons\n"); | 1150 LOG("tessellating simple polygons\n"); |
1248 Edge* activeEdges = NULL; | 1151 Edge* activeEdges = NULL; |
1249 Poly* polys = NULL; | 1152 Poly* polys = NULL; |
1250 for (Vertex* v = vertices; v != NULL; v = v->fNext) { | 1153 for (Vertex* v = vertices; v != NULL; v = v->fNext) { |
1251 if (!v->fFirstEdgeAbove && !v->fFirstEdgeBelow) { | 1154 if (!v->fFirstEdgeAbove && !v->fFirstEdgeBelow) { |
1252 continue; | 1155 continue; |
1253 } | 1156 } |
1254 #if LOGGING_ENABLED | 1157 #if LOGGING_ENABLED |
1255 LOG("\nvertex %g: (%g,%g)\n", v->fID, v->fPoint.fX, v->fPoint.fY); | 1158 LOG("\nvertex %g: (%g,%g)\n", v->fID, v->fPoint.fX, v->fPoint.fY); |
1256 #endif | 1159 #endif |
1257 #ifdef SK_DEBUG | |
1258 validate_connectivity(v); | |
1259 #endif | |
1260 Edge* leftEnclosingEdge = NULL; | 1160 Edge* leftEnclosingEdge = NULL; |
1261 Edge* rightEnclosingEdge = NULL; | 1161 Edge* rightEnclosingEdge = NULL; |
1262 find_enclosing_edges(v, activeEdges, &leftEnclosingEdge, &rightEnclosing
Edge); | 1162 find_enclosing_edges(v, activeEdges, &leftEnclosingEdge, &rightEnclosing
Edge); |
1263 SkASSERT(!leftEnclosingEdge || leftEnclosingEdge->isLeftOf(v)); | |
1264 SkASSERT(!rightEnclosingEdge || rightEnclosingEdge->isRightOf(v)); | |
1265 #ifdef SK_DEBUG | |
1266 validate_edges(activeEdges); | |
1267 #endif | |
1268 Poly* leftPoly = NULL; | 1163 Poly* leftPoly = NULL; |
1269 Poly* rightPoly = NULL; | 1164 Poly* rightPoly = NULL; |
1270 if (v->fFirstEdgeAbove) { | 1165 if (v->fFirstEdgeAbove) { |
1271 leftPoly = v->fFirstEdgeAbove->fLeftPoly; | 1166 leftPoly = v->fFirstEdgeAbove->fLeftPoly; |
1272 rightPoly = v->fLastEdgeAbove->fRightPoly; | 1167 rightPoly = v->fLastEdgeAbove->fRightPoly; |
1273 } else { | 1168 } else { |
1274 leftPoly = leftEnclosingEdge ? leftEnclosingEdge->fRightPoly : NULL; | 1169 leftPoly = leftEnclosingEdge ? leftEnclosingEdge->fRightPoly : NULL; |
1275 rightPoly = rightEnclosingEdge ? rightEnclosingEdge->fLeftPoly : NUL
L; | 1170 rightPoly = rightEnclosingEdge ? rightEnclosingEdge->fLeftPoly : NUL
L; |
1276 } | 1171 } |
1277 #if LOGGING_ENABLED | 1172 #if LOGGING_ENABLED |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 int winding = leftEdge->fLeftPoly ? leftEdge->fLeftPoly->fWindin
g : 0; | 1244 int winding = leftEdge->fLeftPoly ? leftEdge->fLeftPoly->fWindin
g : 0; |
1350 winding += leftEdge->fWinding; | 1245 winding += leftEdge->fWinding; |
1351 if (winding != 0) { | 1246 if (winding != 0) { |
1352 Poly* poly = new_poly(&polys, v, winding, alloc); | 1247 Poly* poly = new_poly(&polys, v, winding, alloc); |
1353 leftEdge->fRightPoly = rightEdge->fLeftPoly = poly; | 1248 leftEdge->fRightPoly = rightEdge->fLeftPoly = poly; |
1354 } | 1249 } |
1355 leftEdge = rightEdge; | 1250 leftEdge = rightEdge; |
1356 } | 1251 } |
1357 v->fLastEdgeBelow->fRightPoly = rightPoly; | 1252 v->fLastEdgeBelow->fRightPoly = rightPoly; |
1358 } | 1253 } |
1359 #ifdef SK_DEBUG | |
1360 validate_edges(activeEdges); | |
1361 #endif | |
1362 #if LOGGING_ENABLED | 1254 #if LOGGING_ENABLED |
1363 LOG("\nactive edges:\n"); | 1255 LOG("\nactive edges:\n"); |
1364 for (Edge* e = activeEdges; e != NULL; e = e->fRight) { | 1256 for (Edge* e = activeEdges; e != NULL; e = e->fRight) { |
1365 LOG("%g -> %g, lpoly %d, rpoly %d\n", e->fTop->fID, e->fBottom->fID, | 1257 LOG("%g -> %g, lpoly %d, rpoly %d\n", e->fTop->fID, e->fBottom->fID, |
1366 e->fLeftPoly ? e->fLeftPoly->fID : -1, e->fRightPoly ? e->fRight
Poly->fID : -1); | 1258 e->fLeftPoly ? e->fLeftPoly->fID : -1, e->fRightPoly ? e->fRight
Poly->fID : -1); |
1367 } | 1259 } |
1368 #endif | 1260 #endif |
1369 } | 1261 } |
1370 return polys; | 1262 return polys; |
1371 } | 1263 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 SkChunkAlloc alloc(maxPts * (3 * sizeof(Vertex) + sizeof(Edge))); | 1392 SkChunkAlloc alloc(maxPts * (3 * sizeof(Vertex) + sizeof(Edge))); |
1501 path_to_contours(fPath, tol, fClipBounds, contours.get(), alloc); | 1393 path_to_contours(fPath, tol, fClipBounds, contours.get(), alloc); |
1502 Poly* polys; | 1394 Poly* polys; |
1503 polys = contours_to_polys(contours.get(), contourCnt, alloc); | 1395 polys = contours_to_polys(contours.get(), contourCnt, alloc); |
1504 int count = 0; | 1396 int count = 0; |
1505 for (Poly* poly = polys; poly; poly = poly->fNext) { | 1397 for (Poly* poly = polys; poly; poly = poly->fNext) { |
1506 if (apply_fill_type(fillType, poly->fWinding) && poly->fCount >= 3)
{ | 1398 if (apply_fill_type(fillType, poly->fWinding) && poly->fCount >= 3)
{ |
1507 count += (poly->fCount - 2) * (WIREFRAME ? 6 : 3); | 1399 count += (poly->fCount - 2) * (WIREFRAME ? 6 : 3); |
1508 } | 1400 } |
1509 } | 1401 } |
| 1402 if (0 == count) { |
| 1403 return; |
| 1404 } |
1510 | 1405 |
1511 size_t stride = gp->getVertexStride(); | 1406 size_t stride = gp->getVertexStride(); |
1512 const GrVertexBuffer* vertexBuffer; | 1407 const GrVertexBuffer* vertexBuffer; |
1513 int firstVertex; | 1408 int firstVertex; |
1514 void* vertices = batchTarget->vertexPool()->makeSpace(stride, | 1409 void* vertices = batchTarget->vertexPool()->makeSpace(stride, |
1515 count, | 1410 count, |
1516 &vertexBuffer, | 1411 &vertexBuffer, |
1517 &firstVertex); | 1412 &firstVertex); |
1518 | 1413 |
1519 if (!vertices) { | 1414 if (!vertices) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 SkMatrix vmi; | 1480 SkMatrix vmi; |
1586 if (!viewM.invert(&vmi)) { | 1481 if (!viewM.invert(&vmi)) { |
1587 return false; | 1482 return false; |
1588 } | 1483 } |
1589 vmi.mapRect(&clipBounds); | 1484 vmi.mapRect(&clipBounds); |
1590 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); | 1485 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); |
1591 target->drawBatch(pipelineBuilder, batch); | 1486 target->drawBatch(pipelineBuilder, batch); |
1592 | 1487 |
1593 return true; | 1488 return true; |
1594 } | 1489 } |
OLD | NEW |