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

Side by Side Diff: src/core/SkTypefaceCache.h

Issue 488143002: Replace SkTypeface::Style with SkFontStyle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add expectations, remove whitespace. Created 6 years, 2 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 | « src/core/SkTypeface.cpp ('k') | src/core/SkTypefaceCache.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 /* 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 8
9 9
10 10
(...skipping 13 matching lines...) Expand all
24 class SkTypefaceCache { 24 class SkTypefaceCache {
25 public: 25 public:
26 SkTypefaceCache(); 26 SkTypefaceCache();
27 ~SkTypefaceCache(); 27 ~SkTypefaceCache();
28 28
29 /** 29 /**
30 * Callback for FindByProc. Returns true if the given typeface is a match 30 * Callback for FindByProc. Returns true if the given typeface is a match
31 * for the given context. The passed typeface is owned by the cache and is 31 * for the given context. The passed typeface is owned by the cache and is
32 * not additionally ref()ed. The typeface may be in the disposed state. 32 * not additionally ref()ed. The typeface may be in the disposed state.
33 */ 33 */
34 typedef bool (*FindProc)(SkTypeface*, SkTypeface::Style, void* context); 34 typedef bool(*FindProc)(SkTypeface*, const SkFontStyle&, void* context);
35 35
36 /** 36 /**
37 * Add a typeface to the cache. This ref()s the typeface, so that the 37 * Add a typeface to the cache. This ref()s the typeface, so that the
38 * cache is also an owner. Later, if we need to purge the cache, typefaces 38 * cache is also an owner. Later, if we need to purge the cache, typefaces
39 * whose refcnt is 1 (meaning only the cache is an owner) will be 39 * whose refcnt is 1 (meaning only the cache is an owner) will be
40 * unref()ed. 40 * unref()ed.
41 */ 41 */
42 void add(SkTypeface*, SkTypeface::Style requested, bool strong = true); 42 void add(SkTypeface*, const SkFontStyle& requested, bool strong = true);
43 43
44 /** 44 /**
45 * Search the cache for a typeface with the specified fontID (uniqueID). 45 * Search the cache for a typeface with the specified fontID (uniqueID).
46 * If one is found, return it (its reference count is unmodified). If none 46 * If one is found, return it (its reference count is unmodified). If none
47 * is found, return NULL. The reference count is unmodified as it is 47 * is found, return NULL. The reference count is unmodified as it is
48 * assumed that the stack will contain a ref to the typeface. 48 * assumed that the stack will contain a ref to the typeface.
49 */ 49 */
50 SkTypeface* findByID(SkFontID findID) const; 50 SkTypeface* findByID(SkFontID findID) const;
51 51
52 /** 52 /**
(...skipping 13 matching lines...) Expand all
66 66
67 /** 67 /**
68 * Helper: returns a unique fontID to pass to the constructor of 68 * Helper: returns a unique fontID to pass to the constructor of
69 * your subclass of SkTypeface 69 * your subclass of SkTypeface
70 */ 70 */
71 static SkFontID NewFontID(); 71 static SkFontID NewFontID();
72 72
73 // These are static wrappers around a global instance of a cache. 73 // These are static wrappers around a global instance of a cache.
74 74
75 static void Add(SkTypeface*, 75 static void Add(SkTypeface*,
76 SkTypeface::Style requested, 76 const SkFontStyle& requested,
77 bool strong = true); 77 bool strong = true);
78 static SkTypeface* FindByID(SkFontID fontID); 78 static SkTypeface* FindByID(SkFontID fontID);
79 static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx); 79 static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx);
80 static void PurgeAll(); 80 static void PurgeAll();
81 81
82 /** 82 /**
83 * Debugging only: dumps the status of the typefaces in the cache 83 * Debugging only: dumps the status of the typefaces in the cache
84 */ 84 */
85 static void Dump(); 85 static void Dump();
86 86
87 private: 87 private:
88 static SkTypefaceCache& Get(); 88 static SkTypefaceCache& Get();
89 89
90 void purge(int count); 90 void purge(int count);
91 91
92 struct Rec { 92 struct Rec {
93 SkTypeface* fFace; 93 SkTypeface* fFace;
94 bool fStrong; 94 bool fStrong;
95 SkTypeface::Style fRequestedStyle; 95 SkFontStyle fRequestedStyle;
96 }; 96 };
97 SkTDArray<Rec> fArray; 97 SkTDArray<Rec> fArray;
98 }; 98 };
99 99
100 #endif 100 #endif
OLDNEW
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/core/SkTypefaceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698