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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsDebug.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,161 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#include "SkPathOpsDebug.h"
    1.12 +#include "SkPath.h"
    1.13 +
    1.14 +#if defined SK_DEBUG || !FORCE_RELEASE
    1.15 +
    1.16 +int SkPathOpsDebug::gMaxWindSum = SK_MaxS32;
    1.17 +int SkPathOpsDebug::gMaxWindValue = SK_MaxS32;
    1.18 +
    1.19 +const char* SkPathOpsDebug::kLVerbStr[] = {"", "line", "quad", "cubic"};
    1.20 +int SkPathOpsDebug::gContourID;
    1.21 +int SkPathOpsDebug::gSegmentID;
    1.22 +
    1.23 +#if DEBUG_SORT || DEBUG_SWAP_TOP
    1.24 +int SkPathOpsDebug::gSortCountDefault = SK_MaxS32;
    1.25 +int SkPathOpsDebug::gSortCount;
    1.26 +#endif
    1.27 +
    1.28 +#if DEBUG_ACTIVE_OP
    1.29 +const char* SkPathOpsDebug::kPathOpStr[] = {"diff", "sect", "union", "xor"};
    1.30 +#endif
    1.31 +
    1.32 +void SkPathOpsDebug::MathematicaIze(char* str, size_t bufferLen) {
    1.33 +    size_t len = strlen(str);
    1.34 +    bool num = false;
    1.35 +    for (size_t idx = 0; idx < len; ++idx) {
    1.36 +        if (num && str[idx] == 'e') {
    1.37 +            if (len + 2 >= bufferLen) {
    1.38 +                return;
    1.39 +            }
    1.40 +            memmove(&str[idx + 2], &str[idx + 1], len - idx);
    1.41 +            str[idx] = '*';
    1.42 +            str[idx + 1] = '^';
    1.43 +            ++len;
    1.44 +        }
    1.45 +        num = str[idx] >= '0' && str[idx] <= '9';
    1.46 +    }
    1.47 +}
    1.48 +
    1.49 +bool SkPathOpsDebug::ValidWind(int wind) {
    1.50 +    return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
    1.51 +}
    1.52 +
    1.53 +void SkPathOpsDebug::WindingPrintf(int wind) {
    1.54 +    if (wind == SK_MinS32) {
    1.55 +        SkDebugf("?");
    1.56 +    } else {
    1.57 +        SkDebugf("%d", wind);
    1.58 +    }
    1.59 +}
    1.60 +
    1.61 +#if DEBUG_SHOW_TEST_NAME
    1.62 +void* SkPathOpsDebug::CreateNameStr() {
    1.63 +    return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH);
    1.64 +}
    1.65 +
    1.66 +void SkPathOpsDebug::DeleteNameStr(void* v) {
    1.67 +    SkDELETE_ARRAY(reinterpret_cast<char* >(v));
    1.68 +}
    1.69 +
    1.70 +void SkPathOpsDebug::BumpTestName(char* test) {
    1.71 +    char* num = test + strlen(test);
    1.72 +    while (num[-1] >= '0' && num[-1] <= '9') {
    1.73 +        --num;
    1.74 +    }
    1.75 +    if (num[0] == '\0') {
    1.76 +        return;
    1.77 +    }
    1.78 +    int dec = atoi(num);
    1.79 +    if (dec == 0) {
    1.80 +        return;
    1.81 +    }
    1.82 +    ++dec;
    1.83 +    SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec);
    1.84 +}
    1.85 +#endif
    1.86 +
    1.87 +#include "SkOpSegment.h"
    1.88 +
    1.89 +void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle, true>& angles) {
    1.90 +    int count = angles.count();
    1.91 +    for (int index = 0; index < count; ++index) {
    1.92 +        angles[index].dump();
    1.93 +    }
    1.94 +}
    1.95 +
    1.96 +void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle* , true>& angles) {
    1.97 +    int count = angles.count();
    1.98 +    for (int index = 0; index < count; ++index) {
    1.99 +        angles[index]->dump();
   1.100 +    }
   1.101 +}
   1.102 +#endif  // SK_DEBUG || !FORCE_RELEASE
   1.103 +
   1.104 +#ifdef SK_DEBUG
   1.105 +void SkOpSpan::dump() const {
   1.106 +    SkDebugf("t=");
   1.107 +    DebugDumpDouble(fT);
   1.108 +    SkDebugf(" pt=");
   1.109 +    SkDPoint::dump(fPt);
   1.110 +    SkDebugf(" other.fID=%d", fOther->debugID());
   1.111 +    SkDebugf(" [%d] otherT=", fOtherIndex);
   1.112 +    DebugDumpDouble(fOtherT);
   1.113 +    SkDebugf(" windSum=");
   1.114 +    SkPathOpsDebug::WindingPrintf(fWindSum);
   1.115 +    if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
   1.116 +        SkDebugf(" oppSum=");
   1.117 +        SkPathOpsDebug::WindingPrintf(fOppSum);
   1.118 +    }
   1.119 +    SkDebugf(" windValue=%d", fWindValue);
   1.120 +    if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
   1.121 +        SkDebugf(" oppValue=%d", fOppValue);
   1.122 +    }
   1.123 +    if (fDone) {
   1.124 +        SkDebugf(" done");
   1.125 +    }
   1.126 +    if (fUnsortableStart) {
   1.127 +        SkDebugf("  unsortable-start");
   1.128 +    }
   1.129 +    if (fUnsortableEnd) {
   1.130 +        SkDebugf(" unsortable-end");
   1.131 +    }
   1.132 +    if (fTiny) {
   1.133 +        SkDebugf(" tiny");
   1.134 +    } else if (fSmall) {
   1.135 +        SkDebugf(" small");
   1.136 +    }
   1.137 +    if (fLoop) {
   1.138 +        SkDebugf(" loop");
   1.139 +    }
   1.140 +    SkDebugf("\n");
   1.141 +}
   1.142 +
   1.143 +void Dump(const SkTArray<class SkOpAngle, true>& angles) {
   1.144 +    SkPathOpsDebug::DumpAngles(angles);
   1.145 +}
   1.146 +
   1.147 +void Dump(const SkTArray<class SkOpAngle* , true>& angles) {
   1.148 +    SkPathOpsDebug::DumpAngles(angles);
   1.149 +}
   1.150 +
   1.151 +void Dump(const SkTArray<class SkOpAngle, true>* angles) {
   1.152 +    SkPathOpsDebug::DumpAngles(*angles);
   1.153 +}
   1.154 +
   1.155 +void Dump(const SkTArray<class SkOpAngle* , true>* angles) {
   1.156 +    SkPathOpsDebug::DumpAngles(*angles);
   1.157 +}
   1.158 +
   1.159 +#endif
   1.160 +
   1.161 +#if !FORCE_RELEASE && 0  // enable when building without extended test
   1.162 +void SkPathOpsDebug::ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name) {
   1.163 +}
   1.164 +#endif

mercurial