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

Side by Side Diff: tools/render_pdfs_main.cpp

Issue 428443002: Cleanup: Rename SkOSPath functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 4 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 | « tools/picture_utils.cpp ('k') | tools/render_pictures_main.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 /** Builds the output filename. path = dir/name, and it replaces expected 105 /** Builds the output filename. path = dir/name, and it replaces expected
106 * .skp extension with .pdf extention. 106 * .skp extension with .pdf extention.
107 * @param path Output filename. 107 * @param path Output filename.
108 * @param name The name of the file. 108 * @param name The name of the file.
109 * @returns false if the file did not has the expected extension. 109 * @returns false if the file did not has the expected extension.
110 * if false is returned, contents of path are undefined. 110 * if false is returned, contents of path are undefined.
111 */ 111 */
112 static bool make_output_filepath(SkString* path, const SkString& dir, 112 static bool make_output_filepath(SkString* path, const SkString& dir,
113 const SkString& name) { 113 const SkString& name) {
114 *path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); 114 *path = SkOSPath::Join(dir.c_str(), name.c_str());
115 return replace_filename_extension(path, 115 return replace_filename_extension(path,
116 SKP_FILE_EXTENSION, 116 SKP_FILE_EXTENSION,
117 PDF_FILE_EXTENSION); 117 PDF_FILE_EXTENSION);
118 } 118 }
119 119
120 /** Write the output of pdf renderer to a file. 120 /** Write the output of pdf renderer to a file.
121 * @param outputDir Output dir. 121 * @param outputDir Output dir.
122 * @param inputFilename The skp file that was read. 122 * @param inputFilename The skp file that was read.
123 * @param renderer The object responsible to write the pdf file. 123 * @param renderer The object responsible to write the pdf file.
124 */ 124 */
(...skipping 17 matching lines...) Expand all
142 return stream; 142 return stream;
143 } 143 }
144 144
145 /** Reads an skp file, renders it to pdf and writes the output to a pdf file 145 /** Reads an skp file, renders it to pdf and writes the output to a pdf file
146 * @param inputPath The skp file to be read. 146 * @param inputPath The skp file to be read.
147 * @param outputDir Output dir. 147 * @param outputDir Output dir.
148 * @param renderer The object responsible to render the skp object into pdf. 148 * @param renderer The object responsible to render the skp object into pdf.
149 */ 149 */
150 static bool render_pdf(const SkString& inputPath, const SkString& outputDir, 150 static bool render_pdf(const SkString& inputPath, const SkString& outputDir,
151 sk_tools::PdfRenderer& renderer) { 151 sk_tools::PdfRenderer& renderer) {
152 SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); 152 SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
153 153
154 SkFILEStream inputStream; 154 SkFILEStream inputStream;
155 inputStream.setPath(inputPath.c_str()); 155 inputStream.setPath(inputPath.c_str());
156 if (!inputStream.isValid()) { 156 if (!inputStream.isValid()) {
157 SkDebugf("Could not open file %s\n", inputPath.c_str()); 157 SkDebugf("Could not open file %s\n", inputPath.c_str());
158 return false; 158 return false;
159 } 159 }
160 160
161 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream)); 161 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
162 162
(...skipping 27 matching lines...) Expand all
190 * @param outputDir Output dir. 190 * @param outputDir Output dir.
191 * @param renderer The object responsible to render the skp object into pdf. 191 * @param renderer The object responsible to render the skp object into pdf.
192 */ 192 */
193 static int process_input(const SkString& input, const SkString& outputDir, 193 static int process_input(const SkString& input, const SkString& outputDir,
194 sk_tools::PdfRenderer& renderer) { 194 sk_tools::PdfRenderer& renderer) {
195 int failures = 0; 195 int failures = 0;
196 if (sk_isdir(input.c_str())) { 196 if (sk_isdir(input.c_str())) {
197 SkOSFile::Iter iter(input.c_str(), SKP_FILE_EXTENSION); 197 SkOSFile::Iter iter(input.c_str(), SKP_FILE_EXTENSION);
198 SkString inputFilename; 198 SkString inputFilename;
199 while (iter.next(&inputFilename)) { 199 while (iter.next(&inputFilename)) {
200 SkString inputPath = SkOSPath::SkPathJoin(input.c_str(), inputFilena me.c_str()); 200 SkString inputPath = SkOSPath::Join(input.c_str(), inputFilename.c_s tr());
201 if (!render_pdf(inputPath, outputDir, renderer)) { 201 if (!render_pdf(inputPath, outputDir, renderer)) {
202 ++failures; 202 ++failures;
203 } 203 }
204 } 204 }
205 } else { 205 } else {
206 SkString inputPath(input); 206 SkString inputPath(input);
207 if (!render_pdf(inputPath, outputDir, renderer)) { 207 if (!render_pdf(inputPath, outputDir, renderer)) {
208 ++failures; 208 ++failures;
209 } 209 }
210 } 210 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 #endif 294 #endif
295 return 0; 295 return 0;
296 } 296 }
297 297
298 #if !defined SK_BUILD_FOR_IOS 298 #if !defined SK_BUILD_FOR_IOS
299 int main(int argc, char * const argv[]) { 299 int main(int argc, char * const argv[]) {
300 return tool_main(argc, (char**) argv); 300 return tool_main(argc, (char**) argv);
301 } 301 }
302 #endif 302 #endif
OLDNEW
« no previous file with comments | « tools/picture_utils.cpp ('k') | tools/render_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698