SkPathOpsDebug.cpp revision fe41b8ffff3463a1b062c4fd7315b44e278ba390
107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com/* 207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Copyright 2013 Google Inc. 307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * 407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be 507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * found in the LICENSE file. 607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com */ 707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPathOpsDebug.h" 9a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com#include "SkPath.h" 1007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 1107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#if defined SK_DEBUG || !FORCE_RELEASE 1207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 13570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comconst char* SkPathOpsDebug::kLVerbStr[] = {"", "line", "quad", "cubic"}; 148cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org 158cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org#if defined(SK_DEBUG) || !FORCE_RELEASE 16fe41b8ffff3463a1b062c4fd7315b44e278ba390commit-bot@chromium.orgint SkPathOpsDebug::gContourID = 0; 17fe41b8ffff3463a1b062c4fd7315b44e278ba390commit-bot@chromium.orgint SkPathOpsDebug::gSegmentID = 0; 188cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org#endif 19570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 20570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#if DEBUG_SORT || DEBUG_SWAP_TOP 21570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comint SkPathOpsDebug::gSortCountDefault = SK_MaxS32; 22570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comint SkPathOpsDebug::gSortCount; 23570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#endif 24570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 25570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#if DEBUG_ACTIVE_OP 26570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comconst char* SkPathOpsDebug::kPathOpStr[] = {"diff", "sect", "union", "xor"}; 27570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#endif 28570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgbool SkPathOpsDebug::ChaseContains(const SkTDArray<SkOpSpan *>& chaseArray, 304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan* span) { 314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int index = 0; index < chaseArray.count(); ++index) { 324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan* entry = chaseArray[index]; 334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (entry == span) { 344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return true; 354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return false; 384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 40570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comvoid SkPathOpsDebug::MathematicaIze(char* str, size_t bufferLen) { 4107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com size_t len = strlen(str); 4207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com bool num = false; 4307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com for (size_t idx = 0; idx < len; ++idx) { 4407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com if (num && str[idx] == 'e') { 4507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com if (len + 2 >= bufferLen) { 4607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com return; 4707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 4807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com memmove(&str[idx + 2], &str[idx + 1], len - idx); 4907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com str[idx] = '*'; 5007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com str[idx + 1] = '^'; 5107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com ++len; 5207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 5307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com num = str[idx] >= '0' && str[idx] <= '9'; 5407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 5507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com} 5607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 57570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.combool SkPathOpsDebug::ValidWind(int wind) { 5807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; 5907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com} 6007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 61570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comvoid SkPathOpsDebug::WindingPrintf(int wind) { 6207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com if (wind == SK_MinS32) { 6307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com SkDebugf("?"); 6407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } else { 6507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com SkDebugf("%d", wind); 6607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com } 6707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com} 68a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com 6907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com#if DEBUG_SHOW_TEST_NAME 70570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comvoid* SkPathOpsDebug::CreateNameStr() { 7107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH); 72cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com} 73cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com 74570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comvoid SkPathOpsDebug::DeleteNameStr(void* v) { 7507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com SkDELETE_ARRAY(reinterpret_cast<char* >(v)); 76a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com} 77a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com 78570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.comvoid SkPathOpsDebug::BumpTestName(char* test) { 7907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com char* num = test + strlen(test); 8007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com while (num[-1] >= '0' && num[-1] <= '9') { 8107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com --num; 8207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com } 8307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com if (num[0] == '\0') { 8407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com return; 8507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com } 8607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com int dec = atoi(num); 8707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com if (dec == 0) { 8807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com return; 8907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com } 9007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com ++dec; 9107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec); 92a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com} 93a5e55925ea03e76885804bda77408a1d6f04c335caryclark@google.com#endif 94570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if !DEBUG_SHOW_TEST_NAME // enable when building without extended test 964431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkPathOpsDebug::ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name) { 974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 984431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 994431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 1004431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif // defined SK_DEBUG || !FORCE_RELEASE 1014431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 1024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#include "SkOpAngle.h" 103570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#include "SkOpSegment.h" 104570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 1054431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_SORT 1064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpAngle::debugLoop() const { 1074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* first = this; 1084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* next = this; 1094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org do { 1104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next->debugOne(true); 1114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("\n"); 1124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->fNext; 1134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } while (next && next != first); 114570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com} 1157eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 1164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpAngle::debugOne(bool functionHeader) const { 1174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// fSegment->debugValidate(); 1184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& mSpan = fSegment->span(SkMin32(fStart, fEnd)); 1194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (functionHeader) { 1204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s ", __FUNCTION__); 1217eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com } 1224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("[%d", fSegment->debugID()); 1234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ANGLE 1244431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("/%d", fID); 1254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 1264431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("] next="); 1274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fNext) { 1284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%d", fNext->fSegment->debugID()); 1294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ANGLE 1304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("/%d", fNext->fID); 1314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 1324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 1334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("?"); 1344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 1354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd); 1364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fSegment->span(fStart).fT, fStart, 1374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fSegment->span(fEnd).fT, fEnd); 1384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" sgn=%d windVal=%d", sign(), mSpan.fWindValue); 139570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 1404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_WINDING 141570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com SkDebugf(" windSum="); 1424431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkPathOpsDebug::WindingPrintf(mSpan.fWindSum); 1434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 1444431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (mSpan.fOppValue != 0 || mSpan.fOppSum != SK_MinS32) { 1454431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" oppVal=%d", mSpan.fOppValue); 1464431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_WINDING 147570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com SkDebugf(" oppSum="); 1484431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkPathOpsDebug::WindingPrintf(mSpan.fOppSum); 1494431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 150570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 1514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (mSpan.fDone) { 152570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com SkDebugf(" done"); 153570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 1544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (unorderable()) { 1554431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" unorderable"); 156570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 1574431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (small()) { 1584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" small"); 159570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 1604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (mSpan.fTiny) { 161570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com SkDebugf(" tiny"); 162570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 1634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fSegment->operand()) { 1644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" operand"); 1654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 1664431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fStop) { 1674431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" stop"); 168570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com } 169570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com} 1704431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 1717eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 1724431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ANGLE 1734431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpAngle::debugSameAs(const SkOpAngle* compare) const { 1744431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(fSegment == compare->fSegment); 1754431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& startSpan = fSegment->span(fStart); 1764431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& oStartSpan = fSegment->span(compare->fStart); 1774431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(startSpan.fToAngleIndex == oStartSpan.fToAngleIndex); 1784431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(startSpan.fFromAngleIndex == oStartSpan.fFromAngleIndex); 1794431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& endSpan = fSegment->span(fEnd); 1804431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& oEndSpan = fSegment->span(compare->fEnd); 1814431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(endSpan.fToAngleIndex == oEndSpan.fToAngleIndex); 1824431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(endSpan.fFromAngleIndex == oEndSpan.fFromAngleIndex); 1837eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com} 1844431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 1857eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 1864431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_VALIDATE 1874431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpAngle::debugValidateNext() const { 1884431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* first = this; 1894431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* next = first; 1904431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTDArray<const SkOpAngle*>(angles); 1914431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org do { 1924431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(next->fSegment->debugContains(next)); 1934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org angles.push(next); 1944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->next(); 1954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (next == first) { 1964431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org break; 1974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 1984431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!angles.contains(next)); 1994431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!next) { 2004431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 2014431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } while (true); 2037eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com} 2047eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 2054431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpAngle::debugValidateLoop() const { 2064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* first = this; 2074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpAngle* next = first; 2084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(first->next() != first); 2094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int signSum = 0; 2104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppSum = 0; 2114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool firstOperand = fSegment->operand(); 2124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool unorderable = false; 2134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org do { 2144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org unorderable |= next->fUnorderable; 2154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSegment* segment = next->fSegment; 2164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool operandsMatch = firstOperand == segment->operand(); 2174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org signSum += operandsMatch ? segment->spanSign(next) : segment->oppSign(next); 2184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org oppSum += operandsMatch ? segment->oppSign(next) : segment->spanSign(next); 2194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& span = segment->span(SkMin32(next->fStart, next->fEnd)); 2204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (segment->_xor()) { 2214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(span.fWindValue == 1); 2224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(span.fWindSum == SK_MinS32 || span.fWindSum == 1); 2234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2244431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (segment->oppXor()) { 2254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(span.fOppValue == 0 || abs(span.fOppValue) == 1); 2264431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(span.fOppSum == SK_MinS32 || span.fOppSum == 0 || abs(span.fOppSum) == 1); 2274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->next(); 2294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!next) { 2304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 2314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } while (next != first); 2334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (unorderable) { 2344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 2354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!signSum || fSegment->_xor()); 2374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!oppSum || fSegment->oppXor()); 2384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int lastWinding; 2394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int lastOppWinding; 2404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int winding; 2414431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppWinding; 2424431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org do { 2434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSegment* segment = next->fSegment; 2444431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& span = segment->span(SkMin32(next->fStart, next->fEnd)); 2454431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org winding = span.fWindSum; 2464431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (winding != SK_MinS32) { 2474431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(winding != 0); 2484431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(winding)); 2494431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastWinding = winding; 2504431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int diffWinding = segment->spanSign(next); 2514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!segment->_xor()) { 2524431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(diffWinding != 0); 2534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool sameSign = (winding > 0) == (diffWinding > 0); 2544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org winding -= sameSign ? diffWinding : -diffWinding; 2554431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(winding)); 2564431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(abs(winding) <= abs(lastWinding)); 2574431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!sameSign) { 2584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTSwap(winding, lastWinding); 2594431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastOppWinding = oppWinding = span.fOppSum; 2624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (oppWinding != SK_MinS32 && !segment->oppXor()) { 2634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppDiffWinding = segment->oppSign(next); 2644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(abs(oppDiffWinding) <= abs(diffWinding) || segment->_xor()); 2654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (oppDiffWinding) { 2664431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool oppSameSign = (oppWinding > 0) == (oppDiffWinding > 0); 2674431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org oppWinding -= oppSameSign ? oppDiffWinding : -oppDiffWinding; 2684431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(oppWinding)); 2694431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(abs(oppWinding) <= abs(lastOppWinding)); 2704431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!oppSameSign) { 2714431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTSwap(oppWinding, lastOppWinding); 2724431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2734431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2744431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2754431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org firstOperand = segment->operand(); 2764431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org break; 2774431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2784431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(span.fOppSum == SK_MinS32); 2794431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->next(); 2804431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } while (next != first); 2814431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (winding == SK_MinS32) { 2824431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 2834431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2844431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(oppWinding == SK_MinS32 || SkPathOpsDebug::ValidWind(oppWinding)); 2854431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org first = next; 2864431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->next(); 2874431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org do { 2884431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSegment* segment = next->fSegment; 2894431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastWinding = winding; 2904431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastOppWinding = oppWinding; 2914431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool operandsMatch = firstOperand == segment->operand(); 2924431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (operandsMatch) { 2934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!segment->_xor()) { 2944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org winding -= segment->spanSign(next); 2954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(winding != lastWinding); 2964431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(winding)); 2974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 2984431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!segment->oppXor()) { 2994431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppDiffWinding = segment->oppSign(next); 3004431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (oppWinding != SK_MinS32) { 3014431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org oppWinding -= oppDiffWinding; 3024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(oppWinding)); 3034431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 3044431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(oppDiffWinding == 0); 3054431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 3084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!segment->oppXor()) { 3094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org winding -= segment->oppSign(next); 3104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(winding)); 3114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!segment->_xor()) { 3134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org oppWinding -= segment->spanSign(next); 3144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(oppWinding != lastOppWinding); 3154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkPathOpsDebug::ValidWind(oppWinding)); 3164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool useInner = SkOpSegment::UseInnerWinding(lastWinding, winding); 3194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int sumWinding = useInner ? winding : lastWinding; 3204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool oppUseInner = SkOpSegment::UseInnerWinding(lastOppWinding, oppWinding); 3214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppSumWinding = oppUseInner ? oppWinding : lastOppWinding; 3224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!operandsMatch) { 3234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTSwap(useInner, oppUseInner); 3244431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTSwap(sumWinding, oppSumWinding); 3254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3264431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& span = segment->span(SkMin32(next->fStart, next->fEnd)); 3274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (winding == -lastWinding) { 3284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (span.fWindSum != SK_MinS32) { 3294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s useInner=%d spanSign=%d lastWinding=%d winding=%d windSum=%d\n", 3304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org __FUNCTION__, 3314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org useInner, segment->spanSign(next), lastWinding, winding, span.fWindSum); 3324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (oppWinding != SK_MinS32) { 3354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (span.fOppSum != SK_MinS32) { 3364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(span.fOppSum == oppSumWinding || segment->oppXor() || segment->_xor()); 3374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 3394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!firstOperand); 3404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!segment->operand()); 3414431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!span.fOppValue); 3424431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org next = next->next(); 3444431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } while (next != first); 3457eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com} 3464431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 3477eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 3484431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_SWAP_TOP 3494431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgbool SkOpSegment::controlsContainedByEnds(int tStart, int tEnd) const { 3504431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fVerb != SkPath::kCubic_Verb) { 3514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return false; 3524431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDCubic dst = SkDCubic::SubDivide(fPts, fTs[tStart].fT, fTs[tEnd].fT); 3544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return dst.controlsContainedByEnds(); 3557eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com} 3564431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 3577eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com 3584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_CONCIDENT 3594431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK if pair has not already been added 3604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugAddTPair(double t, const SkOpSegment& other, double otherT) const { 3614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int i = 0; i < fTs.count(); ++i) { 3624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fTs[i].fT == t && fTs[i].fOther == &other && fTs[i].fOtherT == otherT) { 3634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 3644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3664431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(0); 3674431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 368570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com#endif 369a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com 3704431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ANGLE 3714431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugCheckPointsEqualish(int tStart, int tEnd) const { 3724431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkPoint& basePt = fTs[tStart].fPt; 3734431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org while (++tStart < tEnd) { 3744431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkPoint& cmpPt = fTs[tStart].fPt; 3754431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(SkDPoint::ApproximatelyEqual(basePt, cmpPt)); 3764431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 377a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com} 378a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com#endif 3794431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 3804431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_VALIDATE 3814431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgbool SkOpSegment::debugContains(const SkOpAngle* angle) const { 3824431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int index = 0; index < fAngles.count(); ++index) { 3834431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (&fAngles[index] == angle) { 3844431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return true; 3854431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3864431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3874431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int index = 0; index < fSingletonAngles.count(); ++index) { 3884431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (&fSingletonAngles[index] == angle) { 3894431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return true; 3904431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3914431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 3924431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return false; 3934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 3944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 3954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 3968cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org#if DEBUG_SWAP_TOP 3978cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.orgint SkOpSegment::debugInflections(int tStart, int tEnd) const { 3988cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org if (fVerb != SkPath::kCubic_Verb) { 3998cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org return false; 4008cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org } 4018cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org SkDCubic dst = SkDCubic::SubDivide(fPts, fTs[tStart].fT, fTs[tEnd].fT); 4028cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org double inflections[2]; 4038cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org return dst.findInflections(inflections); 4048cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org} 4058cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org#endif 4068cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org 4074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugReset() { 4084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fTs.reset(); 4094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fAngles.reset(); 4104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 4114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 4124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_CONCIDENT 4134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugShowTs(const char* prefix) const { 4144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s %s id=%d", __FUNCTION__, prefix, fID); 4154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int lastWind = -1; 4164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int lastOpp = -1; 4174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org double lastT = -1; 4184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int i; 4194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (i = 0; i < fTs.count(); ++i) { 4204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool change = lastT != fTs[i].fT || lastWind != fTs[i].fWindValue 4214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org || lastOpp != fTs[i].fOppValue; 4224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (change && lastWind >= 0) { 4234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" t=%1.3g %1.9g,%1.9g w=%d o=%d]", 4244431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastT, xyAtT(i - 1).fX, xyAtT(i - 1).fY, lastWind, lastOpp); 4254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4264431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (change) { 4274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" [o=%d", fTs[i].fOther->fID); 4284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastWind = fTs[i].fWindValue; 4294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastOpp = fTs[i].fOppValue; 4304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastT = fTs[i].fT; 4314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 4324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(",%d", fTs[i].fOther->fID); 4334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (i <= 0) { 4364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 4374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" t=%1.3g %1.9g,%1.9g w=%d o=%d]", 4394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastT, xyAtT(i - 1).fX, xyAtT(i - 1).fY, lastWind, lastOpp); 4404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fOperand) { 4414431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" operand"); 4424431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (done()) { 4444431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" done"); 4454431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4464431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("\n"); 4474431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 4484431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 4494431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 4504431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY 4514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugShowActiveSpans() const { 4524431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org debugValidate(); 4534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (done()) { 4544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return; 4554431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4564431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ACTIVE_SPANS_SHORT_FORM 4574431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int lastId = -1; 4584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org double lastT = -1; 4594431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 4604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int i = 0; i < fTs.count(); ++i) { 4614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fTs[i].fDone) { 4624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org continue; 4634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(i < fTs.count() - 1); 4654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_ACTIVE_SPANS_SHORT_FORM 4664431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (lastId == fID && lastT == fTs[i].fT) { 4674431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org continue; 4684431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4694431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastId = fID; 4704431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org lastT = fTs[i].fT; 4714431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 4724431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s id=%d", __FUNCTION__, fID); 4734431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY); 4744431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) { 4754431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY); 4764431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4774431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan* span = &fTs[i]; 4784431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(") t=%1.9g (%1.9g,%1.9g)", span->fT, xAtT(span), yAtT(span)); 4794431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int iEnd = i + 1; 4804431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org while (fTs[iEnd].fT < 1 && approximately_equal(fTs[i].fT, fTs[iEnd].fT)) { 4814431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org ++iEnd; 4824431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4834431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" tEnd=%1.9g", fTs[iEnd].fT); 4844431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSegment* other = fTs[i].fOther; 4854431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" other=%d otherT=%1.9g otherIndex=%d windSum=", 4864431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org other->fID, fTs[i].fOtherT, fTs[i].fOtherIndex); 4874431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fTs[i].fWindSum == SK_MinS32) { 4884431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("?"); 4894431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 4904431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%d", fTs[i].fWindSum); 4914431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4924431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" windValue=%d oppValue=%d\n", fTs[i].fWindValue, fTs[i].fOppValue); 4934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 4944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 4954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 4964431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 4974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_MARK_DONE || DEBUG_UNSORTABLE 4984431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding) { 4994431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkPoint& pt = xyAtT(&span); 5004431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s id=%d", fun, fID); 5014431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY); 5024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) { 5034431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY); 5044431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5054431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(&span == &span.fOther->fTs[span.fOtherIndex].fOther-> 5064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fTs[span.fOther->fTs[span.fOtherIndex].fOtherIndex]); 5074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(") t=%1.9g [%d] (%1.9g,%1.9g) tEnd=%1.9g newWindSum=%d windSum=", 5084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org span.fT, span.fOther->fTs[span.fOtherIndex].fOtherIndex, pt.fX, pt.fY, 5094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org (&span)[1].fT, winding); 5104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (span.fWindSum == SK_MinS32) { 5114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("?"); 5124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 5134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%d", span.fWindSum); 5144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" windValue=%d\n", span.fWindValue); 5164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 5174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 5184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding, 5194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int oppWinding) { 5204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkPoint& pt = xyAtT(&span); 5214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s id=%d", fun, fID); 5224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY); 5234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) { 5244431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY); 5254431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5264431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(&span == &span.fOther->fTs[span.fOtherIndex].fOther-> 5274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fTs[span.fOther->fTs[span.fOtherIndex].fOtherIndex]); 5284431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(") t=%1.9g [%d] (%1.9g,%1.9g) tEnd=%1.9g newWindSum=%d newOppSum=%d oppSum=", 5294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org span.fT, span.fOther->fTs[span.fOtherIndex].fOtherIndex, pt.fX, pt.fY, 5304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org (&span)[1].fT, winding, oppWinding); 5314431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (span.fOppSum == SK_MinS32) { 5324431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("?"); 5334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 5344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%d", span.fOppSum); 5354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" windSum="); 5374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (span.fWindSum == SK_MinS32) { 5384431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("?"); 5394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 5404431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%d", span.fWindSum); 5414431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5424431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf(" windValue=%d\n", span.fWindValue); 5434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 5444431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 5454431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 5464431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_SHOW_WINDING 5474431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgint SkOpSegment::debugShowWindingValues(int slotCount, int ofInterest) const { 5484431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (!(1 << fID & ofInterest)) { 5494431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return 0; 5504431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int sum = 0; 5524431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkTArray<char, true> slots(slotCount * 2); 5534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org memset(slots.begin(), ' ', slotCount * 2); 5544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int i = 0; i < fTs.count(); ++i) { 5554431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org // if (!(1 << fTs[i].fOther->fID & ofInterest)) { 5564431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org // continue; 5574431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org // } 5584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org sum += fTs[i].fWindValue; 5594431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org slots[fTs[i].fOther->fID - 1] = as_digit(fTs[i].fWindValue); 5604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org sum += fTs[i].fOppValue; 5614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org slots[slotCount + fTs[i].fOther->fID - 1] = as_digit(fTs[i].fOppValue); 5624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 5634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SkDebugf("%s id=%2d %.*s | %.*s\n", __FUNCTION__, fID, slotCount, slots.begin(), slotCount, 5644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org slots.begin() + slotCount); 5654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org return sum; 5664431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 5674431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 5684431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 5694431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.orgvoid SkOpSegment::debugValidate() const { 5704431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if DEBUG_VALIDATE 5714431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int count = fTs.count(); 5724431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(count >= 2); 5734431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(fTs[0].fT == 0); 5744431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(fTs[count - 1].fT == 1); 5754431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int done = 0; 5764431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org double t = -1; 5774431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan* last = NULL; 5784431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool tinyTFound = false; 5794431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool hasLoop = false; 5804431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org for (int i = 0; i < count; ++i) { 5814431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& span = fTs[i]; 5824431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(t <= span.fT); 5834431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org t = span.fT; 5844431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org int otherIndex = span.fOtherIndex; 5854431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSegment* other = span.fOther; 5864431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(other != this || fVerb == SkPath::kCubic_Verb); 5874431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org const SkOpSpan& otherSpan = other->fTs[otherIndex]; 5884431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(otherSpan.fPt == span.fPt); 5894431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(otherSpan.fOtherT == t); 5904431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(&fTs[i] == &otherSpan.fOther->fTs[otherSpan.fOtherIndex]); 5914431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org done += span.fDone; 5924431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (last) { 5934431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool tsEqual = last->fT == span.fT; 5944431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool tsPreciselyEqual = precisely_equal(last->fT, span.fT); 5954431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!tsEqual || tsPreciselyEqual); 5964431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool pointsEqual = last->fPt == span.fPt; 5974431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org bool pointsNearlyEqual = AlmostEqualUlps(last->fPt, span.fPt); 5984431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if 0 // bufferOverflow test triggers this 5994431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!tsPreciselyEqual || pointsNearlyEqual); 6004431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 6014431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(!last->fTiny || !tsPreciselyEqual || span.fTiny || tinyTFound); 6024431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(last->fTiny || tsPreciselyEqual || !pointsEqual || hasLoop); 6034431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!last->fTiny || pointsEqual); 6044431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!last->fTiny || last->fDone); 6054431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!last->fSmall || pointsNearlyEqual); 6064431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(!last->fSmall || last->fDone); 6074431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(!last->fSmall || last->fTiny); 6084431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org// SK_DEBUGBREAK(last->fTiny || !pointsEqual || last->fDone == span.fDone); 6094431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (last->fTiny) { 6104431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org tinyTFound |= !tsPreciselyEqual; 6114431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } else { 6124431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org tinyTFound = false; 6134431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 6144431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 6154431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org last = &span; 6164431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org hasLoop |= last->fLoop; 6174431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 6184431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org SK_DEBUGBREAK(done == fDoneSpans); 6194431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org if (fAngles.count() ) { 6204431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org fAngles.begin()->debugValidateLoop(); 6214431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org } 6224431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif 6234431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org} 624