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 | 7 |
8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 SkRandom rand; | 59 SkRandom rand; |
60 for (int i = 0; i < loops; i++) { | 60 for (int i = 0; i < loops; i++) { |
61 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400, | 61 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400, |
62 rand.nextUScalar1() * 400); | 62 rand.nextUScalar1() * 400); |
63 r.offset(fRadius, fRadius); | 63 r.offset(fRadius, fRadius); |
64 | 64 |
65 if (fRadius > 0) { | 65 if (fRadius > 0) { |
66 SkMorphologyImageFilter* mf = NULL; | 66 SkMorphologyImageFilter* mf = NULL; |
67 switch (fStyle) { | 67 switch (fStyle) { |
68 case kDilate_MT: | 68 case kDilate_MT: |
69 mf = new SkDilateImageFilter(SkScalarFloorToInt(fRadius), | 69 mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius)
, |
70 SkScalarFloorToInt(fRadius)); | 70 SkScalarFloorToInt(fRadius))
; |
71 break; | 71 break; |
72 case kErode_MT: | 72 case kErode_MT: |
73 mf = new SkErodeImageFilter(SkScalarFloorToInt(fRadius), | 73 mf = SkErodeImageFilter::Create(SkScalarFloorToInt(fRadius), |
74 SkScalarFloorToInt(fRadius)); | 74 SkScalarFloorToInt(fRadius))
; |
75 break; | 75 break; |
76 } | 76 } |
77 paint.setImageFilter(mf)->unref(); | 77 paint.setImageFilter(mf)->unref(); |
78 } | 78 } |
79 canvas->drawOval(r, paint); | 79 canvas->drawOval(r, paint); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 typedef SkBenchmark INHERITED; | 84 typedef SkBenchmark INHERITED; |
85 }; | 85 }; |
86 | 86 |
87 DEF_BENCH( return new MorphologyBench(SMALL, kErode_MT); ) | 87 DEF_BENCH( return new MorphologyBench(SMALL, kErode_MT); ) |
88 DEF_BENCH( return new MorphologyBench(SMALL, kDilate_MT); ) | 88 DEF_BENCH( return new MorphologyBench(SMALL, kDilate_MT); ) |
89 | 89 |
90 DEF_BENCH( return new MorphologyBench(BIG, kErode_MT); ) | 90 DEF_BENCH( return new MorphologyBench(BIG, kErode_MT); ) |
91 DEF_BENCH( return new MorphologyBench(BIG, kDilate_MT); ) | 91 DEF_BENCH( return new MorphologyBench(BIG, kDilate_MT); ) |
92 | 92 |
93 DEF_BENCH( return new MorphologyBench(REAL, kErode_MT); ) | 93 DEF_BENCH( return new MorphologyBench(REAL, kErode_MT); ) |
94 DEF_BENCH( return new MorphologyBench(REAL, kDilate_MT); ) | 94 DEF_BENCH( return new MorphologyBench(REAL, kDilate_MT); ) |
95 | 95 |
96 DEF_BENCH( return new MorphologyBench(0, kErode_MT); ) | 96 DEF_BENCH( return new MorphologyBench(0, kErode_MT); ) |
OLD | NEW |