OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 protected: | 33 protected: |
34 virtual const char* onGetName() { | 34 virtual const char* onGetName() { |
35 return fName.c_str(); | 35 return fName.c_str(); |
36 } | 36 } |
37 | 37 |
38 virtual void onDraw(SkCanvas* canvas) { | 38 virtual void onDraw(SkCanvas* canvas) { |
39 SkPaint paint; | 39 SkPaint paint; |
40 this->setupPaint(&paint); | 40 this->setupPaint(&paint); |
41 paint.setAntiAlias(true); | 41 paint.setAntiAlias(true); |
42 SkMWCRandom rand; | 42 SkRandom rand; |
43 for (int i = 0; i < SkBENCHLOOP(3); i++) { | 43 for (int i = 0; i < SkBENCHLOOP(3); i++) { |
44 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400, | 44 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400, |
45 rand.nextUScalar1() * 400); | 45 rand.nextUScalar1() * 400); |
46 paint.setImageFilter(fFilter); | 46 paint.setImageFilter(fFilter); |
47 canvas->drawOval(r, paint); | 47 canvas->drawOval(r, paint); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 typedef SkBenchmark INHERITED; | 52 typedef SkBenchmark INHERITED; |
53 SkMatrixConvolutionImageFilter* fFilter; | 53 SkMatrixConvolutionImageFilter* fFilter; |
54 SkString fName; | 54 SkString fName; |
55 }; | 55 }; |
56 | 56 |
57 static SkBenchmark* Fact00(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClamp_TileMode, true); } | 57 static SkBenchmark* Fact00(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClamp_TileMode, true); } |
58 static SkBenchmark* Fact01(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kRepeat_TileMode, true); } | 58 static SkBenchmark* Fact01(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kRepeat_TileMode, true); } |
59 static SkBenchmark* Fact02(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClampToBlack_TileMode, true); } | 59 static SkBenchmark* Fact02(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClampToBlack_TileMode, true); } |
60 static SkBenchmark* Fact03(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClampToBlack_TileMode, false); } | 60 static SkBenchmark* Fact03(void* p) { return new MatrixConvolutionBench(p, SkMat
rixConvolutionImageFilter::kClampToBlack_TileMode, false); } |
61 | 61 |
62 static BenchRegistry gReg00(Fact00); | 62 static BenchRegistry gReg00(Fact00); |
63 static BenchRegistry gReg01(Fact01); | 63 static BenchRegistry gReg01(Fact01); |
64 static BenchRegistry gReg02(Fact02); | 64 static BenchRegistry gReg02(Fact02); |
65 static BenchRegistry gReg03(Fact03); | 65 static BenchRegistry gReg03(Fact03); |
OLD | NEW |