2013-02-14 18:57:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
// These functions dump 0, 1, and 2d arrays of data in a format that's
|
2013-02-14 18:57:59 +00:00
|
|
|
// compatible with Mathematica for quick visualization
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
inline void SkDebugDumpMathematica( const T val ) {
|
|
|
|
SkDEBUGFAIL("Need to specialize SkDebugDumpMathematica for your type, sorry.");
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<class T>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica(const char *name, const T *array, int size) {
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", name);
|
2013-02-14 18:57:59 +00:00
|
|
|
SkDebugf(" = {");
|
|
|
|
for (int i=0 ; i < size ; i++) {
|
|
|
|
SkDebugDumpMathematica<T>(array[i]);
|
|
|
|
if (i != size-1) SkDebugf(", ");
|
|
|
|
}
|
|
|
|
SkDebugf("};\n");
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<class T>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica(const char *name, const T *array, int width, int height) {
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", name);
|
2013-02-14 18:57:59 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<class T>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica( const char *name, const T val ) {
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", name);
|
2013-02-14 18:57:59 +00:00
|
|
|
SkDebugf(" = ");
|
|
|
|
SkDebugDumpMathematica<T>(val);
|
|
|
|
SkDebugf(";\n");
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica<uint8_t>( const uint8_t val ) {
|
|
|
|
SkDebugf("%u", val);
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica<unsigned int>( const unsigned int val ) {
|
|
|
|
SkDebugf("%u", val);
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica<int>( const int val ) {
|
|
|
|
SkDebugf("%d", val);
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica<size_t>( const size_t val ) {
|
|
|
|
SkDebugf("%u", val);
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
void SkDebugDumpMathematica<const char *>( const char * val ) {
|
|
|
|
SkDebugf("%s", val);
|
|
|
|
}
|
|
|
|
|
2013-02-15 07:16:57 +00:00
|
|
|
template<>
|
2013-02-14 18:57:59 +00:00
|
|
|
inline void SkDebugDumpMathematica<float>( float val ) {
|
|
|
|
SkDebugf("%f", val);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|