2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2009-09-02 21:12:42 +00:00
|
|
|
#include "SkBenchmark.h"
|
|
|
|
#include "SkBitmap.h"
|
2013-09-10 19:23:38 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2009-09-02 21:12:42 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2014-02-20 15:41:17 +00:00
|
|
|
#include "SkOSFile.h"
|
2009-09-02 21:12:42 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for DecodeBench.");
|
|
|
|
|
2009-09-02 21:12:42 +00:00
|
|
|
static const char* gConfigName[] = {
|
|
|
|
"ERROR", "a1", "a8", "index8", "565", "4444", "8888"
|
|
|
|
};
|
|
|
|
|
|
|
|
class DecodeBench : public SkBenchmark {
|
|
|
|
SkBitmap::Config fPrefConfig;
|
|
|
|
SkString fName;
|
|
|
|
public:
|
2013-09-13 19:52:27 +00:00
|
|
|
DecodeBench(SkBitmap::Config c) {
|
2009-09-02 21:12:42 +00:00
|
|
|
fPrefConfig = c;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2014-02-20 15:41:17 +00:00
|
|
|
SkString fname = SkOSPath::SkBasename(FLAGS_decodeBenchFilename[0]);
|
|
|
|
fName.printf("decode_%s_%s", gConfigName[c], fname.c_str());
|
2013-11-21 06:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
|
|
|
|
return backend == kNonRendering_Backend;
|
2009-09-02 21:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual const char* onGetName() {
|
|
|
|
return fName.c_str();
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:17:16 +00:00
|
|
|
virtual void onDraw(const int loops, SkCanvas*) {
|
|
|
|
for (int i = 0; i < loops; i++) {
|
2013-09-10 19:23:38 +00:00
|
|
|
SkBitmap bm;
|
|
|
|
SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0],
|
|
|
|
&bm,
|
|
|
|
fPrefConfig,
|
|
|
|
SkImageDecoder::kDecodePixels_Mode);
|
2009-09-02 21:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkBenchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_8888_Config); )
|
|
|
|
DEF_BENCH( return new DecodeBench(SkBitmap::kRGB_565_Config); )
|
|
|
|
DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_4444_Config); )
|