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 "SkBitmapSource.h" | 8 #include "SkBitmapSource.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkLightingImageFilter.h" | 11 #include "SkLightingImageFilter.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 LightingBaseBench : public SkBenchmark { | 18 class LightingBaseBench : public Benchmark { |
19 public: | 19 public: |
20 LightingBaseBench(bool small) : fIsSmall(small) { } | 20 LightingBaseBench(bool small) : fIsSmall(small) { } |
21 | 21 |
22 protected: | 22 protected: |
23 void draw(const int loops, SkCanvas* canvas, SkImageFilter* imageFilter) con
st { | 23 void draw(const int loops, SkCanvas* canvas, SkImageFilter* imageFilter) con
st { |
24 SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
MALL) : | 24 SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
MALL) : |
25 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
ARGE); | 25 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
ARGE); |
26 SkPaint paint; | 26 SkPaint paint; |
27 paint.setImageFilter(imageFilter)->unref(); | 27 paint.setImageFilter(imageFilter)->unref(); |
28 for (int i = 0; i < loops; i++) { | 28 for (int i = 0; i < loops; i++) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static SkScalar surfaceScale = SkIntToScalar(1); | 85 static SkScalar surfaceScale = SkIntToScalar(1); |
86 return surfaceScale; | 86 return surfaceScale; |
87 } | 87 } |
88 | 88 |
89 static SkColor getWhite() { | 89 static SkColor getWhite() { |
90 static SkColor white(0xFFFFFFFF); | 90 static SkColor white(0xFFFFFFFF); |
91 return white; | 91 return white; |
92 } | 92 } |
93 | 93 |
94 bool fIsSmall; | 94 bool fIsSmall; |
95 typedef SkBenchmark INHERITED; | 95 typedef Benchmark INHERITED; |
96 }; | 96 }; |
97 | 97 |
98 class LightingPointLitDiffuseBench : public LightingBaseBench { | 98 class LightingPointLitDiffuseBench : public LightingBaseBench { |
99 public: | 99 public: |
100 LightingPointLitDiffuseBench(bool small) : INHERITED(small) { | 100 LightingPointLitDiffuseBench(bool small) : INHERITED(small) { |
101 } | 101 } |
102 | 102 |
103 protected: | 103 protected: |
104 virtual const char* onGetName() SK_OVERRIDE { | 104 virtual const char* onGetName() SK_OVERRIDE { |
105 return fIsSmall ? "lightingpointlitdiffuse_small" : "lightingpointlitdif
fuse_large"; | 105 return fIsSmall ? "lightingpointlitdiffuse_small" : "lightingpointlitdif
fuse_large"; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 DEF_BENCH( return new LightingDistantLitDiffuseBench(true); ) | 237 DEF_BENCH( return new LightingDistantLitDiffuseBench(true); ) |
238 DEF_BENCH( return new LightingDistantLitDiffuseBench(false); ) | 238 DEF_BENCH( return new LightingDistantLitDiffuseBench(false); ) |
239 DEF_BENCH( return new LightingSpotLitDiffuseBench(true); ) | 239 DEF_BENCH( return new LightingSpotLitDiffuseBench(true); ) |
240 DEF_BENCH( return new LightingSpotLitDiffuseBench(false); ) | 240 DEF_BENCH( return new LightingSpotLitDiffuseBench(false); ) |
241 DEF_BENCH( return new LightingPointLitSpecularBench(true); ) | 241 DEF_BENCH( return new LightingPointLitSpecularBench(true); ) |
242 DEF_BENCH( return new LightingPointLitSpecularBench(false); ) | 242 DEF_BENCH( return new LightingPointLitSpecularBench(false); ) |
243 DEF_BENCH( return new LightingDistantLitSpecularBench(true); ) | 243 DEF_BENCH( return new LightingDistantLitSpecularBench(true); ) |
244 DEF_BENCH( return new LightingDistantLitSpecularBench(false); ) | 244 DEF_BENCH( return new LightingDistantLitSpecularBench(false); ) |
245 DEF_BENCH( return new LightingSpotLitSpecularBench(true); ) | 245 DEF_BENCH( return new LightingSpotLitSpecularBench(true); ) |
246 DEF_BENCH( return new LightingSpotLitSpecularBench(false); ) | 246 DEF_BENCH( return new LightingSpotLitSpecularBench(false); ) |
OLD | NEW |