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

Side by Side Diff: src/pathops/SkOpSegment.cpp

Issue 19183003: path ops near exact (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove unused static function Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkOpSegment.h ('k') | src/pathops/SkPathOpsCommon.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 #include "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkOpSegment.h" 8 #include "SkOpSegment.h"
9 #include "SkPathWriter.h" 9 #include "SkPathWriter.h"
10 #include "SkTSort.h" 10 #include "SkTSort.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 setUpWinding(index, endIndex, maxWinding, sumWinding); 202 setUpWinding(index, endIndex, maxWinding, sumWinding);
203 bool from = *maxWinding != 0; 203 bool from = *maxWinding != 0;
204 bool to = *sumWinding != 0; 204 bool to = *sumWinding != 0;
205 bool result = gUnaryActiveEdge[from][to]; 205 bool result = gUnaryActiveEdge[from][to];
206 return result; 206 return result;
207 } 207 }
208 208
209 void SkOpSegment::addAngle(SkTArray<SkOpAngle, true>* anglesPtr, int start, int end) const { 209 void SkOpSegment::addAngle(SkTArray<SkOpAngle, true>* anglesPtr, int start, int end) const {
210 SkASSERT(start != end); 210 SkASSERT(start != end);
211 SkOpAngle& angle = anglesPtr->push_back(); 211 SkOpAngle& angle = anglesPtr->push_back();
212 #if DEBUG_ANGLE 212 #if 0 && DEBUG_ANGLE // computed pt and actual pt may differ by more than approx eq
213 SkTArray<SkOpAngle, true>& angles = *anglesPtr; 213 SkTArray<SkOpAngle, true>& angles = *anglesPtr;
214 if (angles.count() > 1) { 214 if (angles.count() > 1) {
215 const SkOpSegment* aSeg = angles[0].segment(); 215 const SkOpSegment* aSeg = angles[0].segment();
216 int aStart = angles[0].start(); 216 int aStart = angles[0].start();
217 if (!aSeg->fTs[aStart].fTiny) { 217 if (!aSeg->fTs[aStart].fTiny) {
218 const SkPoint& angle0Pt = aSeg->xyAtT(aStart); 218 const SkPoint& angle0Pt = aSeg->xyAtT(aStart);
219 SkDPoint newPt = (*CurveDPointAtT[SkPathOpsVerbToPoints(aSeg->fVerb) ])(aSeg->fPts, 219 SkDPoint newPt = (*CurveDPointAtT[SkPathOpsVerbToPoints(aSeg->fVerb) ])(aSeg->fPts,
220 aSeg->fTs[aStart].fT); 220 aSeg->fTs[aStart].fT);
221 #if ONE_OFF_DEBUG 221 #if ONE_OFF_DEBUG
222 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g)\n", __FUNCTION__ , 222 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g)\n", __FUNCTION__ ,
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 span->fOppValue &= 1; 1073 span->fOppValue &= 1;
1074 } 1074 }
1075 if (!span->fWindValue && !span->fOppValue) { 1075 if (!span->fWindValue && !span->fOppValue) {
1076 span->fDone = true; 1076 span->fDone = true;
1077 ++fDoneSpans; 1077 ++fDoneSpans;
1078 return true; 1078 return true;
1079 } 1079 }
1080 return false; 1080 return false;
1081 } 1081 }
1082 1082
1083 // look to see if the curve end intersects an intermediary that intersects the o ther
1084 void SkOpSegment::checkEnds() {
1085 #if 1
1086 return; // FIXME: suspect we will need the code below to make intersections consistent
1087 #else
1088 SkTDArray<SkOpSpan> missingSpans;
1089 int count = fTs.count();
1090 for (int index = 0; index < count; ++index) {
1091 const SkOpSpan& span = fTs[index];
1092 const SkOpSegment* other = span.fOther;
1093 const SkOpSpan* otherSpan = &other->fTs[span.fOtherIndex];
1094 double otherT = otherSpan->fT;
1095 if (otherT != 0 && otherT != 1) {
1096 continue;
1097 }
1098 int peekStart = span.fOtherIndex;
1099 while (peekStart > 0) {
1100 const SkOpSpan* peeker = &other->fTs[peekStart - 1];
1101 if (peeker->fT != otherT) {
1102 break;
1103 }
1104 --peekStart;
1105 }
1106 int otherLast = other->fTs.count() - 1;
1107 int peekLast = span.fOtherIndex;
1108 while (peekLast < otherLast) {
1109 const SkOpSpan* peeker = &other->fTs[peekLast + 1];
1110 if (peeker->fT != otherT) {
1111 break;
1112 }
1113 ++peekLast;
1114 }
1115 if (peekStart == peekLast) {
1116 continue;
1117 }
1118 double t = span.fT;
1119 int tStart = index;
1120 while (tStart > 0 && t == fTs[tStart - 1].fT) {
1121 --tStart;
1122 }
1123 int tLast = index;
1124 int last = count - 1;
1125 while (tLast < last && t == fTs[tLast + 1].fT) {
1126 ++tLast;
1127 }
1128 for (int peekIndex = peekStart; peekIndex <= peekLast; ++peekIndex) {
1129 if (peekIndex == span.fOtherIndex) {
1130 continue;
1131 }
1132 const SkOpSpan& peekSpan = other->fTs[peekIndex];
1133 SkOpSegment* match = peekSpan.fOther;
1134 const double matchT = peekSpan.fOtherT;
1135 for (int tIndex = tStart; tIndex <= tLast; ++tIndex) {
1136 const SkOpSpan& tSpan = fTs[tIndex];
1137 if (tSpan.fOther == match && tSpan.fOtherT == matchT) {
1138 goto nextPeeker;
1139 }
1140 }
1141 // this segment is missing a entry that the other contains
1142 // remember so we can add the missing one and recompute the indices
1143 SkOpSpan* missing = missingSpans.append();
1144 missing->fT = t;
1145 missing->fOther = match;
1146 missing->fOtherT = matchT;
1147 missing->fPt = peekSpan.fPt;
1148 }
1149 nextPeeker:
1150 ;
1151 }
1152 int missingCount = missingSpans.count();
1153 for (int index = 0; index < missingCount; ++index) {
1154 const SkOpSpan& missing = missingSpans[index];
1155 addTPair(missing.fT, missing.fOther, missing.fOtherT, false, missing.fPt );
1156 }
1157 if (missingCount > 0) {
1158 fixOtherTIndex();
1159 }
1160 #endif
1161 }
1162
1083 bool SkOpSegment::equalPoints(int greaterTIndex, int lesserTIndex) { 1163 bool SkOpSegment::equalPoints(int greaterTIndex, int lesserTIndex) {
1084 SkASSERT(greaterTIndex >= lesserTIndex); 1164 SkASSERT(greaterTIndex >= lesserTIndex);
1085 double greaterT = fTs[greaterTIndex].fT; 1165 double greaterT = fTs[greaterTIndex].fT;
1086 double lesserT = fTs[lesserTIndex].fT; 1166 double lesserT = fTs[lesserTIndex].fT;
1087 if (greaterT == lesserT) { 1167 if (greaterT == lesserT) {
1088 return true; 1168 return true;
1089 } 1169 }
1090 if (!approximately_negative(greaterT - lesserT)) { 1170 if (!approximately_negative(greaterT - lesserT)) {
1091 return false; 1171 return false;
1092 } 1172 }
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 sum += fTs[i].fWindValue; 2988 sum += fTs[i].fWindValue;
2909 slots[fTs[i].fOther->fID - 1] = as_digit(fTs[i].fWindValue); 2989 slots[fTs[i].fOther->fID - 1] = as_digit(fTs[i].fWindValue);
2910 sum += fTs[i].fOppValue; 2990 sum += fTs[i].fOppValue;
2911 slots[slotCount + fTs[i].fOther->fID - 1] = as_digit(fTs[i].fOppValue); 2991 slots[slotCount + fTs[i].fOther->fID - 1] = as_digit(fTs[i].fOppValue);
2912 } 2992 }
2913 SkDebugf("%s id=%2d %.*s | %.*s\n", __FUNCTION__, fID, slotCount, slots.begi n(), slotCount, 2993 SkDebugf("%s id=%2d %.*s | %.*s\n", __FUNCTION__, fID, slotCount, slots.begi n(), slotCount,
2914 slots.begin() + slotCount); 2994 slots.begin() + slotCount);
2915 return sum; 2995 return sum;
2916 } 2996 }
2917 #endif 2997 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkOpSegment.h ('k') | src/pathops/SkPathOpsCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698