Chromium Code Reviews| Index: bench/SKDBench.cpp |
| diff --git a/bench/SKDBench.cpp b/bench/SKDBench.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2f6dd0440f1eb13a3bc288c32cafee5bbd108fa0 |
| --- /dev/null |
| +++ b/bench/SKDBench.cpp |
| @@ -0,0 +1,38 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "SKDBench.h" |
| +#include "SkImageDecoder.h" |
| + |
| +/* |
| + * |
| + * This benchmark is designed to test the performance of image decoding. |
| + * It is invoked from the nanobench.cpp file. |
| + * |
| + */ |
| +SKDBench::SKDBench(const char* name, SkString path, SkColorType colorType) |
| + : fPath(path) |
| + , fColorType(colorType) { |
|
scroggo
2015/02/11 19:38:10
I don't think we've made it official, but we've be
msarett
2015/02/11 21:57:00
Done.
|
| + fName.printf("%s_%s_%u", name, path.c_str(), colorType); |
|
scroggo
2015/02/11 19:38:10
We use indents of 4 spaces.
It looks like for dec
msarett
2015/02/11 21:57:00
Done.
|
| +} |
| + |
| +const char* SKDBench::onGetName() { |
| + return fName.c_str(); |
| +} |
| + |
| +bool SKDBench::isSuitableFor(Backend backend) { |
| + return backend == kNonRendering_Backend; |
|
mtklein
2015/02/11 19:15:36
Seems like we might want to say this is suitable f
scroggo
2015/02/11 19:38:10
That's what I did in DM, but I realized that I wan
scroggo
2015/02/11 19:38:10
Constants should go on the left side of == (see ht
msarett
2015/02/11 21:57:00
As discussed, we are not making this edit in order
msarett
2015/02/11 21:57:00
Done.
msarett
2015/02/11 21:57:01
Done.
|
| +} |
| + |
| +void SKDBench::onDraw(const int n, SkCanvas* canvas) { |
| + // Decode each image file n times |
| + for (int i = 0; i < n; i++) { |
| + SkBitmap bitmap; |
| + SkImageDecoder::DecodeFile(fPath.c_str(), &bitmap, fColorType, |
| + SkImageDecoder::kDecodePixels_Mode); |
| + } |
| +} |