aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar tfarina <tfarina@chromium.org>2014-07-01 12:35:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-01 12:35:49 -0700
commitc846f4a96bcde1ffeaf17afc1469db6f2cbd1ad3 (patch)
tree0fcf98e7bc8c1ed90a9d9a61b685d998d362768b /gm
parent696d3611760b0465caaebf6243824960034c3592 (diff)
Cleanup usage of GetResourcePath() after commit bcbc1788b478b1e54079318ad073e8490aa66fae.
There was a clean up opportunity left over after https://skia.googlesource.com/skia/+/bcbc1788b478b1e54079318ad073e8490aa66fae, that could make use of the default parameter of GetResourcePath() function to make some call sites cleaner. We decided to make it in a separate CL to make reviewer's and author's life easier, so we could catch errors and/or mistakes easily. BUG=None TEST=make all && out/Debug/dm && out/Debug/SampleApp R=mtklein@google.com Author: tfarina@chromium.org Review URL: https://codereview.chromium.org/351133003
Diffstat (limited to 'gm')
-rw-r--r--gm/cmykjpeg.cpp10
-rw-r--r--gm/coloremoji.cpp4
-rw-r--r--gm/copyTo4444.cpp5
-rw-r--r--gm/downsamplebitmap.cpp5
-rw-r--r--gm/etc1bitmap.cpp10
-rw-r--r--gm/factory.cpp5
-rw-r--r--gm/filterbitmap.cpp5
-rw-r--r--gm/filterindiabox.cpp5
8 files changed, 13 insertions, 36 deletions
diff --git a/gm/cmykjpeg.cpp b/gm/cmykjpeg.cpp
index a1a12dc388..5371fe2133 100644
--- a/gm/cmykjpeg.cpp
+++ b/gm/cmykjpeg.cpp
@@ -26,14 +26,8 @@ protected:
// parameters to the "decode" call
bool dither = false;
- SkString resourcePath = GetResourcePath();
- if (!resourcePath.endsWith("/") && !resourcePath.endsWith("\\")) {
- resourcePath.append("/");
- }
-
- resourcePath.append("CMYK.jpg");
-
- SkFILEStream stream(resourcePath.c_str());
+ SkString jpgFilename = GetResourcePath("CMYK.jpg");
+ SkFILEStream stream(jpgFilename.c_str());
if (!stream.isValid()) {
SkDebugf("Could not find CMYK.jpg, please set --resourcePath correctly.\n");
return;
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp
index cf4500819a..7fe54f515f 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -29,9 +29,7 @@ protected:
}
virtual void onOnceBeforeDraw() SK_OVERRIDE {
- SkString filename = GetResourcePath();
- filename.append("/Funkster.ttf");
-
+ SkString filename = GetResourcePath("/Funkster.ttf");
SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str()));
if (!stream->isValid()) {
SkDebugf("Could not find Funkster.ttf, please set --resourcePath correctly.\n");
diff --git a/gm/copyTo4444.cpp b/gm/copyTo4444.cpp
index 6465d00212..635cc7b834 100644
--- a/gm/copyTo4444.cpp
+++ b/gm/copyTo4444.cpp
@@ -32,9 +32,8 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkBitmap bm, bm4444;
- SkString resourcePath = GetResourcePath();
- SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_512.png");
- if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, kN32_SkColorType,
+ SkString pngFilename = GetResourcePath("mandrill_512.png");
+ if (!SkImageDecoder::DecodeFile(pngFilename.c_str(), &bm, kN32_SkColorType,
SkImageDecoder::kDecodePixels_Mode)) {
SkDebugf("Could not decode the file. Did you forget to set the "
"resourcePath?\n");
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index a911b83b9f..f24c92b6e5 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -172,11 +172,8 @@ class DownsampleBitmapImageGM: public DownsampleBitmapGM {
int fSize;
virtual void make_bitmap() SK_OVERRIDE {
- SkString resourcePath = GetResourcePath();
- resourcePath.append("/");
- resourcePath.append(fFilename);
-
SkImageDecoder* codec = NULL;
+ SkString resourcePath = GetResourcePath(fFilename.c_str());
SkFILEStream stream(resourcePath.c_str());
if (stream.isValid()) {
codec = SkImageDecoder::Factory(&stream);
diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp
index e0a59b0c4f..2241c848c3 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -95,10 +95,8 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkBitmap bm;
- SkString resourcePath = GetResourcePath();
- SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128.");
+ SkString filename = GetResourcePath("mandrill_128.");
filename.append(this->fileExtension());
-
SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
if (NULL == fileData) {
SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n");
@@ -170,10 +168,8 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkBitmap bm;
- SkString resourcePath = GetResourcePath();
- SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128.pkm");
-
- SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str()));
+ SkString pkmFilename = GetResourcePath("mandrill_128.pkm");
+ SkAutoDataUnref fileData(SkData::NewFromFileName(pkmFilename.c_str()));
if (NULL == fileData) {
SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n");
return;
diff --git a/gm/factory.cpp b/gm/factory.cpp
index 641133c440..608c049dc3 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -29,10 +29,9 @@ public:
protected:
virtual void onOnceBeforeDraw() SK_OVERRIDE {
- SkString resourcePath = GetResourcePath();
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
- SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "plane.png");
- SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str()));
+ SkString pngFilename = GetResourcePath("plane.png");
+ SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str()));
if (NULL != data.get()) {
// Create a cache which will boot the pixels out anytime the
// bitmap is unlocked.
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index d73318d31c..0d4b4b4a4b 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -194,11 +194,8 @@ class FilterBitmapImageGM: public FilterBitmapGM {
}
void makeBitmap() SK_OVERRIDE {
- SkString resourcePath = GetResourcePath();
- resourcePath.append("/");
- resourcePath.append(fFilename);
-
SkImageDecoder* codec = NULL;
+ SkString resourcePath = GetResourcePath(fFilename.c_str());
SkFILEStream stream(resourcePath.c_str());
if (stream.isValid()) {
codec = SkImageDecoder::Factory(&stream);
diff --git a/gm/filterindiabox.cpp b/gm/filterindiabox.cpp
index 1987c95bf7..c3316b4ea2 100644
--- a/gm/filterindiabox.cpp
+++ b/gm/filterindiabox.cpp
@@ -104,11 +104,8 @@ protected:
}
void makeBitmap() {
- SkString resourcePath = GetResourcePath();
- resourcePath.append("/");
- resourcePath.append(fFilename);
-
SkImageDecoder* codec = NULL;
+ SkString resourcePath = GetResourcePath(fFilename.c_str());
SkFILEStream stream(resourcePath.c_str());
if (stream.isValid()) {
codec = SkImageDecoder::Factory(&stream);