diff options
author | mtklein <mtklein@google.com> | 2014-06-08 07:02:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-08 07:02:47 -0700 |
commit | 91359bed48bc006a4319da86eb26db3b2e6d4afb (patch) | |
tree | 923d1ac57009191855db0b4a49b487d9bf39a283 /gm | |
parent | 643b8bd6617e333f7a970a57ad9166f3d6675d1a (diff) |
Revert of Clean up Test's resourcePath code. (https://codereview.chromium.org/319473003/)
Reason for revert:
Some benchmarks are written in a way that makes this change unsafe (e.g. const char* resPath = GetResourcePath().c_str(); in SkipZeroesBench) and Valgrind and ASAN caught that. We can try again after a more careful cleanup of GetResourcePath().
Original issue's description:
> Clean up resourcePath code.
>
> 1) Make the implementation of SetResourcePath/GetResourcePath of GM and SkBenchmark match with the one in Test.
> 2) Make gResourcePath a static pointer to const char and move it inside the classes.
>
> BUG=None
> TEST=make tests && out/Debug/tests
> make gm && out/Debug/gm
> make bench && out/Debug/bench
> R=mtklein@google.com
>
> Committed: https://skia.googlesource.com/skia/+/52e4f413ffe2d281f9e90ff2147db08083ffcba7
R=tfarina@chromium.org
TBR=tfarina@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=None
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/320733002
Diffstat (limited to 'gm')
-rw-r--r-- | gm/copyTo4444.cpp | 3 | ||||
-rw-r--r-- | gm/etc1bitmap.cpp | 6 | ||||
-rw-r--r-- | gm/factory.cpp | 3 | ||||
-rw-r--r-- | gm/gm.cpp | 12 | ||||
-rw-r--r-- | gm/gm.h | 11 |
5 files changed, 17 insertions, 18 deletions
diff --git a/gm/copyTo4444.cpp b/gm/copyTo4444.cpp index 6233301fed..7e2c2798e4 100644 --- a/gm/copyTo4444.cpp +++ b/gm/copyTo4444.cpp @@ -30,7 +30,8 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkBitmap bm, bm4444; - SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_512.png"); + SkString filename = SkOSPath::SkPathJoin( + INHERITED::gResourcePath.c_str(), "mandrill_512.png"); if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, SkBitmap::kARGB_8888_Config, SkImageDecoder::kDecodePixels_Mode)) { diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp index ce0aa7dbad..cdf8617a35 100644 --- a/gm/etc1bitmap.cpp +++ b/gm/etc1bitmap.cpp @@ -93,7 +93,8 @@ protected: virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { SkBitmap bm; - SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_128."); + SkString filename = SkOSPath::SkPathJoin( + INHERITED::gResourcePath.c_str(), "mandrill_128."); filename.append(this->fileExtension()); SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())); @@ -168,7 +169,8 @@ protected: virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { SkBitmap bm; - SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mandrill_128.pkm"); + SkString filename = SkOSPath::SkPathJoin( + INHERITED::gResourcePath.c_str(), "mandrill_128.pkm"); SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str())); if (NULL == fileData) { diff --git a/gm/factory.cpp b/gm/factory.cpp index aa643a2c5b..bd79c9d81e 100644 --- a/gm/factory.cpp +++ b/gm/factory.cpp @@ -28,7 +28,8 @@ public: 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, "plane.png"); + SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath.c_str(), + "plane.png"); SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str())); if (NULL != data.get()) { // Create a cache which will boot the pixels out anytime the @@ -6,10 +6,9 @@ */ #include "gm.h" - using namespace skiagm; -const char* GM::gResourcePath; +SkString GM::gResourcePath; GM::GM() { fMode = kGM_Mode; @@ -18,7 +17,6 @@ GM::GM() { fHaveCalledOnceBeforeDraw = false; fStarterMatrix.reset(); } - GM::~GM() {} void GM::draw(SkCanvas* canvas) { @@ -66,13 +64,5 @@ void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) { 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; @@ -96,8 +96,13 @@ namespace skiagm { // GM's getISize bounds. void drawSizeBounds(SkCanvas*, SkColor); - static void SetResourcePath(const char*); - static SkString GetResourcePath(); + static void SetResourcePath(const char* resourcePath) { + gResourcePath = resourcePath; + } + + static SkString& GetResourcePath() { + return gResourcePath; + } bool isCanvasDeferred() const { return fCanvasIsDeferred; } void setCanvasIsDeferred(bool isDeferred) { @@ -110,7 +115,7 @@ namespace skiagm { } protected: - static const char* gResourcePath; + static SkString gResourcePath; virtual void onOnceBeforeDraw() {} virtual void onDraw(SkCanvas*) = 0; |