aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BlurImageFilterBench.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-06-30 07:42:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-30 07:42:42 -0700
commit2757e3f09d7aae00ebe6c12b55668a89bd71aee1 (patch)
treef751ccc2716d0e0e98b565e5ac7972027c0c1ad3 /bench/BlurImageFilterBench.cpp
parent98fc73c7a9fa5f8e4f6fb0a1af0523d4518d6a3a (diff)
Update blur image filter bench to have crop variation
Diffstat (limited to 'bench/BlurImageFilterBench.cpp')
-rw-r--r--bench/BlurImageFilterBench.cpp59
1 files changed, 41 insertions, 18 deletions
diff --git a/bench/BlurImageFilterBench.cpp b/bench/BlurImageFilterBench.cpp
index 476f192ef8..ec8b9ef59d 100644
--- a/bench/BlurImageFilterBench.cpp
+++ b/bench/BlurImageFilterBench.cpp
@@ -24,10 +24,10 @@
class BlurImageFilterBench : public Benchmark {
public:
- BlurImageFilterBench(SkScalar sigmaX, SkScalar sigmaY, bool small) :
- fIsSmall(small), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) {
- fName.printf("blur_image_filter_%s_%.2f_%.2f", fIsSmall ? "small" : "large",
- SkScalarToFloat(sigmaX), SkScalarToFloat(sigmaY));
+ BlurImageFilterBench(SkScalar sigmaX, SkScalar sigmaY, bool small, bool cropped) :
+ fIsSmall(small), fIsCropped(cropped), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) {
+ fName.printf("blur_image_filter_%s%s_%.2f_%.2f", fIsSmall ? "small" : "large",
+ fIsCropped ? "_cropped" : "", SkScalarToFloat(sigmaX), SkScalarToFloat(sigmaY));
}
protected:
@@ -44,10 +44,19 @@ protected:
void onDraw(const int loops, SkCanvas* canvas) override {
SkPaint paint;
- paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
+ static const SkScalar kX = 0;
+ static const SkScalar kY = 0;
+ const SkRect bmpRect = SkRect::MakeXYWH(kX, kY,
+ SkIntToScalar(fCheckerboard.width()),
+ SkIntToScalar(fCheckerboard.height()));
+ const SkImageFilter::CropRect cropRect =
+ SkImageFilter::CropRect(bmpRect.makeInset(10.f, 10.f));
+ const SkImageFilter::CropRect* crop = fIsCropped ? &cropRect : NULL;
+
+ paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY, NULL, crop))->unref();
for (int i = 0; i < loops; i++) {
- canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
+ canvas->drawBitmap(fCheckerboard, kX, kY, &paint);
}
}
@@ -77,21 +86,35 @@ private:
SkString fName;
bool fIsSmall;
+ bool fIsCropped;
bool fInitialized;
SkBitmap fCheckerboard;
SkScalar fSigmaX, fSigmaY;
typedef Benchmark INHERITED;
};
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, 0, false);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, 0, false);)
-DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_LARGE, false);)
-DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_SMALL, false);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, true);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, false);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, true);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, false);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, true);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, false);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true);)
-DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, 0, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, 0, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_LARGE, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_SMALL, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, true, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, true, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, true, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, false, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true, false);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, false, false);)
+
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, 0, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, 0, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_LARGE, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_SMALL, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, true, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, true, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, true, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, false, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true, true);)
+DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, false, true);)