Remove picture_utils
More pointless hoop-jumping
Change-Id: I0123e0a1e27140a82ffe08ad88e0d115c060436d
Reviewed-on: https://skia-review.googlesource.com/146449
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index fb64695..fd1e05d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1357,7 +1357,6 @@
"tools/fonts/SkTestTypeface.cpp",
"tools/fonts/SkTestTypeface.h",
"tools/fonts/sk_tool_utils_font.cpp",
- "tools/picture_utils.cpp",
"tools/random_parse_path.cpp",
"tools/sk_tool_utils.cpp",
"tools/timer/Timer.cpp",
@@ -1786,7 +1785,6 @@
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
- "tools/picture_utils.cpp",
]
deps = [
":flags",
@@ -2195,7 +2193,6 @@
"tools/mdbviz/MainWindow.cpp",
"tools/mdbviz/Model.cpp",
"tools/mdbviz/main.cpp",
- "tools/picture_utils.cpp",
# generated files
"$target_gen_dir/mdbviz/MainWindow_moc.cpp",
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 0ee436c..9c50eae 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -43,7 +43,6 @@
#include "Test.h"
#include "Timer.h"
#include "ios_utils.h"
-#include "picture_utils.h"
#include "sk_tool_utils.h"
#include <vector>
diff --git a/public.bzl b/public.bzl
index d926ba0..d9922d6 100644
--- a/public.bzl
+++ b/public.bzl
@@ -483,8 +483,6 @@
"tools/fonts/test_font_index.inc",
"tools/gpu/**/*.cpp",
"tools/gpu/**/*.h",
- "tools/picture_utils.cpp",
- "tools/picture_utils.h",
"tools/random_parse_path.cpp",
"tools/random_parse_path.h",
"tools/sk_pixel_iter.h",
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 299a916..7ad800f 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -24,7 +24,6 @@
#include "SkTHash.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
-#include "picture_utils.h"
#include "SkClipOpPriv.h"
#include <SkLatticeIter.h>
#include <SkShadowFlags.h>
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index 85fbd98..468d85b 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -12,7 +12,6 @@
#include "SkGraphics.h"
#include "SkStream.h"
#include "SkData.h"
-#include "picture_utils.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
deleted file mode 100644
index 9a1eb27..0000000
--- a/tools/picture_utils.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "picture_utils.h"
-#include "SkBitmap.h"
-#include "SkOSFile.h"
-#include "SkOSPath.h"
-#include "SkString.h"
-
-#include "sk_tool_utils.h"
-
-namespace sk_tools {
-
-bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath,
- const char *subdirOrNull, const SkString& baseName) {
- SkString partialPath;
- if (subdirOrNull) {
- partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull);
- sk_mkdir(partialPath.c_str());
- } else {
- partialPath.set(dirPath);
- }
- SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str());
- if (sk_tool_utils::EncodeImageToFile(fullPath.c_str(), bm, SkEncodedImageFormat::kPNG, 100)) {
- return true;
- } else {
- SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str());
- return false;
- }
-}
-
-} // namespace sk_tools
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
deleted file mode 100644
index b990703..0000000
--- a/tools/picture_utils.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef picture_utils_DEFINED
-#define picture_utils_DEFINED
-
-class SkBitmap;
-class SkString;
-
-namespace sk_tools {
- /**
- * Write a bitmap file to disk.
- *
- * @param bm the bitmap to record
- * @param dirPath directory within which to write the image file
- * @param subdirOrNull subdirectory within dirPath, or nullptr to just write into dirPath
- * @param baseName last part of the filename
- *
- * @return true if written out successfully
- */
- bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath,
- const char *subdirOrNull, const SkString& baseName);
-
-} // namespace sk_tools
-
-#endif // picture_utils_DEFINED
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 215f667..70b4457 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -9,7 +9,6 @@
#include "SkPictureRecorder.h"
#include "SkPM4fPriv.h"
-#include "picture_utils.h"
#include "sk_tool_utils.h"
using namespace sk_gpu_test;
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index 8084ca9..aaf54e0 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -34,7 +34,6 @@
#include "SkTaskGroup.h"
#include "flags/SkCommandLineFlags.h"
#include "flags/SkCommonFlagsConfig.h"
-#include "picture_utils.h"
#include "sk_tool_utils.h"
#ifdef SK_XML
@@ -470,12 +469,10 @@
if (!surface->getCanvas()->readPixels(bmp, 0, 0)) {
exitf(ExitErr::kUnavailable, "failed to read canvas pixels for png");
}
- const SkString &dirname = SkOSPath::Dirname(FLAGS_png[0]),
- &basename = SkOSPath::Basename(FLAGS_png[0]);
- if (!mkdir_p(dirname)) {
- exitf(ExitErr::kIO, "failed to create directory \"%s\" for png", dirname.c_str());
+ if (!mkdir_p(SkOSPath::Dirname(FLAGS_png[0]))) {
+ exitf(ExitErr::kIO, "failed to create directory for png \"%s\"", FLAGS_png[0]);
}
- if (!sk_tools::write_bitmap_to_disk(bmp, dirname, nullptr, basename)) {
+ if (!sk_tool_utils::EncodeImageToFile(FLAGS_png[0], bmp, SkEncodedImageFormat::kPNG, 100)) {
exitf(ExitErr::kIO, "failed to save png to \"%s\"", FLAGS_png[0]);
}
}