aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 18:17:16 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-03 18:17:16 +0000
commit3361471a3504ecd0351ff70f4c42d8d6fee963d4 (patch)
tree1886e770069303c70c588c396b2d9c19343e3adc
parente3bb3bce3e9c1f3bc8ee779b1b3383c18e560bce (diff)
Simplify benchmark internal API.
I'm not quite sure why I wrote such a convoluted API with setLoops()/getLoops(). This replaces it with a loops argument passed to onDraw(). This CL is largely mechanical translation from the old API to the new one. MathBench used this->getLoops() outside onDraw(), which seems incorrect. I fixed it. BUG= R=djsollen@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/99893003 git-svn-id: http://skia.googlecode.com/svn/trunk@12466 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/AAClipBench.cpp16
-rw-r--r--bench/BicubicBench.cpp4
-rw-r--r--bench/BitmapBench.cpp8
-rw-r--r--bench/BitmapRectBench.cpp4
-rw-r--r--bench/BitmapScaleBench.cpp4
-rw-r--r--bench/BlurBench.cpp4
-rw-r--r--bench/BlurImageFilterBench.cpp4
-rw-r--r--bench/BlurRectBench.cpp4
-rw-r--r--bench/BlurRoundRectBench.cpp4
-rw-r--r--bench/ChartBench.cpp4
-rw-r--r--bench/ChecksumBench.cpp10
-rw-r--r--bench/ChromeBench.cpp4
-rw-r--r--bench/CmapBench.cpp4
-rw-r--r--bench/ColorFilterBench.cpp40
-rw-r--r--bench/ColorPrivBench.cpp4
-rw-r--r--bench/CoverageBench.cpp6
-rw-r--r--bench/DashBench.cpp20
-rw-r--r--bench/DecodeBench.cpp4
-rw-r--r--bench/DeferredCanvasBench.cpp10
-rw-r--r--bench/DeferredSurfaceCopyBench.cpp4
-rw-r--r--bench/DisplacementBench.cpp12
-rw-r--r--bench/FSRectBench.cpp4
-rw-r--r--bench/FontCacheBench.cpp6
-rw-r--r--bench/FontScalerBench.cpp4
-rw-r--r--bench/GameBench.cpp4
-rw-r--r--bench/GrMemoryPoolBench.cpp14
-rw-r--r--bench/GrResourceCacheBench.cpp8
-rw-r--r--bench/GradientBench.cpp8
-rw-r--r--bench/HairlinePathBench.cpp4
-rw-r--r--bench/ImageCacheBench.cpp4
-rw-r--r--bench/ImageDecodeBench.cpp4
-rw-r--r--bench/InterpBench.cpp4
-rw-r--r--bench/LightingBench.cpp63
-rw-r--r--bench/LineBench.cpp4
-rw-r--r--bench/MagnifierBench.cpp4
-rw-r--r--bench/MathBench.cpp38
-rw-r--r--bench/Matrix44Bench.cpp4
-rw-r--r--bench/MatrixBench.cpp4
-rw-r--r--bench/MatrixConvolutionBench.cpp4
-rw-r--r--bench/MemoryBench.cpp8
-rw-r--r--bench/MemsetBench.cpp4
-rw-r--r--bench/MergeBench.cpp4
-rw-r--r--bench/MorphologyBench.cpp4
-rw-r--r--bench/MutexBench.cpp4
-rw-r--r--bench/PathBench.cpp66
-rw-r--r--bench/PathIterBench.cpp6
-rw-r--r--bench/PathUtilsBench.cpp4
-rw-r--r--bench/PerlinNoiseBench.cpp10
-rw-r--r--bench/PicturePlaybackBench.cpp6
-rw-r--r--bench/PictureRecordBench.cpp14
-rw-r--r--bench/PremulAndUnpremulAlphaOpsBench.cpp4
-rw-r--r--bench/RTreeBench.cpp8
-rw-r--r--bench/ReadPixBench.cpp4
-rw-r--r--bench/RectBench.cpp16
-rw-r--r--bench/RectoriBench.cpp4
-rw-r--r--bench/RefCntBench.cpp24
-rw-r--r--bench/RegionBench.cpp4
-rw-r--r--bench/RegionContainBench.cpp4
-rw-r--r--bench/RepeatTileBench.cpp4
-rw-r--r--bench/ScalarBench.cpp8
-rw-r--r--bench/ShaderMaskBench.cpp6
-rw-r--r--bench/SkBenchmark.cpp5
-rw-r--r--bench/SkBenchmark.h17
-rw-r--r--bench/SkipZeroesBench.cpp4
-rw-r--r--bench/SortBench.cpp4
-rw-r--r--bench/StrokeBench.cpp4
-rw-r--r--bench/TableBench.cpp4
-rw-r--r--bench/TextBench.cpp4
-rw-r--r--bench/TileBench.cpp4
-rw-r--r--bench/VertBench.cpp4
-rw-r--r--bench/WritePixelsBench.cpp4
-rw-r--r--bench/WriterBench.cpp4
-rw-r--r--bench/XfermodeBench.cpp8
-rw-r--r--bench/benchmain.cpp9
74 files changed, 331 insertions, 319 deletions
diff --git a/bench/AAClipBench.cpp b/bench/AAClipBench.cpp
index dfafe97671..ab0f4f9a00 100644
--- a/bench/AAClipBench.cpp
+++ b/bench/AAClipBench.cpp
@@ -43,12 +43,12 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
// jostle the clip regions each time to prevent caching
fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-10), 0);
fClipPath.reset();
@@ -158,9 +158,9 @@ protected:
canvas->restore();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkPoint offset = SkPoint::Make(0, 0);
this->recurse(canvas, 0, offset);
}
@@ -195,11 +195,11 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkPaint paint;
this->setupPaint(&paint);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkAAClip clip;
if (fDoPath) {
clip.setPath(fPath, &fRegion, fDoAA);
@@ -230,8 +230,8 @@ public:
protected:
virtual const char* onGetName() { return "aaclip_setregion"; }
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
SkAAClip clip;
clip.setRegion(fRegion);
}
diff --git a/bench/BicubicBench.cpp b/bench/BicubicBench.cpp
index d1f4a4de72..162ec61370 100644
--- a/bench/BicubicBench.cpp
+++ b/bench/BicubicBench.cpp
@@ -30,7 +30,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
@@ -40,7 +40,7 @@ protected:
SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell(fScale));
paint.setImageFilter(bicubic);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->save();
canvas->clipRect(r);
canvas->drawOval(r, paint);
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 6dc759283e..2b0cabfc37 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -130,7 +130,7 @@ protected:
fBitmap.setIsVolatile(fIsVolatile);
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkIPoint dim = this->getSize();
SkRandom rand;
@@ -141,7 +141,7 @@ protected:
const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2);
const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
@@ -221,7 +221,7 @@ protected:
return fFullName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkISize dim = canvas->getDeviceSize();
if (fFlags & kScale_Flag) {
const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
@@ -240,7 +240,7 @@ protected:
canvas->rotate(SkIntToScalar(35));
canvas->translate(-x, -y);
}
- INHERITED::onDraw(canvas);
+ INHERITED::onDraw(loops, canvas);
}
virtual void setupPaint(SkPaint* paint) SK_OVERRIDE {
diff --git a/bench/BitmapRectBench.cpp b/bench/BitmapRectBench.cpp
index 6029aebda2..affed723d9 100644
--- a/bench/BitmapRectBench.cpp
+++ b/bench/BitmapRectBench.cpp
@@ -87,7 +87,7 @@ protected:
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
SkPaint paint;
@@ -95,7 +95,7 @@ protected:
paint.setFilterLevel(fFilterLevel);
paint.setAlpha(fAlpha);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint);
}
}
diff --git a/bench/BitmapScaleBench.cpp b/bench/BitmapScaleBench.cpp
index ae3df71c22..926111d12d 100644
--- a/bench/BitmapScaleBench.cpp
+++ b/bench/BitmapScaleBench.cpp
@@ -69,13 +69,13 @@ protected:
fMatrix.setScale( scale(), scale() );
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkPaint paint;
this->setupPaint(&paint);
preBenchSetup();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
doScaleImage();
}
}
diff --git a/bench/BlurBench.cpp b/bench/BlurBench.cpp
index 49a6297c54..5f735dd8cf 100644
--- a/bench/BlurBench.cpp
+++ b/bench/BlurBench.cpp
@@ -52,14 +52,14 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
paint.setAntiAlias(true);
SkRandom rand;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
rand.nextUScalar1() * 400);
r.offset(fRadius, fRadius);
diff --git a/bench/BlurImageFilterBench.cpp b/bench/BlurImageFilterBench.cpp
index 1c4d4bf361..c39573d8e8 100644
--- a/bench/BlurImageFilterBench.cpp
+++ b/bench/BlurImageFilterBench.cpp
@@ -41,11 +41,11 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
}
}
diff --git a/bench/BlurRectBench.cpp b/bench/BlurRectBench.cpp
index e2528afc7f..d4876ce8a8 100644
--- a/bench/BlurRectBench.cpp
+++ b/bench/BlurRectBench.cpp
@@ -51,7 +51,7 @@ protected:
fName = name;
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkPaint paint;
this->setupPaint(&paint);
@@ -62,7 +62,7 @@ protected:
preBenchSetup(r);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
makeBlurryRect(r);
}
}
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp
index 814e8f474c..2c8ea95f17 100644
--- a/bench/BlurRoundRectBench.cpp
+++ b/bench/BlurRoundRectBench.cpp
@@ -39,7 +39,7 @@ public:
SkScalarCeilToInt(fRRect.rect().height()));
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkLayerDrawLooper* looper = new SkLayerDrawLooper;
{
SkLayerDrawLooper::LayerInfo info;
@@ -72,7 +72,7 @@ public:
loopedPaint.setAntiAlias(true);
loopedPaint.setColor(SK_ColorCYAN);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawRect(fRRect.rect(), dullPaint);
canvas->drawRRect(fRRect, loopedPaint);
}
diff --git a/bench/ChartBench.cpp b/bench/ChartBench.cpp
index ceb62b485b..47fe7527c7 100644
--- a/bench/ChartBench.cpp
+++ b/bench/ChartBench.cpp
@@ -102,7 +102,7 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
bool sizeChanged = false;
if (canvas->getDeviceSize() != fSize) {
fSize = canvas->getDeviceSize();
@@ -122,7 +122,7 @@ protected:
}
}
- for (int frame = 0; frame < this->getLoops(); ++frame) {
+ for (int frame = 0; frame < loops; ++frame) {
canvas->clear(0xFFE0F0E0);
diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp
index d57ede370b..898c411641 100644
--- a/bench/ChecksumBench.cpp
+++ b/bench/ChecksumBench.cpp
@@ -51,16 +51,16 @@ protected:
}
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
switch (fType) {
case kChecksum_ChecksumType: {
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
volatile uint32_t result = SkChecksum::Compute(fData, sizeof(fData));
sk_ignore_unused_variable(result);
}
} break;
case kMD5_ChecksumType: {
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkMD5 md5;
md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkMD5::Digest digest;
@@ -68,7 +68,7 @@ protected:
}
} break;
case kSHA1_ChecksumType: {
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkSHA1 sha1;
sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkSHA1::Digest digest;
@@ -76,7 +76,7 @@ protected:
}
} break;
case kMurmur3_ChecksumType: {
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof(fData));
sk_ignore_unused_variable(result);
}
diff --git a/bench/ChromeBench.cpp b/bench/ChromeBench.cpp
index 9392065e56..b2fc185f20 100644
--- a/bench/ChromeBench.cpp
+++ b/bench/ChromeBench.cpp
@@ -461,14 +461,14 @@ public:
protected:
virtual const char* onGetName() { return "chrome_scrollGmail"; }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkDEBUGCODE(this->validateBounds(canvas));
SkPaint paint;
this->setupPaint(&paint);
for (int i = 0; i < N; i++) {
SkRect current;
setRectangle(current, i);
- for (int j = 0; j < this->getLoops() * gmailScrollingRectSpec[i*3]; j++) {
+ for (int j = 0; j < loops * gmailScrollingRectSpec[i*3]; j++) {
canvas->drawRect(current, paint);
}
}
diff --git a/bench/CmapBench.cpp b/bench/CmapBench.cpp
index 1d2a5ee4e3..fcf40be88a 100644
--- a/bench/CmapBench.cpp
+++ b/bench/CmapBench.cpp
@@ -85,8 +85,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- fProc(this->getLoops(), fPaint, fText, sizeof(fText), NGLYPHS);
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ fProc(loops, fPaint, fText, sizeof(fText), NGLYPHS);
}
private:
diff --git a/bench/ColorFilterBench.cpp b/bench/ColorFilterBench.cpp
index ad27f15806..9fec587b5c 100644
--- a/bench/ColorFilterBench.cpp
+++ b/bench/ColorFilterBench.cpp
@@ -72,12 +72,12 @@ protected:
return isSmall() ? "colorfilter_dim_bright_small" : "colorfilter_dim_bright_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
for (float brightness = -1.0f; brightness <= 1.0f; brightness += 0.4f) {
SkAutoTUnref<SkImageFilter> dim(make_brightness(-brightness));
SkAutoTUnref<SkImageFilter> bright(make_brightness(brightness, dim));
@@ -102,11 +102,11 @@ protected:
return isSmall() ? "colorfilter_bright_gray_small" : "colorfilter_bright_gray_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.9f));
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale(brightness));
paint.setImageFilter(grayscale);
@@ -129,11 +129,11 @@ protected:
return isSmall() ? "colorfilter_gray_bright_small" : "colorfilter_gray_bright_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale());
SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.9f, grayscale));
paint.setImageFilter(brightness);
@@ -156,11 +156,11 @@ protected:
return isSmall() ? "colorfilter_blue_bright_small" : "colorfilter_blue_bright_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> blue(make_mode_blue());
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f, blue));
paint.setImageFilter(brightness);
@@ -183,11 +183,11 @@ protected:
return isSmall() ? "colorfilter_bright_blue_small" : "colorfilter_bright_blue_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f));
SkAutoTUnref<SkImageFilter> blue(make_mode_blue(brightness));
paint.setImageFilter(blue);
@@ -210,11 +210,11 @@ protected:
return isSmall() ? "colorfilter_bright_small" : "colorfilter_bright_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f));
paint.setImageFilter(brightness);
canvas->drawRect(r, paint);
@@ -236,11 +236,11 @@ protected:
return isSmall() ? "colorfilter_blue_small" : "colorfilter_blue_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> blue(make_mode_blue());
paint.setImageFilter(blue);
canvas->drawRect(r, paint);
@@ -262,11 +262,11 @@ protected:
return isSmall() ? "colorfilter_gray_small" : "colorfilter_gray_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale());
paint.setImageFilter(grayscale);
canvas->drawRect(r, paint);
@@ -288,11 +288,11 @@ protected:
return isSmall() ? "table_colorfilter_small" : "table_colorfilter_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkColorFilter> table_filter(make_table_filter());
paint.setColorFilter(table_filter);
canvas->drawRect(r, paint);
@@ -326,12 +326,12 @@ protected:
return isSmall() ? "luma_colorfilter_small" : "luma_colorfilter_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkAutoTUnref<SkColorFilter> luma_filter(SkLumaColorFilter::Create());
paint.setColorFilter(luma_filter);
canvas->drawRect(r, paint);
diff --git a/bench/ColorPrivBench.cpp b/bench/ColorPrivBench.cpp
index 1e152e6d62..328de4aebd 100644
--- a/bench/ColorPrivBench.cpp
+++ b/bench/ColorPrivBench.cpp
@@ -24,10 +24,10 @@ public:
virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
const SkPMColor src = 0xAB998877, dst = 0x66334455;
volatile SkPMColor junk = 0;
- for (int i = 0; i < 10*this->getLoops(); ++i) {
+ for (int i = 0; i < 10*loops; ++i) {
for (size_t j = 0; j <= 256; j++) {
const unsigned scale = fScales[j];
if (kFast && kScale) {
diff --git a/bench/CoverageBench.cpp b/bench/CoverageBench.cpp
index 455151740a..2c84102f7d 100644
--- a/bench/CoverageBench.cpp
+++ b/bench/CoverageBench.cpp
@@ -49,13 +49,13 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
if (fDrawCoverage) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
fDraw.drawPathCoverage(fPath, fPaint);
}
} else {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
fDraw.drawPath(fPath, fPaint);
}
}
diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp
index 040dfd568d..2e4bc376bc 100644
--- a/bench/DashBench.cpp
+++ b/bench/DashBench.cpp
@@ -61,7 +61,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
paint.setStyle(SkPaint::kStroke_Style);
@@ -82,7 +82,7 @@ protected:
canvas->clipRect(r);
}
- this->handlePath(canvas, path, paint, this->getLoops());
+ this->handlePath(canvas, path, paint, loops);
}
virtual void handlePath(SkCanvas* canvas, const SkPath& path,
@@ -194,9 +194,9 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkPath dst;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle);
fPE->filterPath(&dst, fPath, &rec, NULL);
@@ -232,13 +232,13 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
paint.setStrokeWidth(fStrokeWidth);
paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap);
paint.setPathEffect(fPE);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1,
640 * SK_Scalar1, 10 * SK_Scalar1, paint);
}
@@ -271,7 +271,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint p;
this->setupPaint(&p);
p.setColor(SK_ColorBLACK);
@@ -285,7 +285,7 @@ protected:
{ SkIntToScalar(640), 0 }
};
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
pts[0].fY = pts[1].fY = SkIntToScalar(i % 480);
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
}
@@ -357,14 +357,14 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint p;
this->setupPaint(&p);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(fStrokeWidth);
p.setPathEffect(fPathEffect);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p);
}
}
diff --git a/bench/DecodeBench.cpp b/bench/DecodeBench.cpp
index cbcc4a6889..3f535d2f7c 100644
--- a/bench/DecodeBench.cpp
+++ b/bench/DecodeBench.cpp
@@ -40,8 +40,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); i++) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; i++) {
SkBitmap bm;
SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0],
&bm,
diff --git a/bench/DeferredCanvasBench.cpp b/bench/DeferredCanvasBench.cpp
index d2fb9f22ae..6bf4dfdc3b 100644
--- a/bench/DeferredCanvasBench.cpp
+++ b/bench/DeferredCanvasBench.cpp
@@ -24,7 +24,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkBaseDevice *device = canvas->getDevice()->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false);
@@ -32,13 +32,13 @@ protected:
device->unref();
initDeferredCanvas(deferredCanvas);
- drawInDeferredCanvas(deferredCanvas);
+ drawInDeferredCanvas(loops, deferredCanvas);
finalizeDeferredCanvas(deferredCanvas);
deferredCanvas->flush();
}
virtual void initDeferredCanvas(SkDeferredCanvas* canvas) = 0;
- virtual void drawInDeferredCanvas(SkDeferredCanvas* canvas) = 0;
+ virtual void drawInDeferredCanvas(const int loops, SkDeferredCanvas* canvas) = 0;
virtual void finalizeDeferredCanvas(SkDeferredCanvas* canvas) = 0;
SkString fName;
@@ -76,11 +76,11 @@ protected:
canvas->setNotificationClient(&fNotificationClient);
}
- virtual void drawInDeferredCanvas(SkDeferredCanvas* canvas) SK_OVERRIDE {
+ virtual void drawInDeferredCanvas(const int loops, SkDeferredCanvas* canvas) SK_OVERRIDE {
SkRect rect;
rect.setXYWH(0, 0, 10, 10);
SkPaint paint;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
canvas->translate(SkIntToScalar(i * 27 % CANVAS_WIDTH), SkIntToScalar(i * 13 % CANVAS_HEIGHT));
canvas->drawRect(rect, paint);
diff --git a/bench/DeferredSurfaceCopyBench.cpp b/bench/DeferredSurfaceCopyBench.cpp
index 91b34a90c0..713078038e 100644
--- a/bench/DeferredSurfaceCopyBench.cpp
+++ b/bench/DeferredSurfaceCopyBench.cpp
@@ -31,7 +31,7 @@ protected:
"DeferredSurfaceCopy_nonDiscardable";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
// The canvas is not actually used for this test except to provide
// configuration information: gpu, multisampling, size, etc?
SkImageInfo info;
@@ -55,7 +55,7 @@ protected:
SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(surface));
surface->unref();
- for (int iteration = 0; iteration < this->getLoops(); iteration++) {
+ for (int iteration = 0; iteration < loops; iteration++) {
drawingCanvas->clear(0);
SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot());
SkPaint paint;
diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp
index 72d482ee0e..77ac305852 100644
--- a/bench/DisplacementBench.cpp
+++ b/bench/DisplacementBench.cpp
@@ -99,7 +99,7 @@ protected:
return this->isSmall() ? "displacement_zero_small" : "displacement_zero_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
// No displacement effect
@@ -107,7 +107,7 @@ protected:
(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 0, 0, paint);
}
}
@@ -126,14 +126,14 @@ protected:
return isSmall() ? "displacement_alpha_small" : "displacement_alpha_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
// Displacement, with 1 alpha component (which isn't pre-multiplied)
paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
(SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
drawClippedBitmap(canvas, 100, 0, paint);
}
}
@@ -152,14 +152,14 @@ protected:
return isSmall() ? "displacement_full_small" : "displacement_full_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
// Displacement, with 2 non-alpha components
paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->unref();
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
this->drawClippedBitmap(canvas, 200, 0, paint);
}
}
diff --git a/bench/FSRectBench.cpp b/bench/FSRectBench.cpp
index 80f10bd7e4..ea65f30eee 100644
--- a/bench/FSRectBench.cpp
+++ b/bench/FSRectBench.cpp
@@ -39,9 +39,9 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
paint.setColor(fColors[i % N]);
canvas->drawRect(fRects[i % N], paint);
}
diff --git a/bench/FontCacheBench.cpp b/bench/FontCacheBench.cpp
index a52fd42ef2..a3c0672ef4 100644
--- a/bench/FontCacheBench.cpp
+++ b/bench/FontCacheBench.cpp
@@ -32,7 +32,7 @@ protected:
return "fontcache";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
@@ -40,7 +40,7 @@ protected:
const uint16_t* array = gUniqueGlyphIDs;
while (*array != gUniqueGlyphIDs_Sentinel) {
int count = count_glyphs(array);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
paint.measureText(array, count * sizeof(uint16_t));
}
array += count + 1; // skip the sentinel
@@ -119,7 +119,7 @@ protected:
return "fontefficiency";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
static bool gDone;
if (gDone) {
return;
diff --git a/bench/FontScalerBench.cpp b/bench/FontScalerBench.cpp
index d4a9674bcc..6ef0703346 100644
--- a/bench/FontScalerBench.cpp
+++ b/bench/FontScalerBench.cpp
@@ -27,7 +27,7 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
paint.setLCDRenderText(fDoLCD);
@@ -35,7 +35,7 @@ protected:
bool prev = gSkSuppressFontCachePurgeSpew;
gSkSuppressFontCachePurgeSpew = true;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
// this is critical - we want to time the creation process, so we
// explicitly flush our cache before each run
SkGraphics::PurgeFontCache();
diff --git a/bench/GameBench.cpp b/bench/GameBench.cpp
index 3d371bee2b..839440b612 100644
--- a/bench/GameBench.cpp
+++ b/bench/GameBench.cpp
@@ -86,7 +86,7 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom scaleRand;
SkRandom transRand;
SkRandom rotRand;
@@ -143,7 +143,7 @@ protected:
SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode))->unref();
- for (int i = 0; i < this->getLoops(); ++i, ++fNumSaved) {
+ for (int i = 0; i < loops; ++i, ++fNumSaved) {
if (0 == i % kNumBeforeClear) {
if (kPartial_Clear == fClear) {
for (int j = 0; j < fNumSaved; ++j) {
diff --git a/bench/GrMemoryPoolBench.cpp b/bench/GrMemoryPoolBench.cpp
index b692aae432..21f686d89d 100644
--- a/bench/GrMemoryPoolBench.cpp
+++ b/bench/GrMemoryPoolBench.cpp
@@ -41,7 +41,7 @@ protected:
return "grmemorypool_stack";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkRandom r;
enum {
kMaxObjects = 4 * (1 << 10),
@@ -51,11 +51,11 @@ protected:
// We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise,
// we allocate. We start allocate-biased and ping-pong to delete-biased
SkFixed delThresh = -SK_FixedHalf;
- const int kSwitchThreshPeriod = this->getLoops() / (2 * kMaxObjects);
+ const int kSwitchThreshPeriod = loops / (2 * kMaxObjects);
int s = 0;
int count = 0;
- for (int i = 0; i < this->getLoops(); i++, ++s) {
+ for (int i = 0; i < loops; i++, ++s) {
if (kSwitchThreshPeriod == s) {
delThresh = -delThresh;
s = 0;
@@ -93,14 +93,14 @@ protected:
return "grmemorypool_random";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkRandom r;
enum {
kMaxObjects = 4 * (1 << 10),
};
SkAutoTDelete<A> objects[kMaxObjects];
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
if (NULL == objects[idx].get()) {
objects[idx].reset(new A);
@@ -131,10 +131,10 @@ protected:
return "grmemorypool_queue";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkRandom r;
A* objects[M];
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
uint32_t count = r.nextRangeU(0, M-1);
for (uint32_t i = 0; i < count; i++) {
objects[i] = new A;
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index ea8297dec5..d8e63d530a 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -183,10 +183,10 @@ protected:
return "grresourcecache_add";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
GrGpu* gpu = canvas->getGrContext()->getGpu();
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES);
populate_cache(&cache, gpu, DUPLICATE_COUNT);
populate_cache(&cache, gpu, RESOURCE_COUNT);
@@ -219,13 +219,13 @@ protected:
return "grresourcecache_find";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
GrGpu* gpu = canvas->getGrContext()->getGpu();
GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES);
populate_cache(&cache, gpu, DUPLICATE_COUNT);
populate_cache(&cache, gpu, RESOURCE_COUNT);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
for (int k = 0; k < RESOURCE_COUNT; ++k) {
check_cache_contents_or_die(&cache, k);
}
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp
index 63fa8ae4c3..9c6c48a235 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -203,14 +203,14 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
paint.setShader(fShader);
SkRect r = { 0, 0, SkIntToScalar(W), SkIntToScalar(H) };
- for (int i = 0; i < this->getLoops() * kRepeat; i++) {
+ for (int i = 0; i < loops * kRepeat; i++) {
switch (fGeomType) {
case kRect_GeomType:
canvas->drawRect(r, paint);
@@ -273,7 +273,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
@@ -283,7 +283,7 @@ protected:
{ SkIntToScalar(100), SkIntToScalar(100) },
};
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
const int gray = i % 256;
const int alpha = fHasAlpha ? gray : 0xFF;
SkColor colors[] = {
diff --git a/bench/HairlinePathBench.cpp b/bench/HairlinePathBench.cpp
index c59647572a..87557e8467 100644
--- a/bench/HairlinePathBench.cpp
+++ b/bench/HairlinePathBench.cpp
@@ -49,7 +49,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint(fPaint);
this->setupPaint(&paint);
@@ -63,7 +63,7 @@ protected:
path.transform(m);
}
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawPath(path, paint);
}
}
diff --git a/bench/ImageCacheBench.cpp b/bench/ImageCacheBench.cpp
index ea295fd094..9fc538ebef 100644
--- a/bench/ImageCacheBench.cpp
+++ b/bench/ImageCacheBench.cpp
@@ -38,14 +38,14 @@ protected:
return "imagecache";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
if (fCache.getBytesUsed() == 0) {
this->populateCache();
}
SkBitmap tmp;
// search for a miss (-1 scale)
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
(void)fCache.findAndLock(fBM, -1, -1, &tmp);
}
}
diff --git a/bench/ImageDecodeBench.cpp b/bench/ImageDecodeBench.cpp
index af0569fc6f..a2ca0ecaec 100644
--- a/bench/ImageDecodeBench.cpp
+++ b/bench/ImageDecodeBench.cpp
@@ -52,7 +52,7 @@ protected:
}
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
#ifdef SK_DEBUG
if (!fValid) {
SkDebugf("stream was invalid: %s\n", fName.c_str());
@@ -61,7 +61,7 @@ protected:
#endif
// Decode a bunch of times
SkBitmap bm;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &bm);
#ifdef SK_DEBUG
if (!success) {
diff --git a/bench/InterpBench.cpp b/bench/InterpBench.cpp
index 9cd99df017..f6f70d44c8 100644
--- a/bench/InterpBench.cpp
+++ b/bench/InterpBench.cpp
@@ -35,8 +35,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
- int n = this->getLoops() * this->mulLoopCount();
+ virtual void onDraw(const int loops, SkCanvas*) {
+ int n = loops * this->mulLoopCount();
for (int i = 0; i < n; i++) {
this->performTest(fDst, fFx, fDx, kBuffer);
}
diff --git a/bench/LightingBench.cpp b/bench/LightingBench.cpp
index 7a1b5998d8..4529041a78 100644
--- a/bench/LightingBench.cpp
+++ b/bench/LightingBench.cpp
@@ -20,12 +20,12 @@ public:
LightingBaseBench(bool small) : fIsSmall(small) { }
protected:
- void draw(SkCanvas* canvas, SkImageFilter* imageFilter) const {
+ void draw(const int loops, SkCanvas* canvas, SkImageFilter* imageFilter) const {
SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMALL) :
SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARGE);
SkPaint paint;
paint.setImageFilter(imageFilter)->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawRect(r, paint);
}
}
@@ -105,9 +105,11 @@ protected:
return fIsSmall ? "lightingpointlitdiffuse_small" : "lightingpointlitdiffuse_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreatePointLitDiffuse(getPointLocation(), getWhite(),
- getSurfaceScale(), getKd()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreatePointLitDiffuse(getPointLocation(),
+ getWhite(),
+ getSurfaceScale(),
+ getKd()));
}
private:
@@ -124,9 +126,11 @@ protected:
return fIsSmall ? "lightingdistantlitdiffuse_small" : "lightingdistantlitdiffuse_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreateDistantLitDiffuse(getDistantDirection(),
- getWhite(), getSurfaceScale(), getKd()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreateDistantLitDiffuse(getDistantDirection(),
+ getWhite(),
+ getSurfaceScale(),
+ getKd()));
}
private:
@@ -143,10 +147,14 @@ protected:
return fIsSmall ? "lightingspotlitdiffuse_small" : "lightingspotlitdiffuse_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreateSpotLitDiffuse(getSpotLocation(),
- getSpotTarget(), getSpotExponent(), getCutoffAngle(), getWhite(), getSurfaceScale(),
- getKd()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreateSpotLitDiffuse(getSpotLocation(),
+ getSpotTarget(),
+ getSpotExponent(),
+ getCutoffAngle(),
+ getWhite(),
+ getSurfaceScale(),
+ getKd()));
}
private:
@@ -163,9 +171,12 @@ protected:
return fIsSmall ? "lightingpointlitspecular_small" : "lightingpointlitspecular_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreatePointLitSpecular(getPointLocation(), getWhite(),
- getSurfaceScale(), getKs(), getShininess()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreatePointLitSpecular(getPointLocation(),
+ getWhite(),
+ getSurfaceScale(),
+ getKs(),
+ getShininess()));
}
private:
@@ -182,9 +193,12 @@ protected:
return fIsSmall ? "lightingdistantlitspecular_small" : "lightingdistantlitspecular_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreateDistantLitSpecular(getDistantDirection(),
- getWhite(), getSurfaceScale(), getKs(), getShininess()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreateDistantLitSpecular(getDistantDirection(),
+ getWhite(),
+ getSurfaceScale(),
+ getKs(),
+ getShininess()));
}
private:
@@ -201,10 +215,15 @@ protected:
return fIsSmall ? "lightingspotlitspecular_small" : "lightingspotlitspecular_large";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- draw(canvas, SkLightingImageFilter::CreateSpotLitSpecular(getSpotLocation(),
- getSpotTarget(), getSpotExponent(), getCutoffAngle(), getWhite(), getSurfaceScale(),
- getKs(), getShininess()));
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ draw(loops, canvas, SkLightingImageFilter::CreateSpotLitSpecular(getSpotLocation(),
+ getSpotTarget(),
+ getSpotExponent(),
+ getCutoffAngle(),
+ getWhite(),
+ getSurfaceScale(),
+ getKs(),
+ getShininess()));
}
private:
diff --git a/bench/LineBench.cpp b/bench/LineBench.cpp
index e69a40a94c..dc57d9f165 100644
--- a/bench/LineBench.cpp
+++ b/bench/LineBench.cpp
@@ -42,7 +42,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
@@ -50,7 +50,7 @@ protected:
paint.setAntiAlias(fDoAA);
paint.setStrokeWidth(fStrokeWidth);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawPoints(SkCanvas::kLines_PointMode, PTS, fPts, paint);
}
}
diff --git a/bench/MagnifierBench.cpp b/bench/MagnifierBench.cpp
index b5561a22a8..5c53244275 100644
--- a/bench/MagnifierBench.cpp
+++ b/bench/MagnifierBench.cpp
@@ -33,7 +33,7 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
SkPaint paint;
@@ -44,7 +44,7 @@ protected:
SkIntToScalar(w / 2),
SkIntToScalar(h / 2)), 100))->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
}
}
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 8094219f9d..da65456822 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -46,8 +46,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
- int n = this->getLoops() * this->mulLoopCount();
+ virtual void onDraw(const int loops, SkCanvas*) {
+ int n = loops * this->mulLoopCount();
for (int i = 0; i < n; i++) {
this->performTest(fDst, fSrc, kBuffer);
}
@@ -290,20 +290,20 @@ public:
}
protected:
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
IsFiniteProc proc = fProc;
const float* data = fData;
// do this so the compiler won't throw away the function call
int counter = 0;
if (proc) {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < N - 4; ++i) {
counter += proc(&data[i]);
}
}
} else {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < N - 4; ++i) {
const SkRect* r = reinterpret_cast<const SkRect*>(&data[i]);
if (false) { // avoid bit rot, suppress warning
@@ -360,20 +360,20 @@ public:
virtual void process(float) {}
protected:
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SkRandom rand;
float accum = 0;
const float* data = fData;
if (fFast) {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += fast_floor(data[i]);
}
this->process(accum);
}
} else {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += sk_float_floor(data[i]);
}
@@ -422,18 +422,18 @@ public:
virtual void process(int) {}
protected:
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
int accum = 0;
if (fUsePortable) {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += SkCLZ_portable(fData[i]);
}
this->process(accum);
}
} else {
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += SkCLZ(fData[i]);
}
@@ -478,10 +478,10 @@ public:
virtual void process(int) {}
protected:
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
int accum = 0;
- for (int j = 0; j < this->getLoops(); ++j) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += fVec[i].normalize();
}
@@ -511,8 +511,8 @@ public:
FixedMathBench() {
SkRandom rand;
- for (int i = 0; i < this->getLoops(); ++i) {
- fData[i%N] = rand.nextSScalar1();
+ for (int i = 0; i < N; ++i) {
+ fData[i] = rand.nextSScalar1();
}
}
@@ -522,8 +522,8 @@ public:
}
protected:
- virtual void onDraw(SkCanvas*) {
- for (int j = 0; j < this->getLoops(); ++j) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int j = 0; j < loops; ++j) {
for (int i = 0; i < N - 4; ++i) {
fResult[i] = SkFloatToFixed(fData[i]);
}
@@ -562,10 +562,10 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
volatile T a = 0, b = 0;
T div = 0, mod = 0;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
if ((T)i == 0) continue; // Small T will wrap around.
SkTDivMod((T)(i+1), (T)i, &div, &mod);
a ^= div;
diff --git a/bench/Matrix44Bench.cpp b/bench/Matrix44Bench.cpp
index 7c0c0deb92..55f377cb03 100644
--- a/bench/Matrix44Bench.cpp
+++ b/bench/Matrix44Bench.cpp
@@ -30,8 +30,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); i++) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; i++) {
this->performTest();
}
}
diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp
index 4b8cf0223e..7258ff579d 100644
--- a/bench/MatrixBench.cpp
+++ b/bench/MatrixBench.cpp
@@ -31,8 +31,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); i++) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; i++) {
this->performTest();
}
}
diff --git a/bench/MatrixConvolutionBench.cpp b/bench/MatrixConvolutionBench.cpp
index 5e3e201a20..1acc0cb01a 100644
--- a/bench/MatrixConvolutionBench.cpp
+++ b/bench/MatrixConvolutionBench.cpp
@@ -35,12 +35,12 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
paint.setAntiAlias(true);
SkRandom rand;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
rand.nextUScalar1() * 400);
paint.setImageFilter(fFilter);
diff --git a/bench/MemoryBench.cpp b/bench/MemoryBench.cpp
index e3ac2c33b3..19919ab635 100644
--- a/bench/MemoryBench.cpp
+++ b/bench/MemoryBench.cpp
@@ -30,14 +30,14 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
size_t inc = fMinSize >> 4;
SkASSERT(inc > 0);
size_t total = fMinSize * 64;
SkChunkAlloc alloc(fMinSize);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
size_t size = 0;
int calls = 0;
while (size < total) {
@@ -99,8 +99,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); i++) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; i++) {
int* zeros = fUseCalloc ? calloc(fNum) : malloc_bzero(fNum);
if (fRead) {
volatile int x = 15;
diff --git a/bench/MemsetBench.cpp b/bench/MemsetBench.cpp
index 17adf0402a..bfdff5cbcc 100644
--- a/bench/MemsetBench.cpp
+++ b/bench/MemsetBench.cpp
@@ -47,8 +47,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
this->performTest();
}
}
diff --git a/bench/MergeBench.cpp b/bench/MergeBench.cpp
index 51be22f284..1723cbfc21 100644
--- a/bench/MergeBench.cpp
+++ b/bench/MergeBench.cpp
@@ -32,12 +32,12 @@ protected:
}
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMALL) :
SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARGE);
SkPaint paint;
paint.setImageFilter(mergeBitmaps())->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawRect(r, paint);
}
}
diff --git a/bench/MorphologyBench.cpp b/bench/MorphologyBench.cpp
index 956cbbee30..63171c2c12 100644
--- a/bench/MorphologyBench.cpp
+++ b/bench/MorphologyBench.cpp
@@ -50,14 +50,14 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
paint.setAntiAlias(true);
SkRandom rand;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
rand.nextUScalar1() * 400);
r.offset(fRadius, fRadius);
diff --git a/bench/MutexBench.cpp b/bench/MutexBench.cpp
index bec0c8058c..3191ce17be 100644
--- a/bench/MutexBench.cpp
+++ b/bench/MutexBench.cpp
@@ -18,9 +18,9 @@ protected:
return "mutex";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
SK_DECLARE_STATIC_MUTEX(mu);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
mu.acquire();
mu.release();
}
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index b3d4ab1200..67bc901c28 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -50,7 +50,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint(fPaint);
this->setupPaint(&paint);
@@ -62,7 +62,7 @@ protected:
path.transform(m);
}
- int count = this->getLoops();
+ int count = loops;
if (fFlags & kBig_Flag) {
count >>= 2;
}
@@ -330,8 +330,8 @@ protected:
fPaths.reset(kPathCnt);
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
this->makePath(&fPaths[i & (kPathCnt - 1)]);
}
this->restartMakingPaths();
@@ -370,8 +370,8 @@ protected:
}
this->finishedMakingPaths();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
fCopies[idx] = fPaths[idx];
}
@@ -414,13 +414,13 @@ protected:
}
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
if (fInPlace) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
fPaths[i & (kPathCnt - 1)].transform(fMatrix);
}
} else {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
fPaths[idx].transform(fMatrix, &fTransformed[idx]);
}
@@ -466,8 +466,8 @@ protected:
this->finishedMakingPaths();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]);
}
@@ -535,38 +535,38 @@ protected:
this->finishedMakingPaths();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
switch (fType) {
case kAdd_AddType:
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
SkPath result = fPaths0[idx];
result.addPath(fPaths1[idx]);
}
break;
case kAddTrans_AddType:
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
SkPath result = fPaths0[idx];
result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1);
}
break;
case kAddMatrix_AddType:
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
SkPath result = fPaths0[idx];
result.addPath(fPaths1[idx], fMatrix);
}
break;
case kReverseAdd_AddType:
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
SkPath result = fPaths0[idx];
result.reverseAddPath(fPaths1[idx]);
}
break;
case kReversePathTo_AddType:
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
int idx = i & (kPathCnt - 1);
SkPath result = fPaths0[idx];
result.reversePathTo(fPaths1[idx]);
@@ -608,7 +608,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setColor(SK_ColorBLACK);
@@ -621,7 +621,7 @@ protected:
SkRect r;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkScalar radius = rand.nextUScalar1() * 3;
r.fLeft = rand.nextUScalar1() * 300;
r.fTop = rand.nextUScalar1() * 300;
@@ -714,11 +714,11 @@ protected:
SkASSERT(path->isConvex());
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
SkRect r;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkPaint paint;
paint.setColor(0xff000000 | rand.nextU());
paint.setAntiAlias(true);
@@ -788,8 +788,8 @@ private:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
const SkRect& rect = fQueryRects[i % kQueryRectCnt];
fParity = fParity != fPath.conservativelyContainsRect(rect);
}
@@ -851,9 +851,9 @@ private:
return "ratquad-chop-0.5";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkConic dst[2];
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
fRQ.chopAt(0.5f, dst);
}
}
@@ -876,9 +876,9 @@ private:
return "ratquad-chop-half";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkConic dst[2];
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
fRQ.chop(dst);
}
}
@@ -931,9 +931,9 @@ protected:
return "conic-compute-error";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkVector err;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
for (int j = 0; j < CONICS; ++j) {
fConics[j].computeAsQuadError(&err);
}
@@ -953,8 +953,8 @@ protected:
return "conic-asQuadTol";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
for (int j = 0; j < CONICS; ++j) {
fConics[j].asQuadTol(SK_ScalarHalf);
}
@@ -974,8 +974,8 @@ protected:
return "conic-quadPow2";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; ++i) {
for (int j = 0; j < CONICS; ++j) {
fConics[j].computeQuadPOW2(SK_ScalarHalf);
}
diff --git a/bench/PathIterBench.cpp b/bench/PathIterBench.cpp
index aa2042ca43..4e956ce3a5 100644
--- a/bench/PathIterBench.cpp
+++ b/bench/PathIterBench.cpp
@@ -65,9 +65,9 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
if (fRaw) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkPath::RawIter iter(fPath);
SkPath::Verb verb;
SkPoint pts[4];
@@ -75,7 +75,7 @@ protected:
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { }
}
} else {
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkPath::Iter iter(fPath, false);
SkPath::Verb verb;
SkPoint pts[4];
diff --git a/bench/PathUtilsBench.cpp b/bench/PathUtilsBench.cpp
index 06ef5dffb4..4231b72fab 100644
--- a/bench/PathUtilsBench.cpp
+++ b/bench/PathUtilsBench.cpp
@@ -52,9 +52,9 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
- for (int i = 0; i < this->getLoops(); ++i){
+ for (int i = 0; i < loops; ++i){
//create a random 16x16 bitmap
fillRandomBits(H * STRIDE, (char*) &bits);
diff --git a/bench/PerlinNoiseBench.cpp b/bench/PerlinNoiseBench.cpp
index 7cbe5f8c8a..85b536bcfb 100644
--- a/bench/PerlinNoiseBench.cpp
+++ b/bench/PerlinNoiseBench.cpp
@@ -21,9 +21,9 @@ protected:
return "perlinnoise";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- this->test(canvas, 0, 0, SkPerlinNoiseShader::kFractalNoise_Type,
- 0.1f, 0.1f, 3, 0, false);
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ this->test(loops, canvas, 0, 0, SkPerlinNoiseShader::kFractalNoise_Type,
+ 0.1f, 0.1f, 3, 0, false);
}
private:
@@ -38,7 +38,7 @@ private:
canvas->restore();
}
- void test(SkCanvas* canvas, int x, int y, SkPerlinNoiseShader::Type type,
+ void test(const int loops, SkCanvas* canvas, int x, int y, SkPerlinNoiseShader::Type type,
float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed,
bool stitchTiles) {
SkShader* shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ?
@@ -49,7 +49,7 @@ private:
SkPaint paint;
paint.setShader(shader)->unref();
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
this->drawClippedRect(canvas, x, y, paint);
}
}
diff --git a/bench/PicturePlaybackBench.cpp b/bench/PicturePlaybackBench.cpp
index 9d233ec3c0..815ef0b777 100644
--- a/bench/PicturePlaybackBench.cpp
+++ b/bench/PicturePlaybackBench.cpp
@@ -35,7 +35,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPicture picture;
@@ -43,9 +43,9 @@ protected:
recordCanvas(pCanvas);
picture.endRecording();
- const SkPoint translateDelta = getTranslateDelta(this->getLoops());
+ const SkPoint translateDelta = getTranslateDelta(loops);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
picture.draw(canvas);
canvas->translate(translateDelta.fX, translateDelta.fY);
}
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index 66ec19ccbd..4083f81af7 100644
--- a/bench/PictureRecordBench.cpp
+++ b/bench/PictureRecordBench.cpp
@@ -50,13 +50,13 @@ public:
DictionaryRecordBench() : INHERITED("dictionaries") {}
protected:
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkAutoTDelete<SkPicture> picture;
SkCanvas* canvas = NULL;
- const SkPoint translateDelta = getTranslateDelta(this->getLoops());
+ const SkPoint translateDelta = getTranslateDelta(loops);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
if (0 == i % kMaxLoopsPerCanvas) {
picture.reset(SkNEW(SkPicture));
canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
@@ -117,12 +117,12 @@ public:
UniquePaintDictionaryRecordBench() : INHERITED("unique_paint_dictionary") { }
protected:
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkRandom rand;
SkPaint paint;
SkAutoTDelete<SkPicture> picture;
SkCanvas* canvas = NULL;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
if (0 == i % kMaxLoopsPerCanvas) {
picture.reset(SkNEW(SkPicture));
canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
@@ -157,10 +157,10 @@ public:
ObjCount = 100, // number of unique paint objects
};
protected:
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkPicture picture;
SkCanvas* canvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawPaint(fPaint[i % ObjCount]);
}
}
diff --git a/bench/PremulAndUnpremulAlphaOpsBench.cpp b/bench/PremulAndUnpremulAlphaOpsBench.cpp
index aac5934b4c..93c84c9095 100644
--- a/bench/PremulAndUnpremulAlphaOpsBench.cpp
+++ b/bench/PremulAndUnpremulAlphaOpsBench.cpp
@@ -25,7 +25,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
canvas->clear(SK_ColorBLACK);
SkISize size = canvas->getDeviceSize();
@@ -45,7 +45,7 @@ protected:
bmp2.setConfig(SkBitmap::kARGB_8888_Config, size.width(),
size.height());
- for (int loop = 0; loop < this->getLoops(); ++loop) {
+ for (int loop = 0; loop < loops; ++loop) {
// Unpremul -> Premul
canvas->writePixels(bmp1, 0, 0, fUnPremulConfig);
// Premul -> Unpremul
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp
index 6991b3fb87..b51cc4c6a9 100644
--- a/bench/RTreeBench.cpp
+++ b/bench/RTreeBench.cpp
@@ -47,9 +47,9 @@ protected:
virtual const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
for (int j = 0; j < NUM_BUILD_RECTS; ++j) {
fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, NUM_BUILD_RECTS),
fBulkLoad);
@@ -111,9 +111,9 @@ protected:
fTree->flushDeferredInserts();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkTDArray<void*> hits;
SkIRect query;
switch(fQuery) {
diff --git a/bench/ReadPixBench.cpp b/bench/ReadPixBench.cpp
index f62917b6ea..f761e3306c 100644
--- a/bench/ReadPixBench.cpp
+++ b/bench/ReadPixBench.cpp
@@ -24,7 +24,7 @@ protected:
return "readpix";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
canvas->clear(SK_ColorBLACK);
SkISize size = canvas->getDeviceSize();
@@ -45,7 +45,7 @@ protected:
bitmap.setConfig(SkBitmap::kARGB_8888_Config, kWindowSize, kWindowSize);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
for (int x = 0; x < kNumStepsX; ++x) {
for (int y = 0; y < kNumStepsY; ++y) {
canvas->readPixels(&bitmap, x * offX, y * offY);
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 200fb0d330..ee0f76b812 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -62,13 +62,13 @@ protected:
}
virtual const char* onGetName() { return computeName("rects"); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
if (fStroke > 0) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(fStroke));
}
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
paint.setColor(fColors[i % N]);
this->setupPaint(&paint);
this->drawThisRect(canvas, fRects[i % N], paint);
@@ -141,7 +141,7 @@ public:
}
protected:
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkScalar gSizes[] = {
SkIntToScalar(7), 0
};
@@ -155,7 +155,7 @@ protected:
SkPaint paint;
paint.setStrokeCap(SkPaint::kRound_Cap);
- for (int loop = 0; loop < this->getLoops(); loop++) {
+ for (int loop = 0; loop < loops; loop++) {
for (size_t i = 0; i < sizes; i++) {
paint.setStrokeWidth(gSizes[i]);
this->setupPaint(&paint);
@@ -185,7 +185,7 @@ protected:
return "aarects";
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
static const SkScalar kHalfRectSize = 0.75f;
SkPaint paint;
@@ -195,7 +195,7 @@ protected:
SkRect r = { -kHalfRectSize, -kHalfRectSize, kHalfRectSize, kHalfRectSize };
int rot = 0;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
// Draw small aa rects in a grid across the screen
for (SkScalar y = kHalfRectSize+SK_Scalar1; y < H; y += 2*kHalfRectSize+2) {
for (SkScalar x = kHalfRectSize+SK_Scalar1; x < W; x += 2*kHalfRectSize+2) {
@@ -243,7 +243,7 @@ public:
}
protected:
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkScalar gSizes[] = {
SkIntToScalar(13), SkIntToScalar(24)
};
@@ -269,7 +269,7 @@ protected:
SkShader::kClamp_TileMode);
paint.setShader(s)->unref();
}
- for (int loop = 0; loop < this->getLoops(); loop++) {
+ for (int loop = 0; loop < loops; loop++) {
for (size_t i = 0; i < sizes; i++) {
switch (_type) {
case kMaskOpaque:
diff --git a/bench/RectoriBench.cpp b/bench/RectoriBench.cpp
index df695d51dc..e3bf41b78e 100644
--- a/bench/RectoriBench.cpp
+++ b/bench/RectoriBench.cpp
@@ -24,10 +24,10 @@ protected:
return "rectori";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRandom Random;
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkScalar blurSigma = Random.nextRangeScalar(1.5f, 25.0f);
SkScalar size = Random.nextRangeScalar(20*blurSigma, 50*blurSigma);
diff --git a/bench/RefCntBench.cpp b/bench/RefCntBench.cpp
index f6ec7339cb..5147c99e01 100644
--- a/bench/RefCntBench.cpp
+++ b/bench/RefCntBench.cpp
@@ -25,8 +25,8 @@ protected:
return "ref_cnt_stack";
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
SkRefCnt ref;
for (int j = 0; j < M; ++j) {
ref.ref();
@@ -63,9 +63,9 @@ protected:
return "ref_cnt_heap";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
char memory[sizeof(PlacedRefCnt)];
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
PlacedRefCnt* ref = new (memory) PlacedRefCnt();
for (int j = 0; j < M; ++j) {
ref->ref();
@@ -90,8 +90,8 @@ protected:
return "ref_cnt_new";
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
SkRefCnt* ref = new SkRefCnt();
for (int j = 0; j < M; ++j) {
ref->ref();
@@ -118,8 +118,8 @@ protected:
return "ref_cnt_stack_weak";
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
SkWeakRefCnt ref;
for (int j = 0; j < M; ++j) {
ref.ref();
@@ -149,9 +149,9 @@ protected:
return "ref_cnt_heap_weak";
}
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
char memory[sizeof(PlacedWeakRefCnt)];
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
PlacedWeakRefCnt* ref = new (memory) PlacedWeakRefCnt();
for (int j = 0; j < M; ++j) {
ref->ref();
@@ -176,8 +176,8 @@ protected:
return "ref_cnt_new_weak";
}
- virtual void onDraw(SkCanvas*) {
- for (int i = 0; i < this->getLoops(); ++i) {
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
SkWeakRefCnt* ref = new SkWeakRefCnt();
for (int j = 0; j < M; ++j) {
ref->ref();
diff --git a/bench/RegionBench.cpp b/bench/RegionBench.cpp
index fb6e94f67b..ed58e3bdeb 100644
--- a/bench/RegionBench.cpp
+++ b/bench/RegionBench.cpp
@@ -106,9 +106,9 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
Proc proc = fProc;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
proc(fA, fB);
}
}
diff --git a/bench/RegionContainBench.cpp b/bench/RegionContainBench.cpp
index a34706d7ba..35ca46ff0f 100644
--- a/bench/RegionContainBench.cpp
+++ b/bench/RegionContainBench.cpp
@@ -52,10 +52,10 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas*) {
+ virtual void onDraw(const int loops, SkCanvas*) {
Proc proc = fProc;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
proc(fA, fB);
}
}
diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp
index 957ec2a83e..fcbffb2a10 100644
--- a/bench/RepeatTileBench.cpp
+++ b/bench/RepeatTileBench.cpp
@@ -133,11 +133,11 @@ protected:
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint(fPaint);
this->setupPaint(&paint);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawPaint(paint);
}
}
diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp
index a1ea737498..54ee0fcd19 100644
--- a/bench/ScalarBench.cpp
+++ b/bench/ScalarBench.cpp
@@ -31,8 +31,8 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
- for (int i = 0; i < this->getLoops(); i++) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
+ for (int i = 0; i < loops; i++) {
this->performTest();
}
}
@@ -157,9 +157,9 @@ protected:
return "rect_bounds";
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkRect r;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
r.set(fPts, PTS);
}
}
diff --git a/bench/ShaderMaskBench.cpp b/bench/ShaderMaskBench.cpp
index 71ca047018..bf04981bec 100644
--- a/bench/ShaderMaskBench.cpp
+++ b/bench/ShaderMaskBench.cpp
@@ -56,7 +56,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
const SkIPoint dim = this->getSize();
SkRandom rand;
@@ -71,14 +71,14 @@ protected:
const SkScalar y0 = SkIntToScalar(-10);
paint.setTextSize(SkIntToScalar(12));
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
canvas->drawText(fText.c_str(), fText.size(), x, y, paint);
}
paint.setTextSize(SkIntToScalar(48));
- for (int i = 0; i < this->getLoops() / 4 ; i++) {
+ for (int i = 0; i < loops / 4 ; i++) {
SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
canvas->drawText(fText.c_str(), fText.size(), x, y, paint);
diff --git a/bench/SkBenchmark.cpp b/bench/SkBenchmark.cpp
index 26a7a3bb32..39119b98e9 100644
--- a/bench/SkBenchmark.cpp
+++ b/bench/SkBenchmark.cpp
@@ -22,7 +22,6 @@ SkBenchmark::SkBenchmark() {
fForceFilter = false;
fDither = SkTriState::kDefault;
fOrMask = fClearMask = 0;
- fLoops = 1;
}
const char* SkBenchmark::getName() {
@@ -37,8 +36,8 @@ void SkBenchmark::preDraw() {
this->onPreDraw();
}
-void SkBenchmark::draw(SkCanvas* canvas) {
- this->onDraw(canvas);
+void SkBenchmark::draw(const int loops, SkCanvas* canvas) {
+ this->onDraw(loops, canvas);
}
void SkBenchmark::postDraw() {
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 77e2357dd6..bf44d2cc97 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -67,7 +67,8 @@ public:
// before the initial draw.
void preDraw();
- void draw(SkCanvas*);
+ // Bench framework can tune loops to be large enough for stable timing.
+ void draw(const int loops, SkCanvas*);
// Call after draw, allows the benchmark to do cleanup work outside of the
// timer. When a benchmark is repeatedly drawn, this is only called once
@@ -104,15 +105,6 @@ public:
fClearMask = clearMask;
}
- // The bench framework calls this to control the runtime of a bench.
- void setLoops(int loops) {
- fLoops = loops;
- }
-
- // Each bench should do its main work in a loop like this:
- // for (int i = 0; i < this->getLoops(); i++) { <work here> }
- int getLoops() const { return fLoops; }
-
static void SetResourcePath(const char* resPath) { gResourcePath.set(resPath); }
static SkString& GetResourcePath() { return gResourcePath; }
@@ -122,7 +114,9 @@ protected:
virtual const char* onGetName() = 0;
virtual void onPreDraw() {}
- virtual void onDraw(SkCanvas*) = 0;
+ // Each bench should do its main work in a loop like this:
+ // for (int i = 0; i < loops; i++) { <work here> }
+ virtual void onDraw(const int loops, SkCanvas*) = 0;
virtual void onPostDraw() {}
virtual SkIPoint onGetSize();
@@ -133,7 +127,6 @@ private:
bool fForceFilter;
SkTriState::State fDither;
uint32_t fOrMask, fClearMask;
- int fLoops;
static SkString gResourcePath;
typedef SkRefCnt INHERITED;
diff --git a/bench/SkipZeroesBench.cpp b/bench/SkipZeroesBench.cpp
index b0e363051d..3d846bf73d 100644
--- a/bench/SkipZeroesBench.cpp
+++ b/bench/SkipZeroesBench.cpp
@@ -72,7 +72,7 @@ protected:
}
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
if (!fValid) {
#ifdef SK_DEBUG
SkDebugf("stream was invalid: %s\n", fFilename.c_str());
@@ -81,7 +81,7 @@ protected:
}
// Decode a bunch of times
SkBitmap bm;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkDEBUGCODE(bool success =) fDecoder->decode(&fStream, &bm,
SkImageDecoder::kDecodePixels_Mode);
#ifdef SK_DEBUG
diff --git a/bench/SortBench.cpp b/bench/SortBench.cpp
index 161e979776..1f888f2462 100644
--- a/bench/SortBench.cpp
+++ b/bench/SortBench.cpp
@@ -122,9 +122,9 @@ protected:
gRec[fType].fProc(fUnsorted.get());
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkAutoTMalloc<int> sorted(N);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
memcpy(sorted.get(), fUnsorted.get(), N*sizeof(int));
fSortProc(sorted.get());
#ifdef SK_DEBUG
diff --git a/bench/StrokeBench.cpp b/bench/StrokeBench.cpp
index 769c09ad72..975c01f7b6 100644
--- a/bench/StrokeBench.cpp
+++ b/bench/StrokeBench.cpp
@@ -78,13 +78,13 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
fRec.fCanvas = canvas;
this->setupPaint(&fRec.fPaint);
fRec.fPaint.setStyle(SkPaint::kStroke_Style);
fRec.fPaint.setStrokeJoin(fJoin);
fRec.fPaint.setStrokeWidth(5);
- fProc(&fRec, this->getLoops());
+ fProc(&fRec, loops);
}
private:
diff --git a/bench/TableBench.cpp b/bench/TableBench.cpp
index 0646d26be5..ce5c3d293d 100644
--- a/bench/TableBench.cpp
+++ b/bench/TableBench.cpp
@@ -33,14 +33,14 @@ protected:
return "tablebench";
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint cellPaint;
cellPaint.setColor(0xFFFFFFF);
SkPaint borderPaint;
borderPaint.setColor(0xFFCCCCCC);
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
for (int row = 0; row < kNumRows; ++row) {
for (int col = 0; col < kNumCols; ++col) {
SkRect cell = SkRect::MakeLTRB(col * kCellWidth,
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index cc665b785e..d32d0fd105 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -91,7 +91,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
const SkIPoint dim = this->getSize();
SkRandom rand;
@@ -111,7 +111,7 @@ protected:
canvas->translate(SK_Scalar1, SK_Scalar1);
}
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
if (fDoPos) {
canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint);
} else {
diff --git a/bench/TileBench.cpp b/bench/TileBench.cpp
index 4619d8b1ef..9a9e27e951 100644
--- a/bench/TileBench.cpp
+++ b/bench/TileBench.cpp
@@ -82,7 +82,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint(fPaint);
this->setupPaint(&paint);
paint.setFilterLevel(fDoFilter ? SkPaint::kLow_FilterLevel
@@ -103,7 +103,7 @@ protected:
SkPaint bgPaint;
bgPaint.setColor(SK_ColorWHITE);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
if (fDoTrans) {
canvas->drawRect(r, bgPaint);
}
diff --git a/bench/VertBench.cpp b/bench/VertBench.cpp
index 39602b07aa..3f07528142 100644
--- a/bench/VertBench.cpp
+++ b/bench/VertBench.cpp
@@ -77,11 +77,11 @@ public:
protected:
virtual const char* onGetName() { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
canvas->drawVertices(SkCanvas::kTriangles_VertexMode, PTS,
fPts, NULL, fColors, NULL, fIdx, IDX, paint);
}
diff --git a/bench/WritePixelsBench.cpp b/bench/WritePixelsBench.cpp
index 949b5bc4c2..0313846a3b 100644
--- a/bench/WritePixelsBench.cpp
+++ b/bench/WritePixelsBench.cpp
@@ -46,7 +46,7 @@ protected:
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkISize size = canvas->getDeviceSize();
canvas->clear(0xFFFF0000);
@@ -55,7 +55,7 @@ protected:
bmp.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
canvas->readPixels(&bmp, 0, 0);
- for (int loop = 0; loop < this->getLoops(); ++loop) {
+ for (int loop = 0; loop < loops; ++loop) {
canvas->writePixels(bmp, 0, 0, fConfig);
}
}
diff --git a/bench/WriterBench.cpp b/bench/WriterBench.cpp
index f9a0ac89b4..46b26b1efa 100644
--- a/bench/WriterBench.cpp
+++ b/bench/WriterBench.cpp
@@ -21,11 +21,11 @@ protected:
return "writer";
}
- virtual void onDraw(SkCanvas*) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
static const size_t gLen = strlen(gStr);
SkWriter32 writer(256 * 4);
- for (int i = 0; i < this->getLoops(); i++) {
+ for (int i = 0; i < loops; i++) {
for (size_t j = 0; j <= gLen; j++) {
writer.writeString(gStr, j);
}
diff --git a/bench/XfermodeBench.cpp b/bench/XfermodeBench.cpp
index 41b00e6c70..1910b75b21 100644
--- a/bench/XfermodeBench.cpp
+++ b/bench/XfermodeBench.cpp
@@ -31,10 +31,10 @@ public:
protected:
virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkISize size = canvas->getDeviceSize();
SkRandom random;
- for (int i = 0; i < this->getLoops(); ++i) {
+ for (int i = 0; i < loops; ++i) {
SkPaint paint;
paint.setXfermode(fXfermode.get());
paint.setColor(random.nextU());
@@ -70,8 +70,8 @@ public:
protected:
virtual const char* onGetName() SK_OVERRIDE { return "xfermode_create"; }
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- for (int outer = 0; outer < this->getLoops() * 10; ++outer) {
+ virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ for (int outer = 0; outer < loops * 10; ++outer) {
for (int i = 0; i <= SkXfermode::kLastMode; ++i) {
SkXfermode* xfer = SkXfermode::Create(SkXfermode::Mode(i));
SkSafeUnref(xfer);
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 59c48dbb86..092a577c61 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -520,7 +520,7 @@ int tool_main(int argc, char** argv) {
canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.fY, kRecordFlags)));
break;
case kPictureRecord_BenchMode:
- bench->draw(recordFrom.beginRecording(dim.fX, dim.fY, kRecordFlags));
+ bench->draw(1, recordFrom.beginRecording(dim.fX, dim.fY, kRecordFlags));
recordFrom.endRecording();
canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.fY, kRecordFlags)));
break;
@@ -592,18 +592,19 @@ int tool_main(int argc, char** argv) {
// Save and restore around each call to draw() to guarantee a pristine canvas.
SkAutoCanvasRestore saveRestore(canvas, true/*also save*/);
+ int loops;
if (frameIntervalComputed && loopCount > loopsPerFrame) {
- bench->setLoops(loopsPerFrame);
+ loops = loopsPerFrame;
loopCount -= loopsPerFrame;
} else {
- bench->setLoops(loopCount);
+ loops = loopCount;
loopCount = 0;
}
if (benchMode == kPictureRecord_BenchMode) {
recordFrom.draw(canvas);
} else {
- bench->draw(canvas);
+ bench->draw(loops, canvas);
}
if (kDeferredSilent_BenchMode == benchMode) {