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.

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

mercurial