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

Side by Side Diff: include/ports/SkFontMgr_indirect.h

Issue 206683002: A remotable font management interface and DirectWrite implementation. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | « include/ports/SkFontMgr.h ('k') | include/ports/SkRemotableFontMgr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkFontMgr_indirect_DEFINED
9 #define SkFontMgr_indirect_DEFINED
10
11 #include "SkDataTable.h"
12 #include "SkFontMgr.h"
13 #include "SkFontStyle.h"
14 #include "SkOnce.h"
15 #include "SkRemotableFontMgr.h"
16 #include "SkTArray.h"
17 #include "SkTypeface.h"
18
19 class SkData;
20 class SkStream;
21 class SkString;
22 class SkTypeface;
23
24 class SK_API SkFontMgr_Indirect : public SkFontMgr {
25 public:
26 // TODO: The SkFontMgr is only used for createFromStream/File/Data.
27 // In the future these calls should be broken out into their own interface
28 // with a name like SkFontRenderer.
29 SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy)
30 : fImpl(SkRef(impl)), fProxy(SkRef(proxy))
31 {
32 fOnce = SK_ONCE_INIT;
33 }
34
35 protected:
36 virtual int onCountFamilies() const SK_OVERRIDE;
37 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR IDE;
38 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE;
39
40 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER RIDE;
41
42 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
43 const SkFontStyle& fontStyle) const S K_OVERRIDE;
44
45 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
46 const SkFontStyle&,
47 const char bpc47[],
48 uint32_t character) const SK _OVERRIDE;
49
50 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
51 const SkFontStyle& fontStyle) const SK_ OVERRIDE;
52
53 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE;
54 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE;
55 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV ERRIDE;
56
57 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
58 unsigned styleBits) const SK_OVER RIDE;
59
60 private:
61 SkTypeface* createTypefaceFromFontId(const SkFontIdentity& fontId) const;
62
63 SkAutoTUnref<SkFontMgr> fImpl;
64 SkAutoTUnref<SkRemotableFontMgr> fProxy;
65
66 struct DataEntry {
67 int fDataId; // key1
68 int fTtcIndex; // key2
69 SkTypeface* fTypeface; // value: weak ref to typeface
70
71 DataEntry() { }
72
73 // This is a move!!!
74 DataEntry(DataEntry& that)
75 : fDataId(that.fDataId)
76 , fTtcIndex(that.fTtcIndex)
77 , fTypeface(that.fTypeface)
78 {
79 SkDEBUGCODE(that.fDataId = -1;)
80 SkDEBUGCODE(that.fTtcIndex = -1;)
81 that.fTypeface = NULL;
82 }
83
84 ~DataEntry() {
85 if (fTypeface) {
86 fTypeface->weak_unref();
87 }
88 }
89 };
90 /**
91 * This cache is essentially { dataId: { ttcIndex: typeface } }
92 * For data caching we want a mapping from data id to weak references to
93 * typefaces with that data id. By storing the index next to the typeface,
94 * this data cache also acts as a typeface cache.
95 */
96 mutable SkTArray<DataEntry> fDataCache;
97 mutable SkMutex fDataCacheMutex;
98
99 mutable SkAutoTUnref<SkDataTable> fFamilyNames;
100 mutable SkOnceFlag fOnce;
101 static void set_up_family_names(const SkFontMgr_Indirect* self);
102
103 friend class SkStyleSet_Indirect;
104 };
105
106 #endif
107
OLDNEW
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | include/ports/SkRemotableFontMgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698