Index: bench/nanobench.cpp |
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp |
index bf99a1eee14db425a5375e07e18ce538ed58314b..efe74020072f6c4416585c5f3ba94adbac33e81f 100644 |
--- a/bench/nanobench.cpp |
+++ b/bench/nanobench.cpp |
@@ -18,6 +18,7 @@ |
#include "ProcStats.h" |
#include "ResultsWriter.h" |
#include "RecordingBench.h" |
+#include "SKPAnimationBench.h" |
#include "SKPBench.h" |
#include "Stats.h" |
#include "Timer.h" |
@@ -82,6 +83,7 @@ DEFINE_int32(maxCalibrationAttempts, 3, |
DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); |
DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
+DEFINE_string(zoom, "1.0,1.0,1", "Comma-separated X,Y,Step zoom factors for SKPs."); |
bsalomon
2015/04/27 14:31:43
Do you think it really makes sense to have two sca
|
DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
@@ -491,6 +493,7 @@ public: |
, fCurrentImage(0) |
, fCurrentSubsetImage(0) |
, fCurrentColorType(0) |
+ , fCurrentAnimSKP(0) |
, fDivisor(2) { |
for (int i = 0; i < FLAGS_skps.count(); i++) { |
if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
@@ -517,6 +520,11 @@ public: |
} |
} |
+ if (3 != sscanf(FLAGS_zoom[0], "%f,%f,%d", &fZoom.fX, &fZoom.fY, &fSteps)) { |
+ SkDebugf("Can't parse %s from --zoom as an SkPoint.\n", FLAGS_zoom[0]); |
+ exit(1); |
+ } |
+ |
fUseMPDs.push_back() = false; |
if (FLAGS_mpd) { |
fUseMPDs.push_back() = true; |
@@ -625,8 +633,9 @@ public: |
fSourceType = "skp"; |
fBenchType = "playback"; |
return SkNEW_ARGS(SKPBench, |
- (name.c_str(), pic.get(), fClip, |
- fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++])); |
+ (name.c_str(), pic.get(), fClip, |
+ fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++])); |
+ |
} |
fCurrentUseMPD = 0; |
fCurrentSKP++; |
@@ -635,6 +644,26 @@ public: |
fCurrentScale++; |
} |
+ // Now loop over each skp again if we have an animation |
+ if ((fZoom.fX != 1.0 || fZoom.fY != 1.0f) && fSteps != 1) { |
+ while (fCurrentAnimSKP < fSKPs.count()) { |
+ const SkString& path = fSKPs[fCurrentAnimSKP]; |
+ SkAutoTUnref<SkPicture> pic; |
+ if (!ReadPicture(path.c_str(), &pic)) { |
+ fCurrentAnimSKP++; |
+ continue; |
+ } |
+ |
+ fCurrentAnimSKP++; |
+ SkString name = SkOSPath::Basename(path.c_str()); |
+ SkMatrix anim = SkMatrix::I(); |
+ anim.setScale(1.1f, 1.1f); |
+ return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), fClip, anim, |
+ fSteps)); |
+ } |
+ } |
+ |
+ |
for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
const SkString& path = fImages[fCurrentCodec]; |
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
@@ -789,6 +818,8 @@ private: |
SkTArray<bool> fUseMPDs; |
SkTArray<SkString> fImages; |
SkTArray<SkColorType> fColorTypes; |
+ SkPoint fZoom; |
+ int fSteps; |
double fSKPBytes, fSKPOps; |
@@ -802,6 +833,7 @@ private: |
int fCurrentImage; |
int fCurrentSubsetImage; |
int fCurrentColorType; |
+ int fCurrentAnimSKP; |
const int fDivisor; |
}; |