DM: paths as implict strings too.

BUG=skia:

Review URL: https://codereview.chromium.org/891823002
This commit is contained in:
mtklein 2015-01-30 11:42:31 -08:00 committed by Commit bot
parent b932999142
commit 8d17a13a71
3 changed files with 11 additions and 10 deletions

View File

@ -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.
}
}
}

View File

@ -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<SkData> 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<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));

View File

@ -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;
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;
};
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/