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

Side by Side Diff: tools/picture_utils.cpp

Issue 327403002: Cleanup: Delete sk_tools::make_filepath() in favor of SkOSPath::SkPathJoin(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes Created 6 years, 6 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.h ('k') | tools/render_pdfs_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 "picture_utils.h" 8 #include "picture_utils.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 23 matching lines...) Expand all
34 if (NULL == str) { 34 if (NULL == str) {
35 return; 35 return;
36 } 36 }
37 for (size_t i = 0; i < str->size(); ++i) { 37 for (size_t i = 0; i < str->size(); ++i) {
38 if (oldChar == str->operator[](i)) { 38 if (oldChar == str->operator[](i)) {
39 str->operator[](i) = newChar; 39 str->operator[](i) = newChar;
40 } 40 }
41 } 41 }
42 } 42 }
43 43
44 void make_filepath(SkString* path, const SkString& dir, const SkString& name ) {
45 size_t len = dir.size();
46 path->set(dir);
47 if (0 < len && '/' != dir[len - 1]) {
48 path->append("/");
49 }
50 path->append(name);
51 }
52
53 bool is_percentage(const char* const string) { 44 bool is_percentage(const char* const string) {
54 SkString skString(string); 45 SkString skString(string);
55 return skString.endsWith("%"); 46 return skString.endsWith("%");
56 } 47 }
57 48
58 void setup_bitmap(SkBitmap* bitmap, int width, int height) { 49 void setup_bitmap(SkBitmap* bitmap, int width, int height) {
59 bitmap->allocN32Pixels(width, height); 50 bitmap->allocN32Pixels(width, height);
60 bitmap->eraseColor(SK_ColorTRANSPARENT); 51 bitmap->eraseColor(SK_ColorTRANSPARENT);
61 } 52 }
62 53
63 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, 54 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath,
64 const char *subdirOrNull, const SkString& baseName ) { 55 const char *subdirOrNull, const SkString& baseName ) {
65 SkString partialPath; 56 SkString partialPath;
66 if (subdirOrNull) { 57 if (subdirOrNull) {
67 partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull); 58 partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull);
68 sk_mkdir(partialPath.c_str()); 59 sk_mkdir(partialPath.c_str());
69 } else { 60 } else {
70 partialPath.set(dirPath); 61 partialPath.set(dirPath);
71 } 62 }
72 SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c _str()); 63 SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c _str());
73 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN G_Type, 100)) { 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN G_Type, 100)) {
74 return true; 65 return true;
75 } else { 66 } else {
76 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str());
77 return false; 68 return false;
78 } 69 }
79 } 70 }
80 71
81 } // namespace sk_tools 72 } // namespace sk_tools
OLDNEW
« no previous file with comments | « tools/picture_utils.h ('k') | tools/render_pdfs_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698