Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: bench/SkGlyphCacheBench.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Android fix + nit fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | bench/TextBlobBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 bool isSuitableFor(Backend backend) override { 49 bool isSuitableFor(Backend backend) override {
50 return backend == kNonRendering_Backend; 50 return backend == kNonRendering_Backend;
51 } 51 }
52 52
53 void onDraw(int loops, SkCanvas*) override { 53 void onDraw(int loops, SkCanvas*) override {
54 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit(); 54 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
55 SkGraphics::SetFontCacheLimit(fCacheSize); 55 SkGraphics::SetFontCacheLimit(fCacheSize);
56 SkPaint paint; 56 SkPaint paint;
57 paint.setAntiAlias(true); 57 paint.setAntiAlias(true);
58 paint.setSubpixelText(true); 58 paint.setSubpixelText(true);
59 paint.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkTyp eface::kItalic)); 59 paint.setTypeface(sk_tool_utils::create_portable_typeface(
60 "serif", SkFontStyle::FromOldStyle(SkTypeface::kIt alic)));
60 61
61 for (int work = 0; work < loops; work++) { 62 for (int work = 0; work < loops; work++) {
62 do_font_stuff(&paint); 63 do_font_stuff(&paint);
63 } 64 }
64 SkGraphics::SetFontCacheLimit(oldCacheLimitSize); 65 SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
65 } 66 }
66 67
67 private: 68 private:
68 typedef Benchmark INHERITED; 69 typedef Benchmark INHERITED;
69 const size_t fCacheSize; 70 const size_t fCacheSize;
(...skipping 11 matching lines...) Expand all
81 } 82 }
82 83
83 bool isSuitableFor(Backend backend) override { 84 bool isSuitableFor(Backend backend) override {
84 return backend == kNonRendering_Backend; 85 return backend == kNonRendering_Backend;
85 } 86 }
86 87
87 void onDraw(int loops, SkCanvas*) override { 88 void onDraw(int loops, SkCanvas*) override {
88 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit(); 89 size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
89 SkGraphics::SetFontCacheLimit(fCacheSize); 90 SkGraphics::SetFontCacheLimit(fCacheSize);
90 sk_sp<SkTypeface> typefaces[] = 91 sk_sp<SkTypeface> typefaces[] =
91 {sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItali c), 92 {sk_tool_utils::create_portable_typeface("serif",
92 sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::k Italic)}; 93 SkFontStyle::FromOldStyle(SkTypeface::kItalic)),
94 sk_tool_utils::create_portable_typeface("sans-serif",
95 SkFontStyle::FromOldStyle(SkTypeface::kItalic))};
93 96
94 for (int work = 0; work < loops; work++) { 97 for (int work = 0; work < loops; work++) {
95 SkTaskGroup().batch(16, [&](int threadIndex) { 98 SkTaskGroup().batch(16, [&](int threadIndex) {
96 SkPaint paint; 99 SkPaint paint;
97 paint.setAntiAlias(true); 100 paint.setAntiAlias(true);
98 paint.setSubpixelText(true); 101 paint.setSubpixelText(true);
99 paint.setTypeface(typefaces[threadIndex % 2]); 102 paint.setTypeface(typefaces[threadIndex % 2]);
100 do_font_stuff(&paint); 103 do_font_stuff(&paint);
101 }); 104 });
102 } 105 }
103 SkGraphics::SetFontCacheLimit(oldCacheLimitSize); 106 SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
104 } 107 }
105 108
106 private: 109 private:
107 typedef Benchmark INHERITED; 110 typedef Benchmark INHERITED;
108 const size_t fCacheSize; 111 const size_t fCacheSize;
109 SkString fName; 112 SkString fName;
110 }; 113 };
111 114
112 DEF_BENCH( return new SkGlyphCacheBasic(256 * 1024); ) 115 DEF_BENCH( return new SkGlyphCacheBasic(256 * 1024); )
113 DEF_BENCH( return new SkGlyphCacheBasic(32 * 1024 * 1024); ) 116 DEF_BENCH( return new SkGlyphCacheBasic(32 * 1024 * 1024); )
114 DEF_BENCH( return new SkGlyphCacheStressTest(256 * 1024); ) 117 DEF_BENCH( return new SkGlyphCacheStressTest(256 * 1024); )
115 DEF_BENCH( return new SkGlyphCacheStressTest(32 * 1024 * 1024); ) 118 DEF_BENCH( return new SkGlyphCacheStressTest(32 * 1024 * 1024); )
OLDNEW
« no previous file with comments | « no previous file | bench/TextBlobBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698