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

Side by Side Diff: bench/CmapBench.cpp

Issue 18040004: impl charsToGlyphs for freetype (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ports/SkFontHost_FreeType.cpp » ('j') | src/ports/SkFontHost_FreeType.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 SkTypeface::Encoding encoding = paint2Encoding(paint); 46 SkTypeface::Encoding encoding = paint2Encoding(paint);
47 uint16_t glyphs[NGLYPHS]; 47 uint16_t glyphs[NGLYPHS];
48 SkASSERT(glyphCount <= NGLYPHS); 48 SkASSERT(glyphCount <= NGLYPHS);
49 49
50 SkTypeface* face = paint.getTypeface(); 50 SkTypeface* face = paint.getTypeface();
51 for (int i = 0; i < LOOP; ++i) { 51 for (int i = 0; i < LOOP; ++i) {
52 face->charsToGlyphs(text, encoding, glyphs, glyphCount); 52 face->charsToGlyphs(text, encoding, glyphs, glyphCount);
53 } 53 }
54 } 54 }
55 55
56 static void charsToGlyphsNull_proc(const SkPaint& paint, const void* text,
57 size_t len, int glyphCount) {
58 SkTypeface::Encoding encoding = paint2Encoding(paint);
59
60 SkTypeface* face = paint.getTypeface();
61 for (int i = 0; i < LOOP; ++i) {
62 face->charsToGlyphs(text, encoding, NULL, glyphCount);
63 }
64 }
65
56 class CMAPBench : public SkBenchmark { 66 class CMAPBench : public SkBenchmark {
57 TypefaceProc fProc; 67 TypefaceProc fProc;
58 SkString fName; 68 SkString fName;
59 char fText[NGLYPHS]; 69 char fText[NGLYPHS];
60 SkPaint fPaint; 70 SkPaint fPaint;
61 71
62 public: 72 public:
63 CMAPBench(void* param, TypefaceProc proc, const char name[]) : SkBenchmark(p aram) { 73 CMAPBench(void* param, TypefaceProc proc, const char name[]) : SkBenchmark(p aram) {
64 fProc = proc; 74 fProc = proc;
65 fName.printf("cmap_%s", name); 75 fName.printf("cmap_%s", name);
66 76
67 for (int i = 0; i < NGLYPHS; ++i) { 77 for (int i = 0; i < NGLYPHS; ++i) {
68 // we're just jamming values into utf8, so we must keep it legal 78 // we're just jamming values into utf8, so we must keep it legal
69 fText[i] = i; 79 fText[i] = 'A' + i;
70 } 80 }
71 fPaint.setTypeface(SkTypeface::RefDefault())->unref(); 81 fPaint.setTypeface(SkTypeface::RefDefault())->unref();
72 } 82 }
73 83
74 protected: 84 protected:
75 virtual const char* onGetName() SK_OVERRIDE { 85 virtual const char* onGetName() SK_OVERRIDE {
76 return fName.c_str(); 86 return fName.c_str();
77 } 87 }
78 88
79 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 89 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
80 fProc(fPaint, fText, sizeof(fText), NGLYPHS); 90 fProc(fPaint, fText, sizeof(fText), NGLYPHS);
81 } 91 }
82 92
83 private: 93 private:
84 94
85 typedef SkBenchmark INHERITED; 95 typedef SkBenchmark INHERITED;
86 }; 96 };
87 97
88 ////////////////////////////////////////////////////////////////////////////// 98 //////////////////////////////////////////////////////////////////////////////
89 99
90 DEF_BENCH( return new CMAPBench(p, containsText_proc, "paint_containsText"); ) 100 DEF_BENCH( return new CMAPBench(p, containsText_proc, "paint_containsText"); )
91 DEF_BENCH( return new CMAPBench(p, textToGlyphs_proc, "paint_textToGlyphs"); ) 101 DEF_BENCH( return new CMAPBench(p, textToGlyphs_proc, "paint_textToGlyphs"); )
92 DEF_BENCH( return new CMAPBench(p, charsToGlyphs_proc, "face_charsToGlyphs"); ) 102 DEF_BENCH( return new CMAPBench(p, charsToGlyphs_proc, "face_charsToGlyphs"); )
103 DEF_BENCH( return new CMAPBench(p, charsToGlyphsNull_proc, "face_charsToGlyphs_n ull"); )
93 104
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontHost_FreeType.cpp » ('j') | src/ports/SkFontHost_FreeType.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698