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.
|
|
|
|
*/
|
2014-06-19 19:32:29 +00:00
|
|
|
#include "Benchmark.h"
|
2009-09-02 21:12:42 +00:00
|
|
|
#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"
|
2014-06-13 00:40:00 +00:00
|
|
|
#include "sk_tool_utils.h"
|
2009-09-02 21:12:42 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for DecodeBench.");
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
class DecodeBench : public Benchmark {
|
2014-06-13 00:40:00 +00:00
|
|
|
const SkColorType fPrefColorType;
|
|
|
|
SkString fName;
|
2009-09-02 21:12:42 +00:00
|
|
|
public:
|
2014-06-13 00:40:00 +00:00
|
|
|
DecodeBench(SkColorType ct) : fPrefColorType(ct) {
|
2014-07-29 02:26:58 +00:00
|
|
|
SkString fname = SkOSPath::Basename(FLAGS_decodeBenchFilename[0]);
|
2014-06-13 00:40:00 +00:00
|
|
|
fName.printf("decode_%s_%s", sk_tool_utils::colortype_name(ct), fname.c_str());
|
2013-11-21 06:21:58 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 18:06:39 +00:00
|
|
|
bool isSuitableFor(Backend backend) SK_OVERRIDE {
|
2013-11-21 06:21:58 +00:00
|
|
|
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;
|
2014-06-13 00:40:00 +00:00
|
|
|
SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0], &bm, fPrefColorType,
|
2013-09-10 19:23:38 +00:00
|
|
|
SkImageDecoder::kDecodePixels_Mode);
|
2009-09-02 21:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-06-19 19:32:29 +00:00
|
|
|
typedef Benchmark INHERITED;
|
2009-09-02 21:12:42 +00:00
|
|
|
};
|
|
|
|
|
2014-06-13 00:40:00 +00:00
|
|
|
DEF_BENCH( return new DecodeBench(kN32_SkColorType); )
|
|
|
|
DEF_BENCH( return new DecodeBench(kRGB_565_SkColorType); )
|
|
|
|
DEF_BENCH( return new DecodeBench(kARGB_4444_SkColorType); )
|