From 2757e3f09d7aae00ebe6c12b55668a89bd71aee1 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Tue, 30 Jun 2015 07:42:42 -0700 Subject: Update blur image filter bench to have crop variation BUG=skia:3944 Review URL: https://codereview.chromium.org/1212973004 --- bench/BlurImageFilterBench.cpp | 59 +++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'bench/BlurImageFilterBench.cpp') 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);) -- cgit v1.2.3