1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright 2013 Google, Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDebugUtils_DEFINED
#define SkDebugUtils_DEFINED
#include "SkTypes.h"
// These functions dump 0, 1, and 2d arrays of data in a format that's
// compatible with Mathematica for quick visualization
template<class T>
inline void SkDebugDumpMathematica( const T val ) {
SkDEBUGFAIL("Need to specialize SkDebugDumpMathematica for your type, sorry.");
}
template<class T>
inline void SkDebugDumpMathematica(const char *name, const T *array, int size) {
SkDebugf(name);
SkDebugf(" = {");
for (int i=0 ; i < size ; i++) {
SkDebugDumpMathematica<T>(array[i]);
if (i != size-1) SkDebugf(", ");
}
SkDebugf("};\n");
}
template<class T>
inline void SkDebugDumpMathematica(const char *name, const T *array, int width, int height) {
SkDebugf(name);
SkDebugf(" = {\n");
for (int i=0 ; i < height ; i++) {
SkDebugf(" {");
for (int j = 0 ; j < width ; j++) {
SkDebugDumpMathematica<T>(array[i*width + j]);
if (j != width-1) {
SkDebugf(", ");
}
}
SkDebugf("}");
if (i != height-1) {
SkDebugf(", \n");
}
}
SkDebugf("\n};\n");
}
template<class T>
inline void SkDebugDumpMathematica( const char *name, const T val ) {
SkDebugf(name);
SkDebugf(" = ");
SkDebugDumpMathematica<T>(val);
SkDebugf(";\n");
}
template<>
inline void SkDebugDumpMathematica<uint8_t>( const uint8_t val ) {
SkDebugf("%u", val);
}
template<>
inline void SkDebugDumpMathematica<unsigned int>( const unsigned int val ) {
SkDebugf("%u", val);
}
template<>
inline void SkDebugDumpMathematica<int>( const int val ) {
SkDebugf("%d", val);
}
template<>
inline void SkDebugDumpMathematica<size_t>( const size_t val ) {
SkDebugf("%u", val);
}
template<>
void SkDebugDumpMathematica<const char *>( const char * val ) {
SkDebugf("%s", val);
}
template<>
inline void SkDebugDumpMathematica<float>( float val ) {
SkDebugf("%f", val);
}
#endif
|