Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: include/utils/SkDebugUtils.h

Issue 943453002: Avoid wrong memory access due to double substitution and %% (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google, Inc. 3 * Copyright 2013 Google, Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkDebugUtils_DEFINED 10 #ifndef SkDebugUtils_DEFINED
11 #define SkDebugUtils_DEFINED 11 #define SkDebugUtils_DEFINED
12 12
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 // These functions dump 0, 1, and 2d arrays of data in a format that's 15 // These functions dump 0, 1, and 2d arrays of data in a format that's
16 // compatible with Mathematica for quick visualization 16 // compatible with Mathematica for quick visualization
17 17
18 18
19 template<class T> 19 template<class T>
20 inline void SkDebugDumpMathematica( const T val ) { 20 inline void SkDebugDumpMathematica( const T val ) {
21 SkDEBUGFAIL("Need to specialize SkDebugDumpMathematica for your type, sorry. "); 21 SkDEBUGFAIL("Need to specialize SkDebugDumpMathematica for your type, sorry. ");
22 } 22 }
23 23
24 template<class T> 24 template<class T>
25 inline void SkDebugDumpMathematica(const char *name, const T *array, int size) { 25 inline void SkDebugDumpMathematica(const char *name, const T *array, int size) {
26 SkDebugf(name); 26 SkDebugf("%s", name);
27 SkDebugf(" = {"); 27 SkDebugf(" = {");
28 for (int i=0 ; i < size ; i++) { 28 for (int i=0 ; i < size ; i++) {
29 SkDebugDumpMathematica<T>(array[i]); 29 SkDebugDumpMathematica<T>(array[i]);
30 if (i != size-1) SkDebugf(", "); 30 if (i != size-1) SkDebugf(", ");
31 } 31 }
32 SkDebugf("};\n"); 32 SkDebugf("};\n");
33 } 33 }
34 34
35 template<class T> 35 template<class T>
36 inline void SkDebugDumpMathematica(const char *name, const T *array, int width, int height) { 36 inline void SkDebugDumpMathematica(const char *name, const T *array, int width, int height) {
37 SkDebugf(name); 37 SkDebugf("%s", name);
38 SkDebugf(" = {\n"); 38 SkDebugf(" = {\n");
39 for (int i=0 ; i < height ; i++) { 39 for (int i=0 ; i < height ; i++) {
40 SkDebugf(" {"); 40 SkDebugf(" {");
41 for (int j = 0 ; j < width ; j++) { 41 for (int j = 0 ; j < width ; j++) {
42 SkDebugDumpMathematica<T>(array[i*width + j]); 42 SkDebugDumpMathematica<T>(array[i*width + j]);
43 if (j != width-1) { 43 if (j != width-1) {
44 SkDebugf(", "); 44 SkDebugf(", ");
45 } 45 }
46 } 46 }
47 SkDebugf("}"); 47 SkDebugf("}");
48 if (i != height-1) { 48 if (i != height-1) {
49 SkDebugf(", \n"); 49 SkDebugf(", \n");
50 } 50 }
51 } 51 }
52 SkDebugf("\n};\n"); 52 SkDebugf("\n};\n");
53 } 53 }
54 54
55 template<class T> 55 template<class T>
56 inline void SkDebugDumpMathematica( const char *name, const T val ) { 56 inline void SkDebugDumpMathematica( const char *name, const T val ) {
57 SkDebugf(name); 57 SkDebugf("%s", name);
58 SkDebugf(" = "); 58 SkDebugf(" = ");
59 SkDebugDumpMathematica<T>(val); 59 SkDebugDumpMathematica<T>(val);
60 SkDebugf(";\n"); 60 SkDebugf(";\n");
61 } 61 }
62 62
63 template<> 63 template<>
64 inline void SkDebugDumpMathematica<uint8_t>( const uint8_t val ) { 64 inline void SkDebugDumpMathematica<uint8_t>( const uint8_t val ) {
65 SkDebugf("%u", val); 65 SkDebugf("%u", val);
66 } 66 }
67 67
(...skipping 17 matching lines...) Expand all
85 SkDebugf("%s", val); 85 SkDebugf("%s", val);
86 } 86 }
87 87
88 template<> 88 template<>
89 inline void SkDebugDumpMathematica<float>( float val ) { 89 inline void SkDebugDumpMathematica<float>( float val ) {
90 SkDebugf("%f", val); 90 SkDebugf("%f", val);
91 } 91 }
92 92
93 93
94 #endif 94 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698