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

Side by Side Diff: experimental/PdfViewer/pdf_viewer_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 | « experimental/PdfViewer/chop_transparency_main.cpp ('k') | gm/gm_expectations.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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCommandLineFlags.h" 10 #include "SkCommandLineFlags.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 /** Builds the output filename. path = dir/name, and it replaces expected 96 /** Builds the output filename. path = dir/name, and it replaces expected
97 * .skp extension with .pdf extention. 97 * .skp extension with .pdf extention.
98 * @param path Output filename. 98 * @param path Output filename.
99 * @param name The name of the file. 99 * @param name The name of the file.
100 * @returns false if the file did not has the expected extension. 100 * @returns false if the file did not has the expected extension.
101 * if false is returned, contents of path are undefined. 101 * if false is returned, contents of path are undefined.
102 */ 102 */
103 static bool make_output_filepath(SkString* path, const SkString& dir, 103 static bool make_output_filepath(SkString* path, const SkString& dir,
104 const SkString& name, 104 const SkString& name,
105 int page) { 105 int page) {
106 *path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); 106 *path = SkOSPath::Join(dir.c_str(), name.c_str());
107 return add_page_and_replace_filename_extension(path, page, 107 return add_page_and_replace_filename_extension(path, page,
108 PDF_FILE_EXTENSION, 108 PDF_FILE_EXTENSION,
109 PNG_FILE_EXTENSION); 109 PNG_FILE_EXTENSION);
110 } 110 }
111 111
112 static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color) { 112 static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color) {
113 bitmap->allocN32Pixels(width, height); 113 bitmap->allocN32Pixels(width, height);
114 bitmap->eraseColor(color); 114 bitmap->eraseColor(color);
115 } 115 }
116 116
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return true; 214 return true;
215 } 215 }
216 216
217 /** Reads an skp file, renders it to pdf and writes the output to a pdf file 217 /** Reads an skp file, renders it to pdf and writes the output to a pdf file
218 * @param inputPath The skp file to be read. 218 * @param inputPath The skp file to be read.
219 * @param outputDir Output dir. 219 * @param outputDir Output dir.
220 */ 220 */
221 static bool process_pdf(const SkString& inputPath, const SkString& outputDir) { 221 static bool process_pdf(const SkString& inputPath, const SkString& outputDir) {
222 SkDebugf("Loading PDF: %s\n", inputPath.c_str()); 222 SkDebugf("Loading PDF: %s\n", inputPath.c_str());
223 223
224 SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); 224 SkString inputFilename = SkOSPath::Basename(inputPath.c_str());
225 225
226 SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(inputPat h.c_str())); 226 SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(inputPat h.c_str()));
227 if (NULL == renderer.get()) { 227 if (NULL == renderer.get()) {
228 SkDebugf("Failure loading file %s\n", inputPath.c_str()); 228 SkDebugf("Failure loading file %s\n", inputPath.c_str());
229 return false; 229 return false;
230 } 230 }
231 231
232 if (FLAGS_showMemoryUsage) { 232 if (FLAGS_showMemoryUsage) {
233 SkDebugf("Memory usage after load: %u\n", (unsigned int) renderer->bytes Used()); 233 SkDebugf("Memory usage after load: %u\n", (unsigned int) renderer->bytes Used());
234 } 234 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 * parse_pdf. 292 * parse_pdf.
293 * @param input A directory or an pdf file. 293 * @param input A directory or an pdf file.
294 * @param outputDir Output dir. 294 * @param outputDir Output dir.
295 */ 295 */
296 static int process_input(const char* input, const SkString& outputDir) { 296 static int process_input(const char* input, const SkString& outputDir) {
297 int failures = 0; 297 int failures = 0;
298 if (sk_isdir(input)) { 298 if (sk_isdir(input)) {
299 SkOSFile::Iter iter(input, PDF_FILE_EXTENSION); 299 SkOSFile::Iter iter(input, PDF_FILE_EXTENSION);
300 SkString inputFilename; 300 SkString inputFilename;
301 while (iter.next(&inputFilename)) { 301 while (iter.next(&inputFilename)) {
302 SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str ()); 302 SkString inputPath = SkOSPath::Join(input, inputFilename.c_str());
303 if (!process_pdf(inputPath, outputDir)) { 303 if (!process_pdf(inputPath, outputDir)) {
304 ++failures; 304 ++failures;
305 } 305 }
306 } 306 }
307 } else { 307 } else {
308 SkString inputPath(input); 308 SkString inputPath(input);
309 if (!process_pdf(inputPath, outputDir)) { 309 if (!process_pdf(inputPath, outputDir)) {
310 ++failures; 310 ++failures;
311 } 311 }
312 } 312 }
(...skipping 28 matching lines...) Expand all
341 } 341 }
342 342
343 return 0; 343 return 0;
344 } 344 }
345 345
346 #if !defined SK_BUILD_FOR_IOS 346 #if !defined SK_BUILD_FOR_IOS
347 int main(int argc, char * const argv[]) { 347 int main(int argc, char * const argv[]) {
348 return tool_main(argc, (char**) argv); 348 return tool_main(argc, (char**) argv);
349 } 349 }
350 #endif 350 #endif
OLDNEW
« no previous file with comments | « experimental/PdfViewer/chop_transparency_main.cpp ('k') | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698