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 "SkBenchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
11 #include "SkString.h" | 11 #include "SkString.h" |
12 #include "SkBicubicImageFilter.h" | 12 #include "SkBicubicImageFilter.h" |
13 | 13 |
14 // This bench exercises SkBicubicImageFilter, upsampling a 40x40 input to | 14 // This bench exercises SkBicubicImageFilter, upsampling a 40x40 input to |
15 // 100x100, 400x100, 100x400, and 400x400. | 15 // 100x100, 400x100, 100x400, and 400x400. |
16 | 16 |
17 class BicubicBench : public SkBenchmark { | 17 class BicubicBench : public SkBenchmark { |
18 SkSize fScale; | 18 SkSize fScale; |
19 SkString fName; | 19 SkString fName; |
20 | 20 |
21 public: | 21 public: |
22 BicubicBench(void* param, float x, float y) | 22 BicubicBench(float x, float y) |
23 : INHERITED(param), fScale(SkSize::Make(SkFloatToScalar(x), SkFloatToSc alar(y))) { | 23 : fScale(SkSize::Make(SkFloatToScalar(x) |
24 , SkFloatToScalar(y))) { | |
scroggo
2013/09/10 21:31:15
This is formatted as if SkFloatToScalar(y) is a pa
mtklein
2013/09/11 13:33:01
Ooh, thanks. Overzealous reformatting! Fixed.
| |
24 fName.printf("bicubic_%gx%g", | 25 fName.printf("bicubic_%gx%g", |
25 SkScalarToFloat(fScale.fWidth), SkScalarToFloat(fScale.fHeight)); | 26 SkScalarToFloat(fScale.fWidth), SkScalarToFloat(fScale.fHeight)); |
26 } | 27 } |
27 | 28 |
28 protected: | 29 protected: |
29 virtual const char* onGetName() { | 30 virtual const char* onGetName() { |
30 return fName.c_str(); | 31 return fName.c_str(); |
31 } | 32 } |
32 | 33 |
33 virtual void onDraw(SkCanvas* canvas) { | 34 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 11 matching lines...) Expand all Loading... | |
45 canvas->clipRect(r); | 46 canvas->clipRect(r); |
46 canvas->drawOval(r, paint); | 47 canvas->drawOval(r, paint); |
47 canvas->restore(); | 48 canvas->restore(); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 private: | 52 private: |
52 typedef SkBenchmark INHERITED; | 53 typedef SkBenchmark INHERITED; |
53 }; | 54 }; |
54 | 55 |
55 static SkBenchmark* Fact00(void* p) { return new BicubicBench(p, 10.0f, 10.0f); } | 56 DEF_BENCH( return new BicubicBench(10.0f, 10.0f); ) |
56 static SkBenchmark* Fact01(void* p) { return new BicubicBench(p, 2.5f, 10.0f); } | 57 DEF_BENCH( return new BicubicBench(2.5f, 10.0f); ) |
57 static SkBenchmark* Fact02(void* p) { return new BicubicBench(p, 10.0f, 2.5f); } | 58 DEF_BENCH( return new BicubicBench(10.0f, 2.5f); ) |
58 static SkBenchmark* Fact03(void* p) { return new BicubicBench(p, 2.5f, 2.5f); } | 59 DEF_BENCH( return new BicubicBench(2.5f, 2.5f); ) |
59 | |
60 static BenchRegistry gReg00(Fact00); | |
61 static BenchRegistry gReg01(Fact01); | |
62 static BenchRegistry gReg02(Fact02); | |
63 static BenchRegistry gReg03(Fact03); | |
OLD | NEW |