aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-28 16:45:07 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-28 16:45:07 +0000
commitccd7afb6fb2df9774e57fb4d7f62f9504cabf03e (patch)
tree54818885b59f98ac958e6c35d67109b098f26a19 /gm
parent7b06ba45b34855a5bb16f9c729813173d7dfe47d (diff)
Reland 'Add path utils, plus a test for it.'
Build SkPathJoin and SkBasename on windows also. Previous CL did not build on Windows because the two functions were accidentally placed inside an ifdef that did not include windows. Move the functions to the top of the file, and add a comment by the endif for clarity. Previously reviewed at https://codereview.chromium.org/15747004/ Review URL: https://codereview.chromium.org/15740024 git-svn-id: http://skia.googlecode.com/svn/trunk@9295 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r--gm/factory.cpp9
-rw-r--r--gm/gm_expectations.cpp11
-rw-r--r--gm/gm_expectations.h10
-rw-r--r--gm/gmmain.cpp2
-rw-r--r--gm/image.cpp3
5 files changed, 8 insertions, 27 deletions
diff --git a/gm/factory.cpp b/gm/factory.cpp
index 4538cda894..a7356a96e3 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -11,6 +11,7 @@
#include "SkData.h"
#include "SkImageDecoder.h"
#include "SkLruImageCache.h"
+#include "SkOSFile.h"
#include "SkStream.h"
namespace skiagm {
@@ -24,13 +25,9 @@ public:
protected:
virtual void onOnceBeforeDraw() SK_OVERRIDE {
- SkString filename(INHERITED::gResourcePath);
- if (!filename.endsWith("/") && !filename.endsWith("\\")) {
- filename.append("/");
- }
-
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
- filename.append("plane.png");
+ SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath.c_str(),
+ "plane.png");
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(filename.c_str()));
if (NULL != stream.get()) {
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp
index 08461bd901..2f921201fa 100644
--- a/gm/gm_expectations.cpp
+++ b/gm/gm_expectations.cpp
@@ -37,15 +37,6 @@ namespace skiagm {
va_end(args);
}
- SkString SkPathJoin(const char *rootPath, const char *relativePath) {
- SkString result(rootPath);
- if (!result.endsWith(SkPATH_SEPARATOR)) {
- result.appendUnichar(SkPATH_SEPARATOR);
- }
- result.append(relativePath);
- return result;
- }
-
Json::Value CreateJsonTree(Json::Value expectedResults,
Json::Value actualResultsFailed,
Json::Value actualResultsFailureIgnored,
@@ -194,7 +185,7 @@ namespace skiagm {
// IndividualImageExpectationsSource class...
Expectations IndividualImageExpectationsSource::get(const char *testName) {
- SkString path = SkPathJoin(fRootDir.c_str(), testName);
+ SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName);
SkBitmap referenceBitmap;
bool decodedReferenceBitmap =
SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h
index 8efb986713..55122d4ab8 100644
--- a/gm/gm_expectations.h
+++ b/gm/gm_expectations.h
@@ -32,16 +32,6 @@ namespace skiagm {
void gm_fprintf(FILE *stream, const char format[], ...);
- /**
- * Assembles rootPath and relativePath into a single path, like this:
- * rootPath/relativePath
- *
- * Uses SkPATH_SEPARATOR, to work on all platforms.
- *
- * TODO(epoger): This should probably move into SkOSFile.h
- */
- SkString SkPathJoin(const char *rootPath, const char *relativePath);
-
Json::Value CreateJsonTree(Json::Value expectedResults,
Json::Value actualResultsFailed,
Json::Value actualResultsFailureIgnored,
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 3481cf8940..3c4f27dafb 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -222,7 +222,7 @@ public:
filename.append(renderModeDescriptor);
filename.appendUnichar('.');
filename.append(suffix);
- return SkPathJoin(path, filename.c_str());
+ return SkOSPath::SkPathJoin(path, filename.c_str());
}
/* since PNG insists on unpremultiplying our alpha, we take no
diff --git a/gm/image.cpp b/gm/image.cpp
index 8578e510ba..71fe0e176f 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -31,6 +31,9 @@ static SkData* fileToData(const char path[]) {
}
static void drawJpeg(SkCanvas* canvas, const SkISize& size) {
+ // TODO: Make this draw a file that is checked in, so it can
+ // be exercised on machines other than mike's. Will require a
+ // rebaseline.
SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg"));
SkImage* image = SkImage::NewEncodedData(data);
if (image) {