OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 8 |
9 #include "SkGlyphCache.h" | 9 #include "SkGlyphCache.h" |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 void onDraw(int loops, SkCanvas*) override { | 90 void onDraw(int loops, SkCanvas*) override { |
91 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit(); | 91 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit(); |
92 SkGraphics::SetFontCacheLimit(fCacheSize); | 92 SkGraphics::SetFontCacheLimit(fCacheSize); |
93 SkTypeface* typefaces[] = | 93 SkTypeface* typefaces[] = |
94 {sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItali
c), | 94 {sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItali
c), |
95 sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::k
Italic)}; | 95 sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::k
Italic)}; |
96 | 96 |
97 for (int work = 0; work < loops; work++) { | 97 for (int work = 0; work < loops; work++) { |
98 sk_parallel_for(16, [&](int threadIndex) { | 98 SkTaskGroup().batch(16, [&](int threadIndex) { |
99 SkPaint paint; | 99 SkPaint paint; |
100 paint.setAntiAlias(true); | 100 paint.setAntiAlias(true); |
101 paint.setSubpixelText(true); | 101 paint.setSubpixelText(true); |
102 paint.setTypeface(typefaces[threadIndex % 2]); | 102 paint.setTypeface(typefaces[threadIndex % 2]); |
103 do_font_stuff(&paint); | 103 do_font_stuff(&paint); |
104 }); | 104 }); |
105 } | 105 } |
106 SkGraphics::SetFontCacheLimit(oldCacheLimitSize); | 106 SkGraphics::SetFontCacheLimit(oldCacheLimitSize); |
107 SkSafeUnref(typefaces[0]); | 107 SkSafeUnref(typefaces[0]); |
108 SkSafeUnref(typefaces[1]); | 108 SkSafeUnref(typefaces[1]); |
109 } | 109 } |
110 | 110 |
111 private: | 111 private: |
112 typedef Benchmark INHERITED; | 112 typedef Benchmark INHERITED; |
113 const size_t fCacheSize; | 113 const size_t fCacheSize; |
114 SkString fName; | 114 SkString fName; |
115 }; | 115 }; |
116 | 116 |
117 DEF_BENCH( return new SkGlyphCacheBasic(256 * 1024); ) | 117 DEF_BENCH( return new SkGlyphCacheBasic(256 * 1024); ) |
118 DEF_BENCH( return new SkGlyphCacheBasic(32 * 1024 * 1024); ) | 118 DEF_BENCH( return new SkGlyphCacheBasic(32 * 1024 * 1024); ) |
119 DEF_BENCH( return new SkGlyphCacheStressTest(256 * 1024); ) | 119 DEF_BENCH( return new SkGlyphCacheStressTest(256 * 1024); ) |
120 DEF_BENCH( return new SkGlyphCacheStressTest(32 * 1024 * 1024); ) | 120 DEF_BENCH( return new SkGlyphCacheStressTest(32 * 1024 * 1024); ) |
OLD | NEW |