| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 SkPaint paint; | 76 SkPaint paint; |
| 77 paint.setAntiAlias(true); | 77 paint.setAntiAlias(true); |
| 78 paint.setTextSize(SkIntToScalar(30)); | 78 paint.setTextSize(SkIntToScalar(30)); |
| 79 paint.setTextAlign(SkPaint::kCenter_Align); | 79 paint.setTextAlign(SkPaint::kCenter_Align); |
| 80 | 80 |
| 81 SkScalar width = paint.measureText(text.c_str(), text.size()); | 81 SkScalar width = paint.measureText(text.c_str(), text.size()); |
| 82 SkScalar spacing = paint.getFontSpacing(); | 82 SkScalar spacing = paint.getFontSpacing(); |
| 83 | 83 |
| 84 int w = SkScalarRound(width) + 30; | 84 int w = SkScalarRoundToInt(width) + 30; |
| 85 int h = SkScalarRound(spacing) + 30; | 85 int h = SkScalarRoundToInt(spacing) + 30; |
| 86 | 86 |
| 87 static const struct { | 87 static const struct { |
| 88 bool (*fProc)(int w, int h, const char path[], const char text[], | 88 bool (*fProc)(int w, int h, const char path[], const char text[], |
| 89 const SkPaint&); | 89 const SkPaint&); |
| 90 const char* fSuffix; | 90 const char* fSuffix; |
| 91 } gRec[] = { | 91 } gRec[] = { |
| 92 { do_surface, ".png" }, | 92 { do_surface, ".png" }, |
| 93 { do_document, ".pdf" }, | 93 { do_document, ".pdf" }, |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 96 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 97 SkString file; | 97 SkString file; |
| 98 file.printf("%s%s", path.c_str(), gRec[i].fSuffix); | 98 file.printf("%s%s", path.c_str(), gRec[i].fSuffix); |
| 99 if (!gRec[i].fProc(w, h, file.c_str(), text.c_str(), paint)) { | 99 if (!gRec[i].fProc(w, h, file.c_str(), text.c_str(), paint)) { |
| 100 return -1; | 100 return -1; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 #if !defined SK_BUILD_FOR_IOS | 106 #if !defined SK_BUILD_FOR_IOS |
| 107 int main(int argc, char * const argv[]) { | 107 int main(int argc, char * const argv[]) { |
| 108 return tool_main(argc, (char**) argv); | 108 return tool_main(argc, (char**) argv); |
| 109 } | 109 } |
| 110 #endif | 110 #endif |
| OLD | NEW |