OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 textencoding? | 38 textencoding? |
39 text -vs- postext - pathtext | 39 text -vs- postext - pathtext |
40 */ | 40 */ |
41 class TextBench : public SkBenchmark { | 41 class TextBench : public SkBenchmark { |
42 SkPaint fPaint; | 42 SkPaint fPaint; |
43 SkString fText; | 43 SkString fText; |
44 SkString fName; | 44 SkString fName; |
45 FontQuality fFQ; | 45 FontQuality fFQ; |
46 bool fDoPos; | 46 bool fDoPos; |
47 SkPoint* fPos; | 47 SkPoint* fPos; |
48 enum { N = SkBENCHLOOP(800) }; | |
49 public: | 48 public: |
50 TextBench(void* param, const char text[], int ps, | 49 TextBench(void* param, const char text[], int ps, |
51 SkColor color, FontQuality fq, bool doPos = false) : INHERITED(par
am) { | 50 SkColor color, FontQuality fq, bool doPos = false) : INHERITED(par
am) { |
52 fPos = NULL; | 51 fPos = NULL; |
53 fFQ = fq; | 52 fFQ = fq; |
54 fDoPos = doPos; | 53 fDoPos = doPos; |
55 fText.set(text); | 54 fText.set(text); |
56 | 55 |
57 fPaint.setAntiAlias(kBW != fq); | 56 fPaint.setAntiAlias(kBW != fq); |
58 fPaint.setLCDRenderText(kLCD == fq); | 57 fPaint.setLCDRenderText(kLCD == fq); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 104 |
106 const SkScalar x0 = SkIntToScalar(-10); | 105 const SkScalar x0 = SkIntToScalar(-10); |
107 const SkScalar y0 = SkIntToScalar(-10); | 106 const SkScalar y0 = SkIntToScalar(-10); |
108 | 107 |
109 if (fDoPos) { | 108 if (fDoPos) { |
110 // realistically, the matrix is often at least translated, so we | 109 // realistically, the matrix is often at least translated, so we |
111 // do that since it exercises different code in drawPosText. | 110 // do that since it exercises different code in drawPosText. |
112 canvas->translate(SK_Scalar1, SK_Scalar1); | 111 canvas->translate(SK_Scalar1, SK_Scalar1); |
113 } | 112 } |
114 | 113 |
115 for (int i = 0; i < N; i++) { | 114 for (int i = 0; i < this->getLoops(); i++) { |
116 if (fDoPos) { | 115 if (fDoPos) { |
117 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint); | 116 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint); |
118 } else { | 117 } else { |
119 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; | 118 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; |
120 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; | 119 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; |
121 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); | 120 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); |
122 } | 121 } |
123 } | 122 } |
124 } | 123 } |
125 | 124 |
(...skipping 25 matching lines...) Expand all Loading... |
151 | 150 |
152 static BenchRegistry gReg11(Fact11); | 151 static BenchRegistry gReg11(Fact11); |
153 static BenchRegistry gReg12(Fact12); | 152 static BenchRegistry gReg12(Fact12); |
154 static BenchRegistry gReg13(Fact13); | 153 static BenchRegistry gReg13(Fact13); |
155 | 154 |
156 static BenchRegistry gReg21(Fact21); | 155 static BenchRegistry gReg21(Fact21); |
157 static BenchRegistry gReg22(Fact22); | 156 static BenchRegistry gReg22(Fact22); |
158 static BenchRegistry gReg23(Fact23); | 157 static BenchRegistry gReg23(Fact23); |
159 | 158 |
160 static BenchRegistry gReg111(Fact111); | 159 static BenchRegistry gReg111(Fact111); |
OLD | NEW |