aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-01-08 14:20:36 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-08 14:20:36 -0800
commitc146aa6fd45dffe29b4f565aafd4ec3a16d9f73b (patch)
tree0c7bd9303f6a21eeff457c2302166ed4030deb87
parent1bcbc8f8c0747691496d779055675bc47ca65c86 (diff)
Add --zero_init to simulate zero-initialized memory in CodecBench
-rw-r--r--bench/CodecBench.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/bench/CodecBench.cpp b/bench/CodecBench.cpp
index 66831fb24c..fc52edfb07 100644
--- a/bench/CodecBench.cpp
+++ b/bench/CodecBench.cpp
@@ -9,8 +9,12 @@
#include "CodecBenchPriv.h"
#include "SkBitmap.h"
#include "SkCodec.h"
+#include "SkCommandLineFlags.h"
#include "SkOSFile.h"
+// Actually zeroing the memory would throw off timing, so we just lie.
+DEFINE_bool(zero_init, false, "Pretend our destination is zero-intialized, simulating Android?");
+
CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType,
SkAlphaType alphaType)
: fColorType(colorType)
@@ -47,6 +51,10 @@ void CodecBench::onDraw(int n, SkCanvas* canvas) {
SkAutoTDelete<SkCodec> codec;
SkPMColor colorTable[256];
int colorCount;
+ SkCodec::Options options;
+ if (FLAGS_zero_init) {
+ options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
+ }
for (int i = 0; i < n; i++) {
colorCount = 256;
codec.reset(SkCodec::NewFromData(fData));
@@ -54,7 +62,7 @@ void CodecBench::onDraw(int n, SkCanvas* canvas) {
const SkCodec::Result result =
#endif
codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(),
- nullptr, colorTable, &colorCount);
+ &options, colorTable, &colorCount);
SkASSERT(result == SkCodec::kSuccess
|| result == SkCodec::kIncompleteInput);
}