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 "SkBlurMask.h" |
9 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 11 #include "SkPaint.h" |
11 #include "SkRandom.h" | 12 #include "SkRandom.h" |
12 #include "SkShader.h" | 13 #include "SkShader.h" |
13 #include "SkString.h" | 14 #include "SkString.h" |
14 #include "SkBlurMask.h" | |
15 | 15 |
16 class BitmapScaleBench: public SkBenchmark { | 16 class BitmapScaleBench: public Benchmark { |
17 int fLoopCount; | 17 int fLoopCount; |
18 int fInputSize; | 18 int fInputSize; |
19 int fOutputSize; | 19 int fOutputSize; |
20 SkString fName; | 20 SkString fName; |
21 | 21 |
22 public: | 22 public: |
23 BitmapScaleBench( int is, int os) { | 23 BitmapScaleBench( int is, int os) { |
24 fInputSize = is; | 24 fInputSize = is; |
25 fOutputSize = os; | 25 fOutputSize = os; |
26 | 26 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 preBenchSetup(); | 72 preBenchSetup(); |
73 | 73 |
74 for (int i = 0; i < loops; i++) { | 74 for (int i = 0; i < loops; i++) { |
75 doScaleImage(); | 75 doScaleImage(); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 virtual void doScaleImage() = 0; | 79 virtual void doScaleImage() = 0; |
80 virtual void preBenchSetup() {} | 80 virtual void preBenchSetup() {} |
81 private: | 81 private: |
82 typedef SkBenchmark INHERITED; | 82 typedef Benchmark INHERITED; |
83 }; | 83 }; |
84 | 84 |
85 class BitmapFilterScaleBench: public BitmapScaleBench { | 85 class BitmapFilterScaleBench: public BitmapScaleBench { |
86 public: | 86 public: |
87 BitmapFilterScaleBench( int is, int os) : INHERITED(is, os) { | 87 BitmapFilterScaleBench( int is, int os) : INHERITED(is, os) { |
88 setName( "filter" ); | 88 setName( "filter" ); |
89 } | 89 } |
90 protected: | 90 protected: |
91 virtual void doScaleImage() SK_OVERRIDE { | 91 virtual void doScaleImage() SK_OVERRIDE { |
92 SkCanvas canvas( fOutputBitmap ); | 92 SkCanvas canvas( fOutputBitmap ); |
93 SkPaint paint; | 93 SkPaint paint; |
94 | 94 |
95 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); | 95 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); |
96 fInputBitmap.notifyPixelsChanged(); | 96 fInputBitmap.notifyPixelsChanged(); |
97 canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint ); | 97 canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint ); |
98 } | 98 } |
99 private: | 99 private: |
100 typedef BitmapScaleBench INHERITED; | 100 typedef BitmapScaleBench INHERITED; |
101 }; | 101 }; |
102 | 102 |
103 DEF_BENCH(return new BitmapFilterScaleBench(10, 90);) | 103 DEF_BENCH(return new BitmapFilterScaleBench(10, 90);) |
104 DEF_BENCH(return new BitmapFilterScaleBench(30, 90);) | 104 DEF_BENCH(return new BitmapFilterScaleBench(30, 90);) |
105 DEF_BENCH(return new BitmapFilterScaleBench(80, 90);) | 105 DEF_BENCH(return new BitmapFilterScaleBench(80, 90);) |
106 DEF_BENCH(return new BitmapFilterScaleBench(90, 90);) | 106 DEF_BENCH(return new BitmapFilterScaleBench(90, 90);) |
107 DEF_BENCH(return new BitmapFilterScaleBench(90, 80);) | 107 DEF_BENCH(return new BitmapFilterScaleBench(90, 80);) |
108 DEF_BENCH(return new BitmapFilterScaleBench(90, 30);) | 108 DEF_BENCH(return new BitmapFilterScaleBench(90, 30);) |
109 DEF_BENCH(return new BitmapFilterScaleBench(90, 10);) | 109 DEF_BENCH(return new BitmapFilterScaleBench(90, 10);) |
110 DEF_BENCH(return new BitmapFilterScaleBench(256, 64);) | 110 DEF_BENCH(return new BitmapFilterScaleBench(256, 64);) |
111 DEF_BENCH(return new BitmapFilterScaleBench(64, 256);) | 111 DEF_BENCH(return new BitmapFilterScaleBench(64, 256);) |
OLD | NEW |