OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorShader.h" | |
11 #include "SkPaint.h" | 10 #include "SkPaint.h" |
12 #include "SkRandom.h" | 11 #include "SkRandom.h" |
13 #include "SkString.h" | 12 #include "SkString.h" |
14 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
15 | 14 |
16 #define STR "Hamburgefons" | 15 #define STR "Hamburgefons" |
17 | 16 |
18 enum FontQuality { | 17 enum FontQuality { |
19 kBW, | 18 kBW, |
20 kAA, | 19 kAA, |
(...skipping 15 matching lines...) Expand all Loading... |
36 SkString fText; | 35 SkString fText; |
37 SkString fName; | 36 SkString fName; |
38 FontQuality fFQ; | 37 FontQuality fFQ; |
39 public: | 38 public: |
40 ShaderMaskBench(bool isOpaque, FontQuality fq) { | 39 ShaderMaskBench(bool isOpaque, FontQuality fq) { |
41 fFQ = fq; | 40 fFQ = fq; |
42 fText.set(STR); | 41 fText.set(STR); |
43 | 42 |
44 fPaint.setAntiAlias(kBW != fq); | 43 fPaint.setAntiAlias(kBW != fq); |
45 fPaint.setLCDRenderText(kLCD == fq); | 44 fPaint.setLCDRenderText(kLCD == fq); |
46 fPaint.setShader(new SkColorShader(isOpaque ? 0xFFFFFFFF : 0x80808080))-
>unref(); | 45 fPaint.setShader(SkShader::MakeColorShader(isOpaque ? 0xFFFFFFFF : 0x808
08080)); |
47 } | 46 } |
48 | 47 |
49 protected: | 48 protected: |
50 virtual const char* onGetName() { | 49 virtual const char* onGetName() { |
51 fName.printf("shadermask"); | 50 fName.printf("shadermask"); |
52 fName.appendf("_%s", fontQualityName(fPaint)); | 51 fName.appendf("_%s", fontQualityName(fPaint)); |
53 fName.appendf("_%02X", fPaint.getAlpha()); | 52 fName.appendf("_%02X", fPaint.getAlpha()); |
54 return fName.c_str(); | 53 return fName.c_str(); |
55 } | 54 } |
56 | 55 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }; | 87 }; |
89 | 88 |
90 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
91 | 90 |
92 DEF_BENCH( return new ShaderMaskBench(true, kBW); ) | 91 DEF_BENCH( return new ShaderMaskBench(true, kBW); ) |
93 DEF_BENCH( return new ShaderMaskBench(false, kBW); ) | 92 DEF_BENCH( return new ShaderMaskBench(false, kBW); ) |
94 DEF_BENCH( return new ShaderMaskBench(true, kAA); ) | 93 DEF_BENCH( return new ShaderMaskBench(true, kAA); ) |
95 DEF_BENCH( return new ShaderMaskBench(false, kAA); ) | 94 DEF_BENCH( return new ShaderMaskBench(false, kAA); ) |
96 DEF_BENCH( return new ShaderMaskBench(true, kLCD); ) | 95 DEF_BENCH( return new ShaderMaskBench(true, kLCD); ) |
97 DEF_BENCH( return new ShaderMaskBench(false, kLCD); ) | 96 DEF_BENCH( return new ShaderMaskBench(false, kLCD); ) |
OLD | NEW |