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

Unified Diff: src/core/SkTypefaceCache.h

Issue 23067003: expose instance methods on SkTypefaceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkTypefaceCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypefaceCache.h
diff --git a/src/core/SkTypefaceCache.h b/src/core/SkTypefaceCache.h
index b6cab8163fa156580b38bb9934c0172d80fb5365..ae37ab76ec4ba6cfd4984087606eb78f40030f08 100644
--- a/src/core/SkTypefaceCache.h
+++ b/src/core/SkTypefaceCache.h
@@ -23,6 +23,9 @@
class SkTypefaceCache {
public:
+ SkTypefaceCache();
+ ~SkTypefaceCache();
+
/**
* Callback for FindByProc. Returns true if the given typeface is a match
* for the given context. The passed typeface is owned by the cache and is
@@ -31,20 +34,12 @@ public:
typedef bool (*FindProc)(SkTypeface*, SkTypeface::Style, void* context);
/**
- * Helper: returns a unique fontID to pass to the constructor of
- * your subclass of SkTypeface
- */
- static SkFontID NewFontID();
-
- /**
* Add a typeface to the cache. This ref()s the typeface, so that the
* cache is also an owner. Later, if we need to purge the cache, typefaces
* whose refcnt is 1 (meaning only the cache is an owner) will be
* unref()ed.
*/
- static void Add(SkTypeface*,
- SkTypeface::Style requested,
- bool strong = true);
+ void add(SkTypeface*, SkTypeface::Style requested, bool strong = true);
/**
* Search the cache for a typeface with the specified fontID (uniqueID).
@@ -52,14 +47,14 @@ public:
* is found, return NULL. The reference count is unmodified as it is
* assumed that the stack will contain a ref to the typeface.
*/
- static SkTypeface* FindByID(SkFontID fontID);
+ SkTypeface* findByID(SkFontID findID) const;
/**
* Iterate through the cache, calling proc(typeface, ctx) with each
* typeface. If proc returns true, then we return that typeface (this
* ref()s the typeface). If it never returns true, we return NULL.
*/
- static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx);
+ SkTypeface* findByProcAndRef(FindProc proc, void* ctx) const;
/**
* This will unref all of the typefaces in the cache for which the cache
@@ -67,6 +62,21 @@ public:
* This function is exposed for clients that explicitly want to purge the
* cache (e.g. to look for leaks).
*/
+ void purgeAll();
+
+ /**
+ * Helper: returns a unique fontID to pass to the constructor of
+ * your subclass of SkTypeface
+ */
+ static SkFontID NewFontID();
+
+ // These are static wrappers around a global instance of a cache.
+
+ static void Add(SkTypeface*,
+ SkTypeface::Style requested,
+ bool strong = true);
+ static SkTypeface* FindByID(SkFontID fontID);
+ static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx);
static void PurgeAll();
/**
@@ -77,11 +87,7 @@ public:
private:
static SkTypefaceCache& Get();
- void add(SkTypeface*, SkTypeface::Style requested, bool strong = true);
- SkTypeface* findByID(SkFontID findID) const;
- SkTypeface* findByProcAndRef(FindProc proc, void* ctx) const;
void purge(int count);
- void purgeAll();
struct Rec {
SkTypeface* fFace;
« no previous file with comments | « no previous file | src/core/SkTypefaceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698