gfx/skia/trunk/src/pathops/SkPathOpsDebug.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright 2013 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #include "SkPathOpsDebug.h"
michael@0 9 #include "SkPath.h"
michael@0 10
michael@0 11 #if defined SK_DEBUG || !FORCE_RELEASE
michael@0 12
michael@0 13 int SkPathOpsDebug::gMaxWindSum = SK_MaxS32;
michael@0 14 int SkPathOpsDebug::gMaxWindValue = SK_MaxS32;
michael@0 15
michael@0 16 const char* SkPathOpsDebug::kLVerbStr[] = {"", "line", "quad", "cubic"};
michael@0 17 int SkPathOpsDebug::gContourID;
michael@0 18 int SkPathOpsDebug::gSegmentID;
michael@0 19
michael@0 20 #if DEBUG_SORT || DEBUG_SWAP_TOP
michael@0 21 int SkPathOpsDebug::gSortCountDefault = SK_MaxS32;
michael@0 22 int SkPathOpsDebug::gSortCount;
michael@0 23 #endif
michael@0 24
michael@0 25 #if DEBUG_ACTIVE_OP
michael@0 26 const char* SkPathOpsDebug::kPathOpStr[] = {"diff", "sect", "union", "xor"};
michael@0 27 #endif
michael@0 28
michael@0 29 void SkPathOpsDebug::MathematicaIze(char* str, size_t bufferLen) {
michael@0 30 size_t len = strlen(str);
michael@0 31 bool num = false;
michael@0 32 for (size_t idx = 0; idx < len; ++idx) {
michael@0 33 if (num && str[idx] == 'e') {
michael@0 34 if (len + 2 >= bufferLen) {
michael@0 35 return;
michael@0 36 }
michael@0 37 memmove(&str[idx + 2], &str[idx + 1], len - idx);
michael@0 38 str[idx] = '*';
michael@0 39 str[idx + 1] = '^';
michael@0 40 ++len;
michael@0 41 }
michael@0 42 num = str[idx] >= '0' && str[idx] <= '9';
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 bool SkPathOpsDebug::ValidWind(int wind) {
michael@0 47 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
michael@0 48 }
michael@0 49
michael@0 50 void SkPathOpsDebug::WindingPrintf(int wind) {
michael@0 51 if (wind == SK_MinS32) {
michael@0 52 SkDebugf("?");
michael@0 53 } else {
michael@0 54 SkDebugf("%d", wind);
michael@0 55 }
michael@0 56 }
michael@0 57
michael@0 58 #if DEBUG_SHOW_TEST_NAME
michael@0 59 void* SkPathOpsDebug::CreateNameStr() {
michael@0 60 return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH);
michael@0 61 }
michael@0 62
michael@0 63 void SkPathOpsDebug::DeleteNameStr(void* v) {
michael@0 64 SkDELETE_ARRAY(reinterpret_cast<char* >(v));
michael@0 65 }
michael@0 66
michael@0 67 void SkPathOpsDebug::BumpTestName(char* test) {
michael@0 68 char* num = test + strlen(test);
michael@0 69 while (num[-1] >= '0' && num[-1] <= '9') {
michael@0 70 --num;
michael@0 71 }
michael@0 72 if (num[0] == '\0') {
michael@0 73 return;
michael@0 74 }
michael@0 75 int dec = atoi(num);
michael@0 76 if (dec == 0) {
michael@0 77 return;
michael@0 78 }
michael@0 79 ++dec;
michael@0 80 SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec);
michael@0 81 }
michael@0 82 #endif
michael@0 83
michael@0 84 #include "SkOpSegment.h"
michael@0 85
michael@0 86 void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle, true>& angles) {
michael@0 87 int count = angles.count();
michael@0 88 for (int index = 0; index < count; ++index) {
michael@0 89 angles[index].dump();
michael@0 90 }
michael@0 91 }
michael@0 92
michael@0 93 void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle* , true>& angles) {
michael@0 94 int count = angles.count();
michael@0 95 for (int index = 0; index < count; ++index) {
michael@0 96 angles[index]->dump();
michael@0 97 }
michael@0 98 }
michael@0 99 #endif // SK_DEBUG || !FORCE_RELEASE
michael@0 100
michael@0 101 #ifdef SK_DEBUG
michael@0 102 void SkOpSpan::dump() const {
michael@0 103 SkDebugf("t=");
michael@0 104 DebugDumpDouble(fT);
michael@0 105 SkDebugf(" pt=");
michael@0 106 SkDPoint::dump(fPt);
michael@0 107 SkDebugf(" other.fID=%d", fOther->debugID());
michael@0 108 SkDebugf(" [%d] otherT=", fOtherIndex);
michael@0 109 DebugDumpDouble(fOtherT);
michael@0 110 SkDebugf(" windSum=");
michael@0 111 SkPathOpsDebug::WindingPrintf(fWindSum);
michael@0 112 if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
michael@0 113 SkDebugf(" oppSum=");
michael@0 114 SkPathOpsDebug::WindingPrintf(fOppSum);
michael@0 115 }
michael@0 116 SkDebugf(" windValue=%d", fWindValue);
michael@0 117 if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
michael@0 118 SkDebugf(" oppValue=%d", fOppValue);
michael@0 119 }
michael@0 120 if (fDone) {
michael@0 121 SkDebugf(" done");
michael@0 122 }
michael@0 123 if (fUnsortableStart) {
michael@0 124 SkDebugf(" unsortable-start");
michael@0 125 }
michael@0 126 if (fUnsortableEnd) {
michael@0 127 SkDebugf(" unsortable-end");
michael@0 128 }
michael@0 129 if (fTiny) {
michael@0 130 SkDebugf(" tiny");
michael@0 131 } else if (fSmall) {
michael@0 132 SkDebugf(" small");
michael@0 133 }
michael@0 134 if (fLoop) {
michael@0 135 SkDebugf(" loop");
michael@0 136 }
michael@0 137 SkDebugf("\n");
michael@0 138 }
michael@0 139
michael@0 140 void Dump(const SkTArray<class SkOpAngle, true>& angles) {
michael@0 141 SkPathOpsDebug::DumpAngles(angles);
michael@0 142 }
michael@0 143
michael@0 144 void Dump(const SkTArray<class SkOpAngle* , true>& angles) {
michael@0 145 SkPathOpsDebug::DumpAngles(angles);
michael@0 146 }
michael@0 147
michael@0 148 void Dump(const SkTArray<class SkOpAngle, true>* angles) {
michael@0 149 SkPathOpsDebug::DumpAngles(*angles);
michael@0 150 }
michael@0 151
michael@0 152 void Dump(const SkTArray<class SkOpAngle* , true>* angles) {
michael@0 153 SkPathOpsDebug::DumpAngles(*angles);
michael@0 154 }
michael@0 155
michael@0 156 #endif
michael@0 157
michael@0 158 #if !FORCE_RELEASE && 0 // enable when building without extended test
michael@0 159 void SkPathOpsDebug::ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name) {
michael@0 160 }
michael@0 161 #endif

mercurial