Cleanup usage of GetResourcePath() after commit bcbc1788b4
.
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
This commit is contained in:
parent
696d361176
commit
c846f4a96b
@ -89,13 +89,10 @@ protected:
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -24,13 +24,9 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
protected:
|
||||
SkBitmap fBM;
|
||||
SkString fFilename;
|
||||
SkScalar fSize;
|
||||
float fHorizontalVelocity, fVerticalVelocity;
|
||||
|
||||
|
@ -503,12 +503,9 @@ static SkPixelRef* install_pixel_ref(SkBitmap* bitmap,
|
||||
* 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,
|
||||
|
@ -141,12 +141,11 @@ DEF_TEST(KtxReadUnpremul, reporter) {
|
||||
* 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 @@ DEF_TEST(KtxReexportPKM, reporter) {
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user