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

Unified Diff: tools/skimage_main.cpp

Issue 646213002: Eliminate one copy of replace_char() function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« tools/picture_utils.h ('K') | « tools/picture_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skimage_main.cpp
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index a2d353c25de695fa5d63f96c657688227f836f44..3ed0d8de961b3db796f1d269970505ffc3dba932 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -6,6 +6,7 @@
*/
#include "gm_expectations.h"
+#include "picture_utils.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
#include "SkCommandLineFlags.h"
@@ -463,24 +464,6 @@ static void test_stream_without_length(const char srcPath[], SkImageDecoder* cod
}
#endif // defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
-/**
- * Replaces all instances of oldChar with newChar in str.
- *
- * TODO: This function appears here and in picture_utils.[cpp|h] ;
- * we should add the implementation to src/core/SkString.cpp, write tests for it,
- * and remove it from elsewhere.
- */
-static void replace_char(SkString* str, const char oldChar, const char newChar) {
- if (NULL == str) {
- return;
- }
- for (size_t i = 0; i < str->size(); ++i) {
- if (oldChar == str->operator[](i)) {
- str->operator[](i) = newChar;
- }
- }
-}
-
static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) {
SkBitmap bitmap;
SkFILEStream stream(srcPath);
@@ -504,10 +487,10 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
// Create a string representing just the filename itself, for use in json expectations.
SkString basename = SkOSPath::Basename(srcPath);
// Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENAME_PATTERN
- replace_char(&basename, '_', '-');
+ sk_tools::replace_char(&basename, '_', '-');
// Replace '.' with '-', so the output filename can still retain the original file extension,
// but still end up with only one '.', which denotes the actual extension of the final file.
- replace_char(&basename, '.', '-');
+ sk_tools::replace_char(&basename, '.', '-');
const char* filename = basename.c_str();
if (!codec->decode(&stream, &bitmap, gPrefColorType, SkImageDecoder::kDecodePixels_Mode)) {
« tools/picture_utils.h ('K') | « tools/picture_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698