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 #include "SkBenchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkMergeImageFilter.h" | 11 #include "SkMergeImageFilter.h" |
12 | 12 |
13 #define FILTER_WIDTH_SMALL SkIntToScalar(32) | 13 #define FILTER_WIDTH_SMALL SkIntToScalar(32) |
14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) | 14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) |
15 #define FILTER_WIDTH_LARGE SkIntToScalar(256) | 15 #define FILTER_WIDTH_LARGE SkIntToScalar(256) |
16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) | 16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) |
17 | 17 |
18 class MergeBench : public SkBenchmark { | 18 class MergeBench : public Benchmark { |
19 public: | 19 public: |
20 MergeBench(bool small) : fIsSmall(small), fInitialized(false) { } | 20 MergeBench(bool small) : fIsSmall(small), fInitialized(false) { } |
21 | 21 |
22 protected: | 22 protected: |
23 virtual const char* onGetName() SK_OVERRIDE { | 23 virtual const char* onGetName() SK_OVERRIDE { |
24 return fIsSmall ? "merge_small" : "merge_large"; | 24 return fIsSmall ? "merge_small" : "merge_large"; |
25 } | 25 } |
26 | 26 |
27 virtual void onPreDraw() SK_OVERRIDE { | 27 virtual void onPreDraw() SK_OVERRIDE { |
28 if (!fInitialized) { | 28 if (!fInitialized) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); | 81 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); |
82 canvas.restore(); | 82 canvas.restore(); |
83 } | 83 } |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 bool fIsSmall; | 87 bool fIsSmall; |
88 bool fInitialized; | 88 bool fInitialized; |
89 SkBitmap fBitmap, fCheckerboard; | 89 SkBitmap fBitmap, fCheckerboard; |
90 | 90 |
91 typedef SkBenchmark INHERITED; | 91 typedef Benchmark INHERITED; |
92 }; | 92 }; |
93 | 93 |
94 /////////////////////////////////////////////////////////////////////////////// | 94 /////////////////////////////////////////////////////////////////////////////// |
95 | 95 |
96 DEF_BENCH( return new MergeBench(true); ) | 96 DEF_BENCH( return new MergeBench(true); ) |
97 DEF_BENCH( return new MergeBench(false); ) | 97 DEF_BENCH( return new MergeBench(false); ) |
OLD | NEW |