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

Side by Side Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 15111004: Move the FontConfigTypeface class into private header. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | « src/ports/SkFontConfigTypeface.h ('k') | no next file » | 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 2008 Google Inc. 2 * Copyright 2008 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 "SkFontConfigInterface.h" 8 #include "SkFontConfigInterface.h"
9 #include "SkFontConfigTypeface.h"
9 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
10 #include "SkFontHost.h" 11 #include "SkFontHost.h"
11 #include "SkFontHost_FreeType_common.h" 12 #include "SkFontHost_FreeType_common.h"
12 #include "SkFontStream.h" 13 #include "SkFontStream.h"
13 #include "SkStream.h" 14 #include "SkStream.h"
14 #include "SkTypeface.h" 15 #include "SkTypeface.h"
15 #include "SkTypefaceCache.h" 16 #include "SkTypefaceCache.h"
16 17
17 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); 18 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
18 static SkFontConfigInterface* gFontConfigInterface; 19 static SkFontConfigInterface* gFontConfigInterface;
(...skipping 29 matching lines...) Expand all
48 } 49 }
49 50
50 // export this to SkFontMgr_fontconfig.cpp until this file just goes away. 51 // export this to SkFontMgr_fontconfig.cpp until this file just goes away.
51 SkFontConfigInterface* SkFontHost_fontconfig_ref_global(); 52 SkFontConfigInterface* SkFontHost_fontconfig_ref_global();
52 SkFontConfigInterface* SkFontHost_fontconfig_ref_global() { 53 SkFontConfigInterface* SkFontHost_fontconfig_ref_global() {
53 return RefFCI(); 54 return RefFCI();
54 } 55 }
55 56
56 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
57 58
58 class FontConfigTypeface : public SkTypeface_FreeType {
59 SkFontConfigInterface::FontIdentity fIdentity;
60 SkString fFamilyName;
61 SkStream* fLocalStream;
62
63 public:
64 FontConfigTypeface(Style style,
65 const SkFontConfigInterface::FontIdentity& fi,
66 const SkString& familyName)
67 : INHERITED(style, SkTypefaceCache::NewFontID(), false)
68 , fIdentity(fi)
69 , fFamilyName(familyName)
70 , fLocalStream(NULL) {}
71
72 FontConfigTypeface(Style style, SkStream* localStream)
73 : INHERITED(style, SkTypefaceCache::NewFontID(), false) {
74 // we default to empty fFamilyName and fIdentity
75 fLocalStream = localStream;
76 SkSafeRef(localStream);
77 }
78
79 virtual ~FontConfigTypeface() {
80 SkSafeUnref(fLocalStream);
81 }
82
83 const SkFontConfigInterface::FontIdentity& getIdentity() const {
84 return fIdentity;
85 }
86
87 const char* getFamilyName() const { return fFamilyName.c_str(); }
88 SkStream* getLocalStream() const { return fLocalStream; }
89
90 bool isFamilyName(const char* name) const {
91 return fFamilyName.equals(name);
92 }
93
94 protected:
95 friend class SkFontHost; // hack until we can make public versions
96
97 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
98 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
99 size_t length, void* data) const SK_OVERRIDE;
100 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE ;
101 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
102
103 private:
104 typedef SkTypeface_FreeType INHERITED;
105 };
106
107 ///////////////////////////////////////////////////////////////////////////////
108
109 struct FindRec { 59 struct FindRec {
110 FindRec(const char* name, SkTypeface::Style style) 60 FindRec(const char* name, SkTypeface::Style style)
111 : fFamilyName(name) // don't need to make a deep copy 61 : fFamilyName(name) // don't need to make a deep copy
112 , fStyle(style) {} 62 , fStyle(style) {}
113 63
114 const char* fFamilyName; 64 const char* fFamilyName;
115 SkTypeface::Style fStyle; 65 SkTypeface::Style fStyle;
116 }; 66 };
117 67
118 static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) { 68 static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 : 0; 175 : 0;
226 } 176 }
227 177
228 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, 178 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
229 bool* isLocalStream) const { 179 bool* isLocalStream) const {
230 desc->setFamilyName(this->getFamilyName()); 180 desc->setFamilyName(this->getFamilyName());
231 *isLocalStream = SkToBool(this->getLocalStream()); 181 *isLocalStream = SkToBool(this->getLocalStream());
232 } 182 }
233 183
234 /////////////////////////////////////////////////////////////////////////////// 184 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698