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

Side by Side Diff: experimental/PdfViewer/pdf_viewer_main.cpp

Issue 18293012: pdf viewer: fix a few warnings, and enable warning as errors (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 #include "SkCanvas.h" 1 #include "SkCanvas.h"
2 #include "SkDevice.h" 2 #include "SkDevice.h"
3 #include "SkForceLinking.h" 3 #include "SkForceLinking.h"
4 #include "SkGraphics.h" 4 #include "SkGraphics.h"
5 #include "SkImageDecoder.h" 5 #include "SkImageDecoder.h"
6 #include "SkImageEncoder.h" 6 #include "SkImageEncoder.h"
7 #include "SkOSFile.h" 7 #include "SkOSFile.h"
8 #include "SkPicture.h" 8 #include "SkPicture.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 30 matching lines...) Expand all
41 SkDebugf("\n"); 41 SkDebugf("\n");
42 } 42 }
43 43
44 /** Replaces the extension of a file. 44 /** Replaces the extension of a file.
45 * @param path File name whose extension will be changed. 45 * @param path File name whose extension will be changed.
46 * @param old_extension The old extension. 46 * @param old_extension The old extension.
47 * @param new_extension The new extension. 47 * @param new_extension The new extension.
48 * @returns false if the file did not has the expected extension. 48 * @returns false if the file did not has the expected extension.
49 * if false is returned, contents of path are undefined. 49 * if false is returned, contents of path are undefined.
50 */ 50 */
51 /*
51 static bool replace_filename_extension(SkString* path, 52 static bool replace_filename_extension(SkString* path,
52 const char old_extension[], 53 const char old_extension[],
53 const char new_extension[]) { 54 const char new_extension[]) {
54 if (path->endsWith(old_extension)) { 55 if (path->endsWith(old_extension)) {
55 path->remove(path->size() - strlen(old_extension), 56 path->remove(path->size() - strlen(old_extension),
56 strlen(old_extension)); 57 strlen(old_extension));
57 if (!path->endsWith(".")) { 58 if (!path->endsWith(".")) {
58 return false; 59 return false;
59 } 60 }
60 path->append(new_extension); 61 path->append(new_extension);
61 return true; 62 return true;
62 } 63 }
63 return false; 64 return false;
64 } 65 }
65 66 */
66 /** Builds the output filename. path = dir/name, and it replaces expected 67 /** Builds the output filename. path = dir/name, and it replaces expected
67 * .skp extension with .pdf extention. 68 * .skp extension with .pdf extention.
68 * @param path Output filename. 69 * @param path Output filename.
69 * @param name The name of the file. 70 * @param name The name of the file.
70 * @returns false if the file did not has the expected extension. 71 * @returns false if the file did not has the expected extension.
71 * if false is returned, contents of path are undefined. 72 * if false is returned, contents of path are undefined.
72 */ 73 */
74
75 /*
73 static bool make_output_filepath(SkString* path, const SkString& dir, 76 static bool make_output_filepath(SkString* path, const SkString& dir,
74 const SkString& name) { 77 const SkString& name) {
75 sk_tools::make_filepath(path, dir, name); 78 sk_tools::make_filepath(path, dir, name);
76 return replace_filename_extension(path, 79 return replace_filename_extension(path,
77 PDF_FILE_EXTENSION, 80 PDF_FILE_EXTENSION,
78 PNG_FILE_EXTENSION); 81 PNG_FILE_EXTENSION);
79 } 82 }
80 83 */
81 /** Write the output of pdf renderer to a file. 84 /** Write the output of pdf renderer to a file.
82 * @param outputDir Output dir. 85 * @param outputDir Output dir.
83 * @param inputFilename The skp file that was read. 86 * @param inputFilename The skp file that was read.
84 * @param renderer The object responsible to write the pdf file. 87 * @param renderer The object responsible to write the pdf file.
85 */ 88 */
89 /*
86 static bool write_output(const SkString& outputDir, 90 static bool write_output(const SkString& outputDir,
87 const SkString& inputFilename, 91 const SkString& inputFilename,
88 const SkPdfViewer& renderer) { 92 const SkPdfViewer& renderer) {
89 if (outputDir.isEmpty()) { 93 if (outputDir.isEmpty()) {
90 SkDynamicMemoryWStream stream; 94 SkDynamicMemoryWStream stream;
91 renderer.write(&stream); 95 renderer.write(&stream);
92 return true; 96 return true;
93 } 97 }
94 98
95 SkString outputPath; 99 SkString outputPath;
96 if (!make_output_filepath(&outputPath, outputDir, inputFilename)) { 100 if (!make_output_filepath(&outputPath, outputDir, inputFilename)) {
97 return false; 101 return false;
98 } 102 }
99 103
100 SkFILEWStream stream(outputPath.c_str()); 104 SkFILEWStream stream(outputPath.c_str());
101 if (!stream.isValid()) { 105 if (!stream.isValid()) {
102 SkDebugf("Could not write to file %s\n", outputPath.c_str()); 106 SkDebugf("Could not write to file %s\n", outputPath.c_str());
103 return false; 107 return false;
104 } 108 }
105 renderer.write(&stream); 109 renderer.write(&stream);
106 110
107 return true; 111 return true;
108 } 112 }
109 113 */
110 /** Reads an skp file, renders it to pdf and writes the output to a pdf file 114 /** Reads an skp file, renders it to pdf and writes the output to a pdf file
111 * @param inputPath The skp file to be read. 115 * @param inputPath The skp file to be read.
112 * @param outputDir Output dir. 116 * @param outputDir Output dir.
113 * @param renderer The object responsible to render the skp object into pdf. 117 * @param renderer The object responsible to render the skp object into pdf.
114 */ 118 */
115 static bool parse_pdf(const SkString& inputPath, const SkString& outputDir, 119 static bool parse_pdf(const SkString& inputPath, const SkString& outputDir,
116 SkPdfViewer& renderer) { 120 SkPdfViewer& renderer) {
117 SkString inputFilename; 121 SkString inputFilename;
118 sk_tools::get_basename(&inputFilename, inputPath); 122 sk_tools::get_basename(&inputFilename, inputPath);
119 123
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 221 }
218 222
219 return 0; 223 return 0;
220 } 224 }
221 225
222 #if !defined SK_BUILD_FOR_IOS 226 #if !defined SK_BUILD_FOR_IOS
223 int main(int argc, char * const argv[]) { 227 int main(int argc, char * const argv[]) {
224 return tool_main(argc, (char**) argv); 228 return tool_main(argc, (char**) argv);
225 } 229 }
226 #endif 230 #endif
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfParser.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698