From 8d17a13a71edb0d8412e4354c428582b74587b79 Mon Sep 17 00:00:00 2001 From: mtklein Date: Fri, 30 Jan 2015 11:42:31 -0800 Subject: DM: paths as implict strings too. BUG=skia: Review URL: https://codereview.chromium.org/891823002 --- dm/DM.cpp | 6 +++--- dm/DMSrcSink.cpp | 4 ++-- dm/DMSrcSink.h | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dm/DM.cpp b/dm/DM.cpp index e162e7762c..6dc7e668e2 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -130,7 +130,7 @@ static void gather_srcs() { push_src("skp", new SKPSrc(SkOSPath::Join(path, file.c_str()))); } } else { - push_src("skp", new SKPSrc(SkString(path))); + push_src("skp", new SKPSrc(path)); } } static const char* const exts[] = { @@ -150,8 +150,8 @@ static void gather_srcs() { } } else if (sk_exists(flag)) { // assume that FLAGS_images[i] is a valid image if it is a file. - push_src("image", new ImageSrc(SkString(flag))); // Decode entire image. - push_src("image", new ImageSrc(SkString(flag), 5)); // Decode 5 random subsets. + push_src("image", new ImageSrc(flag)); // Decode entire image. + push_src("image", new ImageSrc(flag, 5)); // Decode 5 random subsets. } } } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index a57192e881..39b92cd800 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -31,7 +31,7 @@ Name GMSrc::name() const { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -ImageSrc::ImageSrc(SkString path, int subsets) : fPath(path), fSubsets(subsets) {} +ImageSrc::ImageSrc(Path path, int subsets) : fPath(path), fSubsets(subsets) {} Error ImageSrc::draw(SkCanvas* canvas) const { SkAutoTUnref encoded(SkData::NewFromFileName(fPath.c_str())); @@ -103,7 +103,7 @@ Name ImageSrc::name() const { static const SkRect kSKPViewport = {0,0, 1000,1000}; -SKPSrc::SKPSrc(SkString path) : fPath(path) {} +SKPSrc::SKPSrc(Path path) : fPath(path) {} Error SKPSrc::draw(SkCanvas* canvas) const { SkAutoTDelete stream(SkStream::NewFromFile(fPath.c_str())); diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index 67c8e5cf4f..16f7c144eb 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -21,6 +21,7 @@ struct ImplicitString : public SkString { }; typedef ImplicitString Error; typedef ImplicitString Name; +typedef ImplicitString Path; struct Src { // All Srcs must be thread safe. @@ -60,25 +61,25 @@ private: class ImageSrc : public Src { public: - explicit ImageSrc(SkString path, int subsets = 0); + explicit ImageSrc(Path path, int subsets = 0); Error draw(SkCanvas*) const SK_OVERRIDE; SkISize size() const SK_OVERRIDE; Name name() const SK_OVERRIDE; private: - SkString fPath; - int fSubsets; + Path fPath; + int fSubsets; }; class SKPSrc : public Src { public: - explicit SKPSrc(SkString path); + explicit SKPSrc(Path path); Error draw(SkCanvas*) const SK_OVERRIDE; SkISize size() const SK_OVERRIDE; Name name() const SK_OVERRIDE; private: - SkString fPath; + Path fPath; }; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -- cgit v1.2.3