Index: bench/DecodeBench.cpp |
diff --git a/bench/DecodeBench.cpp b/bench/DecodeBench.cpp |
index c87e6f6484fb467a2352bd72736e8b7322e548a0..c45654cccb72f3619edb833e8b0a5c9f5ac15322 100644 |
--- a/bench/DecodeBench.cpp |
+++ b/bench/DecodeBench.cpp |
@@ -7,29 +7,26 @@ |
*/ |
#include "SkBenchmark.h" |
#include "SkBitmap.h" |
+#include "SkCommandLineFlags.h" |
#include "SkImageDecoder.h" |
#include "SkString.h" |
+DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for DecodeBench."); |
+ |
static const char* gConfigName[] = { |
"ERROR", "a1", "a8", "index8", "565", "4444", "8888" |
}; |
class DecodeBench : public SkBenchmark { |
- const char* fFilename; |
SkBitmap::Config fPrefConfig; |
SkString fName; |
- enum { N = SkBENCHLOOP(10) }; |
public: |
DecodeBench(void* param, SkBitmap::Config c) : SkBenchmark(param) { |
- fFilename = this->findDefine("decode-filename"); |
fPrefConfig = c; |
- const char* fname = NULL; |
- if (fFilename) { |
- fname = strrchr(fFilename, '/'); |
- if (fname) { |
- fname += 1; // skip the slash |
- } |
+ const char* fname = strrchr(FLAGS_decodeBenchFilename[0], '/'); |
+ if (fname) { |
+ fname++; // skip the slash |
} |
fName.printf("decode_%s_%s", gConfigName[c], fname); |
fIsRendering = false; |
@@ -41,12 +38,12 @@ protected: |
} |
virtual void onDraw(SkCanvas*) { |
- if (fFilename) { |
- for (int i = 0; i < N; i++) { |
- SkBitmap bm; |
- SkImageDecoder::DecodeFile(fFilename, &bm, fPrefConfig, |
- SkImageDecoder::kDecodePixels_Mode); |
- } |
+ for (int i = 0; i < this->getLoops(); i++) { |
+ SkBitmap bm; |
+ SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0], |
+ &bm, |
+ fPrefConfig, |
+ SkImageDecoder::kDecodePixels_Mode); |
} |
} |