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
diff --git a/bench/ETCBitmapBench.cpp b/bench/ETCBitmapBench.cpp
index e5ec44f..529f5f6 100644
--- a/bench/ETCBitmapBench.cpp
+++ b/bench/ETCBitmapBench.cpp
@@ -89,13 +89,10 @@
     SkAutoDataUnref fPKMData;
 
 private:
-    SkData *loadPKM() {
-        SkString resourcePath = GetResourcePath();
-        SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(),
-                                                 "mandrill_128.pkm");
-
+    SkData* loadPKM() {
+        SkString pkmFilename = GetResourcePath("mandrill_128.pkm");
         // Expand the data
-        SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str()));
+        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 NULL;
diff --git a/gm/cmykjpeg.cpp b/gm/cmykjpeg.cpp
index a1a12dc..5371fe2 100644
--- a/gm/cmykjpeg.cpp
+++ b/gm/cmykjpeg.cpp
@@ -26,14 +26,8 @@
         // 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 cf45008..7fe54f5 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -29,9 +29,7 @@
     }
 
     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 6465d00..635cc7b 100644
--- a/gm/copyTo4444.cpp
+++ b/gm/copyTo4444.cpp
@@ -32,9 +32,8 @@
 
     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 a911b83..f24c92b 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -172,11 +172,8 @@
       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 e0a59b0..2241c84 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -95,10 +95,8 @@
 
     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 @@
 
     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 641133c..608c049 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -29,10 +29,9 @@
 
 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 d73318d..0d4b4b4 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -194,11 +194,8 @@
       }
 
       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 1987c95..c3316b4 100644
--- a/gm/filterindiabox.cpp
+++ b/gm/filterindiabox.cpp
@@ -104,11 +104,8 @@
       }
 
       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);
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index ecc5941..28256e5 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -37,9 +37,8 @@
 
 static SkBitmap load_bitmap() {
     SkBitmap bm;
-    SkString resourcePath = GetResourcePath();
-    SkString path = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_512.png");
-    SkAutoDataUnref data(SkData::NewFromFileName(path.c_str()));
+    SkString pngFilename = GetResourcePath("mandrill_512.png");
+    SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str()));
     if (data.get() != NULL) {
         SkInstallDiscardablePixelRef(SkDecodingImageGenerator::Create(
             data, SkDecodingImageGenerator::Options()), &bm);
diff --git a/samplecode/SampleSubpixelTranslate.cpp b/samplecode/SampleSubpixelTranslate.cpp
index 41a0f15..4652bc3 100644
--- a/samplecode/SampleSubpixelTranslate.cpp
+++ b/samplecode/SampleSubpixelTranslate.cpp
@@ -24,13 +24,9 @@
     SubpixelTranslateView(const char imageFilename[],
                           float horizontalVelocity,
                           float verticalVelocity)
-      : fFilename(imageFilename),
-        fHorizontalVelocity(horizontalVelocity),
+      : fHorizontalVelocity(horizontalVelocity),
         fVerticalVelocity(verticalVelocity) {
-      SkString resourcePath = GetResourcePath();
-      resourcePath.append("/");
-      resourcePath.append(fFilename);
-
+      SkString resourcePath = GetResourcePath(imageFilename);
       SkImageDecoder* codec = NULL;
       SkFILEStream stream(resourcePath.c_str());
       if (stream.isValid()) {
@@ -50,7 +46,6 @@
 
 protected:
     SkBitmap fBM;
-    SkString fFilename;
     SkScalar fSize;
     float fHorizontalVelocity, fVerticalVelocity;
 
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 89db399..d070f61 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -503,12 +503,9 @@
  *  SkInstallDiscardablePixelRef functions.
  */
 DEF_TEST(ImprovedBitmapFactory, reporter) {
-    SkString resourcePath = GetResourcePath();
-    SkString path = SkOSPath::SkPathJoin(
-            resourcePath.c_str(), "randPixels.png");
-    SkAutoTUnref<SkStreamRewindable> stream(
-        SkStream::NewFromFile(path.c_str()));
-    if (sk_exists(path.c_str())) {
+    SkString pngFilename = GetResourcePath("randPixels.png");
+    SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c_str()));
+    if (sk_exists(pngFilename.c_str())) {
         SkBitmap bm;
         SkAssertResult(bm.setInfo(SkImageInfo::MakeN32Premul(1, 1)));
         REPORTER_ASSERT(reporter,
diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp
index e9c4217..83a3546 100644
--- a/tests/KtxTest.cpp
+++ b/tests/KtxTest.cpp
@@ -141,12 +141,11 @@
  * the PKM to the KTX should produce an identical KTX to the one we have on file)
  */
 DEF_TEST(KtxReexportPKM, reporter) {
-    SkString resourcePath = GetResourcePath();
-    SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128.pkm");
+    SkString pkmFilename = GetResourcePath("mandrill_128.pkm");
 
     // Load PKM file into a bitmap
     SkBitmap etcBitmap;
-    SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
+    SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(pkmFilename.c_str()));
     REPORTER_ASSERT(reporter, NULL != fileData);
 
     bool installDiscardablePixelRefSuccess =
@@ -161,7 +160,7 @@
     REPORTER_ASSERT(reporter, NULL != ktxDataPtr);
 
     // See is this data is identical to data in existing ktx file.
-    SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128.ktx");
+    SkString ktxFilename = GetResourcePath("mandrill_128.ktx");
     SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str()));
     REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData));
 }