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 "SkBenchmark.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 SkBenchmark { |
19 public: | 19 public: |
20 LightingBaseBench(void* param, bool small) : INHERITED(param), fIsSmall(smal
l) { | 20 LightingBaseBench(void* param, bool small) : INHERITED(param), fIsSmall(smal
l) { |
21 } | 21 } |
22 | 22 |
23 protected: | 23 protected: |
24 void draw(SkCanvas* canvas, SkImageFilter* imageFilter) const { | 24 void draw(SkCanvas* canvas, SkImageFilter* imageFilter) const { |
25 SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
MALL) : | 25 SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
MALL) : |
26 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
ARGE); | 26 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
ARGE); |
27 SkPaint paint; | 27 SkPaint paint; |
28 paint.setImageFilter(imageFilter)->unref(); | 28 paint.setImageFilter(imageFilter)->unref(); |
29 canvas->drawRect(r, paint); | 29 for (int i = 0; i < this->getLoops(); i++) { |
| 30 canvas->drawRect(r, paint); |
| 31 } |
30 } | 32 } |
31 | 33 |
32 static SkPoint3 getPointLocation() { | 34 static SkPoint3 getPointLocation() { |
33 static SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); | 35 static SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); |
34 return pointLocation; | 36 return pointLocation; |
35 } | 37 } |
36 | 38 |
37 static SkPoint3 getDistantDirection() { | 39 static SkPoint3 getDistantDirection() { |
38 static SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); | 40 static SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); |
39 static SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); | 41 static SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 DEF_BENCH( return new LightingDistantLitDiffuseBench(p, true); ) | 219 DEF_BENCH( return new LightingDistantLitDiffuseBench(p, true); ) |
218 DEF_BENCH( return new LightingDistantLitDiffuseBench(p, false); ) | 220 DEF_BENCH( return new LightingDistantLitDiffuseBench(p, false); ) |
219 DEF_BENCH( return new LightingSpotLitDiffuseBench(p, true); ) | 221 DEF_BENCH( return new LightingSpotLitDiffuseBench(p, true); ) |
220 DEF_BENCH( return new LightingSpotLitDiffuseBench(p, false); ) | 222 DEF_BENCH( return new LightingSpotLitDiffuseBench(p, false); ) |
221 DEF_BENCH( return new LightingPointLitSpecularBench(p, true); ) | 223 DEF_BENCH( return new LightingPointLitSpecularBench(p, true); ) |
222 DEF_BENCH( return new LightingPointLitSpecularBench(p, false); ) | 224 DEF_BENCH( return new LightingPointLitSpecularBench(p, false); ) |
223 DEF_BENCH( return new LightingDistantLitSpecularBench(p, true); ) | 225 DEF_BENCH( return new LightingDistantLitSpecularBench(p, true); ) |
224 DEF_BENCH( return new LightingDistantLitSpecularBench(p, false); ) | 226 DEF_BENCH( return new LightingDistantLitSpecularBench(p, false); ) |
225 DEF_BENCH( return new LightingSpotLitSpecularBench(p, true); ) | 227 DEF_BENCH( return new LightingSpotLitSpecularBench(p, true); ) |
226 DEF_BENCH( return new LightingSpotLitSpecularBench(p, false); ) | 228 DEF_BENCH( return new LightingSpotLitSpecularBench(p, false); ) |
OLD | NEW |