diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-03 18:17:16 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-03 18:17:16 +0000 |
commit | 3361471a3504ecd0351ff70f4c42d8d6fee963d4 (patch) | |
tree | 1886e770069303c70c588c396b2d9c19343e3adc /bench/LightingBench.cpp | |
parent | e3bb3bce3e9c1f3bc8ee779b1b3383c18e560bce (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
Diffstat (limited to 'bench/LightingBench.cpp')
-rw-r--r-- | bench/LightingBench.cpp | 63 |
1 files changed, 41 insertions, 22 deletions
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: |