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

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

Issue 12593013: remove SkFontHost::CreateScalerContext (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | « src/ports/SkFontHost_android.cpp ('k') | src/ports/SkFontHost_freetype_mac.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 * 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 "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost.h" 10 #include "SkFontHost.h"
11 #include "SkFontHost_FreeType_common.h"
11 #include "SkFontStream.h" 12 #include "SkFontStream.h"
12 #include "SkStream.h" 13 #include "SkStream.h"
13 #include "SkTypeface.h" 14 #include "SkTypeface.h"
14 #include "SkTypefaceCache.h" 15 #include "SkTypefaceCache.h"
15 16
16 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); 17 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
17 static SkFontConfigInterface* gFontConfigInterface; 18 static SkFontConfigInterface* gFontConfigInterface;
18 19
19 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { 20 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
20 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); 21 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
(...skipping 18 matching lines...) Expand all
39 for (;;) { 40 for (;;) {
40 SkFontConfigInterface* fci = SkFontConfigInterface::RefGlobal(); 41 SkFontConfigInterface* fci = SkFontConfigInterface::RefGlobal();
41 if (fci) { 42 if (fci) {
42 return fci; 43 return fci;
43 } 44 }
44 fci = SkFontConfigInterface::GetSingletonDirectInterface(); 45 fci = SkFontConfigInterface::GetSingletonDirectInterface();
45 SkFontConfigInterface::SetGlobal(fci)->unref(); 46 SkFontConfigInterface::SetGlobal(fci)->unref();
46 } 47 }
47 } 48 }
48 49
49 class FontConfigTypeface : public SkTypeface { 50 class FontConfigTypeface : public SkTypeface_FreeType {
50 SkFontConfigInterface::FontIdentity fIdentity; 51 SkFontConfigInterface::FontIdentity fIdentity;
51 SkString fFamilyName; 52 SkString fFamilyName;
52 SkStream* fLocalStream; 53 SkStream* fLocalStream;
53 54
54 public: 55 public:
55 FontConfigTypeface(Style style, 56 FontConfigTypeface(Style style,
56 const SkFontConfigInterface::FontIdentity& fi, 57 const SkFontConfigInterface::FontIdentity& fi,
57 const SkString& familyName) 58 const SkString& familyName)
58 : SkTypeface(style, SkTypefaceCache::NewFontID()) 59 : INHERITED(style, SkTypefaceCache::NewFontID(), false)
59 , fIdentity(fi) 60 , fIdentity(fi)
60 , fFamilyName(familyName) 61 , fFamilyName(familyName)
61 , fLocalStream(NULL) {} 62 , fLocalStream(NULL) {}
62 63
63 FontConfigTypeface(Style style, SkStream* localStream) 64 FontConfigTypeface(Style style, SkStream* localStream)
64 : SkTypeface(style, SkTypefaceCache::NewFontID()) { 65 : INHERITED(style, SkTypefaceCache::NewFontID(), false) {
65 // we default to empty fFamilyName and fIdentity 66 // we default to empty fFamilyName and fIdentity
66 fLocalStream = localStream; 67 fLocalStream = localStream;
67 SkSafeRef(localStream); 68 SkSafeRef(localStream);
68 } 69 }
69 70
70 virtual ~FontConfigTypeface() { 71 virtual ~FontConfigTypeface() {
71 SkSafeUnref(fLocalStream); 72 SkSafeUnref(fLocalStream);
72 } 73 }
73 74
74 const SkFontConfigInterface::FontIdentity& getIdentity() const { 75 const SkFontConfigInterface::FontIdentity& getIdentity() const {
75 return fIdentity; 76 return fIdentity;
76 } 77 }
77 78
78 const char* getFamilyName() const { return fFamilyName.c_str(); } 79 const char* getFamilyName() const { return fFamilyName.c_str(); }
79 SkStream* getLocalStream() const { return fLocalStream; } 80 SkStream* getLocalStream() const { return fLocalStream; }
80 81
81 bool isFamilyName(const char* name) const { 82 bool isFamilyName(const char* name) const {
82 return fFamilyName.equals(name); 83 return fFamilyName.equals(name);
83 } 84 }
84 85
85 protected: 86 protected:
86 friend class SkFontHost; // hack until we can make public versions 87 friend class SkFontHost; // hack until we can make public versions
87 88
88 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; 89 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
89 virtual size_t onGetTableData(SkFontTableTag, size_t offset, 90 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
90 size_t length, void* data) const SK_OVERRIDE; 91 size_t length, void* data) const SK_OVERRIDE;
91 virtual void onGetFontDescriptor(SkFontDescriptor*) const SK_OVERRIDE; 92 virtual void onGetFontDescriptor(SkFontDescriptor*) const SK_OVERRIDE;
92 93
93 private: 94 private:
94 typedef SkTypeface INHERITED; 95 typedef SkTypeface_FreeType INHERITED;
95 }; 96 };
96 97
97 /////////////////////////////////////////////////////////////////////////////// 98 ///////////////////////////////////////////////////////////////////////////////
98 99
99 struct FindRec { 100 struct FindRec {
100 FindRec(const char* name, SkTypeface::Style style) 101 FindRec(const char* name, SkTypeface::Style style)
101 : fFamilyName(name) // don't need to make a deep copy 102 : fFamilyName(name) // don't need to make a deep copy
102 , fStyle(style) {} 103 , fStyle(style) {}
103 104
104 const char* fFamilyName; 105 const char* fFamilyName;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 193 }
193 194
194 // DEPRECATED 195 // DEPRECATED
195 size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag, 196 size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
196 size_t offset, size_t length, void* dst) { 197 size_t offset, size_t length, void* dst) {
197 SkTypeface* face = SkTypefaceCache::FindByID(fontID); 198 SkTypeface* face = SkTypefaceCache::FindByID(fontID);
198 return face ? face->onGetTableData(tag, offset, length, dst) : 0; 199 return face ? face->onGetTableData(tag, offset, length, dst) : 0;
199 } 200 }
200 201
201 // DEPRECATED 202 // DEPRECATED
202 uint32_t SkFontHost::NextLogicalFont(SkFontID curr, SkFontID orig) { 203 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID curr, SkFontID orig) {
203 // We don't handle font fallback. 204 // We don't handle font fallback.
204 return 0; 205 return NULL;
205 } 206 }
206 207
207 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
208 209
209 // Serialize, Deserialize need to be compatible across platforms, hence the use 210 // Serialize, Deserialize need to be compatible across platforms, hence the use
210 // of SkFontDescriptor. 211 // of SkFontDescriptor.
211 212
212 void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) { 213 void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
213 FontConfigTypeface* fct = (FontConfigTypeface*)face; 214 FontConfigTypeface* fct = (FontConfigTypeface*)face;
214 215
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return stream.get() 309 return stream.get()
309 ? SkFontStream::GetTableData(stream, ttcIndex, 310 ? SkFontStream::GetTableData(stream, ttcIndex,
310 tag, offset, length, data) 311 tag, offset, length, data)
311 : 0; 312 : 0;
312 } 313 }
313 314
314 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { 315 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const {
315 desc->setStyle(this->style()); 316 desc->setStyle(this->style());
316 desc->setFamilyName(this->getFamilyName()); 317 desc->setFamilyName(this->getFamilyName());
317 } 318 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_android.cpp ('k') | src/ports/SkFontHost_freetype_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698