Index: bench/CodecSubsetBench.h |
diff --git a/bench/CodecSubsetBench.h b/bench/CodecSubsetBench.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2d49a4ee4c36c0b80c48bcd4a353987978c760ac |
--- /dev/null |
+++ b/bench/CodecSubsetBench.h |
@@ -0,0 +1,69 @@ |
+/* |
+ * 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 "Benchmark.h" |
+#include "SkImageDecoder.h" |
+#include "SkImageInfo.h" |
+#include "SkStream.h" |
+#include "SkString.h" |
+ |
+/* |
+ * |
+ * This benchmark is designed to test the performance of subset decoding. |
+ * |
+ */ |
+class CodecSubsetBench : public Benchmark { |
+public: |
+ |
+ // Defines the style of the subset decoding benchmark. |
+ enum SubsetMode { |
+ // Use an input width, height, left, and top to decode a single subset. |
+ // Must specify: subsetWidth, subsetHeight, offsetLeft, offsetTop |
scroggo
2015/05/29 15:36:03
It might be clearer to have different constructors
msarett
2015/06/01 14:03:25
I am splitting the benchmark into separate subclas
|
+ kSingle_SubsetMode, |
+ |
+ // Use a divisor to decode the entire image in a grid of divisor x divisor blocks. |
+ // Must specify: divisor |
+ kDivisor_SubsetMode, |
+ |
+ // Use input dimensions to decode the entire image where each block is susbetW x subsetH. |
+ // Must specify: subsetWidth, subsetHeight |
+ kTranslate_SubsetMode, |
+ |
+ // Choose subsets to mimic a user zooming out on a photo |
scroggo
2015/05/29 15:36:03
nit: zooming in* ?
msarett
2015/06/01 14:03:25
It mimics zooming out. The subsets get bigger eac
|
+ // Must specify: subsetWidth, subsetHeight |
+ kScale_SubsetMode |
+ }; |
+ |
+ CodecSubsetBench(SkString* path, |
+ SubsetMode subsetMode, |
+ SkColorType colorType, |
+ uint32_t subsetWidth, |
+ uint32_t subsetHeight, |
+ uint32_t offsetLeft, |
+ uint32_t offsetTop, |
+ uint32_t divisor, |
+ bool useCodec); |
+ |
+protected: |
+ const char* onGetName() override; |
+ bool isSuitableFor(Backend backend) override; |
+ void onDraw(const int n, SkCanvas* canvas) override; |
+ |
+private: |
+ |
+ SkString fName; |
+ SubsetMode fSubsetMode; |
+ SkColorType fColorType; |
+ const uint32_t fSubsetWidth; |
+ const uint32_t fSubsetHeight; |
+ const uint32_t fOffsetLeft; |
+ const uint32_t fOffsetTop; |
+ const uint32_t fDivisor; |
+ const bool fUseCodec; |
+ SkAutoTDelete<SkMemoryStream> fStream; |
+ typedef Benchmark INHERITED; |
+}; |