aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-09-16 06:24:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 06:24:20 -0700
commitf93d71122e4fcfcdc674a0163455990b13855f2f (patch)
treeb3713fad2da586bf997264247961c1a91453c383 /tools
parentf560ef86813f712eff70feb9b00b70d0fe92c3cd (diff)
SkFontData to use smart pointers.
The SkFontData type is not exposed externally, so any method which uses it can be updated to use smart pointers without affecting external users. Updating this first will make updating the public API much easier. This also updates SkStreamAsset* SkStream::NewFromFile(const char*) to std::unique_ptr<SkStreamAsset> SkStream::MakeFromFile(const char*). It appears that no one outside Skia is currently using SkStream::NewfromFile so this is a good time to update it as well. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339273002 Committed: https://skia.googlesource.com/skia/+/d8c2476a8b1e1e1a1771b17e8dd4db8645914f8c Review-Url: https://codereview.chromium.org/2339273002
Diffstat (limited to 'tools')
-rw-r--r--tools/Resources.cpp5
-rw-r--r--tools/dump_record.cpp4
-rw-r--r--tools/get_images_from_skps.cpp6
-rw-r--r--tools/lua/lua_pictures.cpp4
-rw-r--r--tools/viewer/SKPSlide.cpp4
5 files changed, 11 insertions, 12 deletions
diff --git a/tools/Resources.cpp b/tools/Resources.cpp
index 899f5d2bc4..9c12a67c20 100644
--- a/tools/Resources.cpp
+++ b/tools/Resources.cpp
@@ -41,12 +41,11 @@ sk_sp<SkImage> GetResourceAsImage(const char* resource) {
SkStreamAsset* GetResourceAsStream(const char* resource) {
SkString resourcePath = GetResourcePath(resource);
SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str()));
- if (stream->isValid()) {
- return stream.release();
- } else {
+ if (!stream->isValid()) {
SkDebugf("Resource %s not found.\n", resource);
return nullptr;
}
+ return stream.release();
}
sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource) {
diff --git a/tools/dump_record.cpp b/tools/dump_record.cpp
index 5d54f4d561..03ef93e581 100644
--- a/tools/dump_record.cpp
+++ b/tools/dump_record.cpp
@@ -46,12 +46,12 @@ int tool_main(int argc, char** argv) {
continue;
}
- SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i]));
+ std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(FLAGS_skps[i]);
if (!stream) {
SkDebugf("Could not read %s.\n", FLAGS_skps[i]);
return 1;
}
- sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream));
+ sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream.get()));
if (!src) {
SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]);
return 1;
diff --git a/tools/get_images_from_skps.cpp b/tools/get_images_from_skps.cpp
index 1ec70b3531..e38a245915 100644
--- a/tools/get_images_from_skps.cpp
+++ b/tools/get_images_from_skps.cpp
@@ -128,9 +128,9 @@ int main(int argc, char** argv) {
SkOSFile::Iter iter(inputs, "skp");
for (SkString file; iter.next(&file); ) {
- SkAutoTDelete<SkStream> stream =
- SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str());
- sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream));
+ std::unique_ptr<SkStream> stream =
+ SkStream::MakeFromFile(SkOSPath::Join(inputs, file.c_str()).c_str());
+ sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream.get()));
SkDynamicMemoryWStream scratch;
Sniffer sniff(file.c_str());
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index eee7088f0d..58983f4d58 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -39,8 +39,8 @@ DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
DEFINE_bool2(quiet, q, false, "Silence all non-error related output");
static sk_sp<SkPicture> load_picture(const char path[]) {
- SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
- if (stream.get()) {
+ std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(path);
+ if (stream) {
return SkPicture::MakeFromStream(stream.get());
}
return nullptr;
diff --git a/tools/viewer/SKPSlide.cpp b/tools/viewer/SKPSlide.cpp
index 9419253f0c..e24e1fdb04 100644
--- a/tools/viewer/SKPSlide.cpp
+++ b/tools/viewer/SKPSlide.cpp
@@ -35,8 +35,8 @@ void SKPSlide::draw(SkCanvas* canvas) {
}
static sk_sp<SkPicture> read_picture(const char path[]) {
- SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
- if (stream.get() == nullptr) {
+ std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(path);
+ if (!stream) {
SkDebugf("Could not read %s.\n", path);
return nullptr;
}