| 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 "Benchmark.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
| 15 | 15 |
| 16 enum FontQuality { | 16 enum FontQuality { |
| 17 kBW, | 17 kBW, |
| 18 kAA, | 18 kAA, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 /* Some considerations for performance: | 32 /* Some considerations for performance: |
| 33 short -vs- long strings (measuring overhead) | 33 short -vs- long strings (measuring overhead) |
| 34 tiny -vs- large pointsize (measure blit -vs- overhead) | 34 tiny -vs- large pointsize (measure blit -vs- overhead) |
| 35 1 -vs- many point sizes (measure cache lookup) | 35 1 -vs- many point sizes (measure cache lookup) |
| 36 normal -vs- subpixel -vs- lineartext (minor) | 36 normal -vs- subpixel -vs- lineartext (minor) |
| 37 force purge after each draw to measure scaler | 37 force purge after each draw to measure scaler |
| 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 Benchmark { |
| 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 public: | 48 public: |
| 49 TextBench(const char text[], int ps, | 49 TextBench(const char text[], int ps, |
| 50 SkColor color, FontQuality fq, bool doPos = false) { | 50 SkColor color, FontQuality fq, bool doPos = false) { |
| 51 fPos = NULL; | 51 fPos = NULL; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint); | 116 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint); |
| 117 } else { | 117 } else { |
| 118 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; | 118 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; |
| 119 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; | 119 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; |
| 120 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); | 120 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 typedef SkBenchmark INHERITED; | 126 typedef Benchmark INHERITED; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 /////////////////////////////////////////////////////////////////////////////// | 129 /////////////////////////////////////////////////////////////////////////////// |
| 130 | 130 |
| 131 #define STR "Hamburgefons" | 131 #define STR "Hamburgefons" |
| 132 | 132 |
| 133 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW); ) | 133 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW); ) |
| 134 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kBW); ) | 134 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kBW); ) |
| 135 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kBW); ) | 135 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kBW); ) |
| 136 | 136 |
| 137 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA); ) | 137 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA); ) |
| 138 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kAA); ) | 138 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kAA); ) |
| 139 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kAA); ) | 139 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kAA); ) |
| 140 | 140 |
| 141 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kLCD); ) | 141 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kLCD); ) |
| 142 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); ) | 142 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); ) |
| 143 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); ) | 143 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); ) |
| 144 | 144 |
| 145 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, true); ) | 145 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, true); ) |
| OLD | NEW |