private:
SkData *loadPKM() {
- SkString filename = SkOSPath::SkPathJoin(
- INHERITED::GetResourcePath().c_str(), "mandrill_128.pkm");
+ SkString resourcePath = GetResourcePath();
+ SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(),
+ "mandrill_128.pkm");
// Expand the data
SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str()));
template BenchRegistry* BenchRegistry::gHead;
-SkString SkBenchmark::gResourcePath;
+const char* SkBenchmark::gResourcePath;
SkBenchmark::SkBenchmark() {
fForceAlpha = 0xFF;
}
}
+void SkBenchmark::SetResourcePath(const char* resourcePath) {
+ gResourcePath = resourcePath;
+}
+
+SkString SkBenchmark::GetResourcePath() {
+ return SkString(gResourcePath);
+}
///////////////////////////////////////////////////////////////////////////////
fClearMask = clearMask;
}
- static void SetResourcePath(const char* resPath) { gResourcePath.set(resPath); }
-
- static SkString& GetResourcePath() { return gResourcePath; }
+ static void SetResourcePath(const char*);
+ static SkString GetResourcePath();
protected:
virtual void setupPaint(SkPaint* paint);
bool fForceFilter;
SkTriState::State fDither;
uint32_t fOrMask, fClearMask;
- static SkString gResourcePath;
+ static const char* gResourcePath;
typedef SkRefCnt INHERITED;
};
}
virtual void onPreDraw() SK_OVERRIDE {
- const char* resPath = GetResourcePath().c_str();
- if (NULL == resPath) {
+ SkString resourcePath = GetResourcePath();
+ if (resourcePath.isEmpty()) {
fValid = false;
return;
}
- SkString fullPath = SkOSPath::SkPathJoin(resPath, fFilename.c_str());
+ SkString fullPath = SkOSPath::SkPathJoin(resourcePath.c_str(),
+ fFilename.c_str());
SkFILEStream fileStream(fullPath.c_str());
fValid = fileStream.isValid() && fileStream.getLength() > 0;
if (fValid) {
virtual void onDraw(SkCanvas* canvas) {
SkBitmap bm, bm4444;
- SkString filename = SkOSPath::SkPathJoin(
- INHERITED::gResourcePath.c_str(), "mandrill_512.png");
+ SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_512.png");
if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm,
SkBitmap::kARGB_8888_Config,
SkImageDecoder::kDecodePixels_Mode)) {
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkBitmap bm;
- SkString filename = SkOSPath::SkPathJoin(
- INHERITED::gResourcePath.c_str(), "mandrill_128.");
+ SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_128.");
filename.append(this->fileExtension());
SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkBitmap bm;
- SkString filename = SkOSPath::SkPathJoin(
- INHERITED::gResourcePath.c_str(), "mandrill_128.pkm");
+ SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_128.pkm");
SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str()));
if (NULL == fileData) {
protected:
virtual void onOnceBeforeDraw() SK_OVERRIDE {
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
- SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath.c_str(),
- "plane.png");
+ SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "plane.png");
SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str()));
if (NULL != data.get()) {
// Create a cache which will boot the pixels out anytime the
*/
#include "gm.h"
+
using namespace skiagm;
-SkString GM::gResourcePath;
+const char* GM::gResourcePath;
GM::GM() {
fMode = kGM_Mode;
fHaveCalledOnceBeforeDraw = false;
fStarterMatrix.reset();
}
+
GM::~GM() {}
void GM::draw(SkCanvas* canvas) {
canvas->drawRect(r, paint);
}
+void GM::SetResourcePath(const char* resourcePath) {
+ gResourcePath = resourcePath;
+}
+
+SkString GM::GetResourcePath() {
+ return SkString(gResourcePath);
+}
+
// need to explicitly declare this, or we get some weird infinite loop llist
template GMRegistry* SkTRegistry<GM*(*)(void*)>::gHead;
// GM's getISize bounds.
void drawSizeBounds(SkCanvas*, SkColor);
- static void SetResourcePath(const char* resourcePath) {
- gResourcePath = resourcePath;
- }
-
- static SkString& GetResourcePath() {
- return gResourcePath;
- }
+ static void SetResourcePath(const char*);
+ static SkString GetResourcePath();
bool isCanvasDeferred() const { return fCanvasIsDeferred; }
void setCanvasIsDeferred(bool isDeferred) {
}
protected:
- static SkString gResourcePath;
+ static const char* gResourcePath;
virtual void onOnceBeforeDraw() {}
virtual void onDraw(SkCanvas*) = 0;
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "Test.h"
#include "SkCommandLineFlags.h"
///////////////////////////////////////////////////////////////////////////////
+const char* Test::gResourcePath;
+
Test::Test() : fReporter(NULL), fPassed(true) {}
Test::~Test() {
return SkString(tmpDir);
}
-static const char* gResourcePath = NULL;
-void Test::SetResourcePath(const char* resourcePath) { gResourcePath = resourcePath; }
+void Test::SetResourcePath(const char* resourcePath) {
+ gResourcePath = resourcePath;
+}
SkString Test::GetResourcePath() {
return SkString(gResourcePath);
virtual void onRun(Reporter*) = 0;
private:
+ static const char* gResourcePath;
+
Reporter* fReporter;
SkString fName;
bool fPassed;