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 "SkBenchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
14 #include "SkShader.h" | 14 #include "SkShader.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 | 16 |
17 #define FILTER_WIDTH_SMALL 32 | 17 #define FILTER_WIDTH_SMALL 32 |
18 #define FILTER_HEIGHT_SMALL 32 | 18 #define FILTER_HEIGHT_SMALL 32 |
19 #define FILTER_WIDTH_LARGE 256 | 19 #define FILTER_WIDTH_LARGE 256 |
20 #define FILTER_HEIGHT_LARGE 256 | 20 #define FILTER_HEIGHT_LARGE 256 |
21 #define BLUR_SIGMA_SMALL 1.0f | 21 #define BLUR_SIGMA_SMALL 1.0f |
22 #define BLUR_SIGMA_LARGE 10.0f | 22 #define BLUR_SIGMA_LARGE 10.0f |
23 #define BLUR_SIGMA_HUGE 80.0f | 23 #define BLUR_SIGMA_HUGE 80.0f |
24 | 24 |
25 class BlurImageFilterBench : public SkBenchmark { | 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 virtual const char* onGetName() SK_OVERRIDE { |
35 return fName.c_str(); | 35 return fName.c_str(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 canvas.restore(); | 73 canvas.restore(); |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 SkString fName; | 78 SkString fName; |
79 bool fIsSmall; | 79 bool fIsSmall; |
80 bool fInitialized; | 80 bool fInitialized; |
81 SkBitmap fCheckerboard; | 81 SkBitmap fCheckerboard; |
82 SkScalar fSigmaX, fSigmaY; | 82 SkScalar fSigmaX, fSigmaY; |
83 typedef SkBenchmark INHERITED; | 83 typedef Benchmark INHERITED; |
84 }; | 84 }; |
85 | 85 |
86 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, 0, false);) | 86 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, 0, false);) |
87 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, 0, false);) | 87 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, 0, false);) |
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_SMALL, BLUR_SIGMA_SMALL, tr
ue);) | 90 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, tr
ue);) |
91 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, fa
lse);) | 91 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, fa
lse);) |
92 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, tr
ue);) | 92 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, tr
ue);) |
93 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, fa
lse);) | 93 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, fa
lse);) |
94 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true
);) | 94 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, true
);) |
95 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, fals
e);) | 95 DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_HUGE, BLUR_SIGMA_HUGE, fals
e);) |
OLD | NEW |