OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class BlurImageFilterBench : public Benchmark { | 25 class BlurImageFilterBench : public Benchmark { |
26 public: | 26 public: |
27 BlurImageFilterBench(SkScalar sigmaX, SkScalar sigmaY, bool small) : | 27 BlurImageFilterBench(SkScalar sigmaX, SkScalar sigmaY, bool small) : |
28 fIsSmall(small), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) { | 28 fIsSmall(small), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) { |
29 fName.printf("blur_image_filter_%s_%.2f_%.2f", fIsSmall ? "small" : "lar
ge", | 29 fName.printf("blur_image_filter_%s_%.2f_%.2f", fIsSmall ? "small" : "lar
ge", |
30 SkScalarToFloat(sigmaX), SkScalarToFloat(sigmaY)); | 30 SkScalarToFloat(sigmaX), SkScalarToFloat(sigmaY)); |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 virtual const char* onGetName() SK_OVERRIDE { | 34 const char* onGetName() SK_OVERRIDE { |
35 return fName.c_str(); | 35 return fName.c_str(); |
36 } | 36 } |
37 | 37 |
38 virtual void onPreDraw() SK_OVERRIDE { | 38 void onPreDraw() SK_OVERRIDE { |
39 if (!fInitialized) { | 39 if (!fInitialized) { |
40 make_checkerboard(); | 40 make_checkerboard(); |
41 fInitialized = true; | 41 fInitialized = true; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 45 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
46 SkPaint paint; | 46 SkPaint paint; |
47 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); | 47 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); |
48 | 48 |
49 for (int i = 0; i < loops; i++) { | 49 for (int i = 0; i < loops; i++) { |
50 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); | 50 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 void make_checkerboard() { | 55 void make_checkerboard() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_LARGE, false);) | 88 DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_LARGE, false);) |
89 DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_SMALL, false);) | 89 DEF_BENCH(return new BlurImageFilterBench(0, BLUR_SIGMA_SMALL, false);) |
90 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, true
);) | 90 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, true
);) |
91 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, fals
e);) | 91 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_MINI, BLUR_SIGMA_MINI, fals
e);) |
92 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, tr
ue);) | 92 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, tr
ue);) |
93 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, fa
lse);) | 93 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, fa
lse);) |
94 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, tr
ue);) | 94 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, tr
ue);) |
95 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, fa
lse);) | 95 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, fa
lse);) |
96 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true
);) | 96 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true
);) |
97 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, fals
e);) | 97 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, fals
e);) |
OLD | NEW |