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

Side by Side Diff: src/ports/SkFontConfigTypeface.h

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 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/pdf/SkPDFStream.cpp ('k') | src/ports/SkFontHost_FreeType.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 2013 Google Inc. 2 * Copyright 2013 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 "SkFontHost_FreeType_common.h" 9 #include "SkFontHost_FreeType_common.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
11 #include "SkTypefaceCache.h" 11 #include "SkTypefaceCache.h"
12 12
13 class SkFontDescriptor; 13 class SkFontDescriptor;
14 14
15 class FontConfigTypeface : public SkTypeface_FreeType { 15 class FontConfigTypeface : public SkTypeface_FreeType {
16 SkFontConfigInterface::FontIdentity fIdentity; 16 SkFontConfigInterface::FontIdentity fIdentity;
17 SkString fFamilyName; 17 SkString fFamilyName;
18 SkStream* fLocalStream; 18 SkAutoTDelete<SkStream> fLocalStream;
19 19
20 public: 20 public:
21 static FontConfigTypeface* Create(const SkFontStyle& style, 21 static FontConfigTypeface* Create(const SkFontStyle& style,
22 const SkFontConfigInterface::FontIdentity& fi, 22 const SkFontConfigInterface::FontIdentity& fi,
23 const SkString& familyName) { 23 const SkString& familyName) {
24 return SkNEW_ARGS(FontConfigTypeface, (style, fi, familyName)); 24 return SkNEW_ARGS(FontConfigTypeface, (style, fi, familyName));
25 } 25 }
26 26
27 static FontConfigTypeface* Create(const SkFontStyle& style, bool fixedWidth, 27 static FontConfigTypeface* Create(const SkFontStyle& style, bool fixedWidth,
28 SkStream* localStream) { 28 SkStream* localStream) {
29 return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream)); 29 return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream));
30 } 30 }
31 31
32 virtual ~FontConfigTypeface() {
33 SkSafeUnref(fLocalStream);
34 }
35
36 const SkFontConfigInterface::FontIdentity& getIdentity() const { 32 const SkFontConfigInterface::FontIdentity& getIdentity() const {
37 return fIdentity; 33 return fIdentity;
38 } 34 }
39 35
40 const char* getFamilyName() const { return fFamilyName.c_str(); } 36 const char* getFamilyName() const { return fFamilyName.c_str(); }
41 SkStream* getLocalStream() const { return fLocalStream; } 37 SkStream* getLocalStream() const { return fLocalStream.get(); }
42 38
43 bool isFamilyName(const char* name) const { 39 bool isFamilyName(const char* name) const {
44 return fFamilyName.equals(name); 40 return fFamilyName.equals(name);
45 } 41 }
46 42
47 static SkTypeface* LegacyCreateTypeface(const SkTypeface* family, 43 static SkTypeface* LegacyCreateTypeface(const SkTypeface* family,
48 const char familyName[], 44 const char familyName[],
49 SkTypeface::Style); 45 SkTypeface::Style);
50 46
51 protected: 47 protected:
52 friend class SkFontHost; // hack until we can make public versions 48 friend class SkFontHost; // hack until we can make public versions
53 49
54 FontConfigTypeface(const SkFontStyle& style, 50 FontConfigTypeface(const SkFontStyle& style,
55 const SkFontConfigInterface::FontIdentity& fi, 51 const SkFontConfigInterface::FontIdentity& fi,
56 const SkString& familyName) 52 const SkString& familyName)
57 : INHERITED(style, SkTypefaceCache::NewFontID(), false) 53 : INHERITED(style, SkTypefaceCache::NewFontID(), false)
58 , fIdentity(fi) 54 , fIdentity(fi)
59 , fFamilyName(familyName) 55 , fFamilyName(familyName)
60 , fLocalStream(NULL) {} 56 , fLocalStream(NULL) {}
61 57
62 FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStream* loca lStream) 58 FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStream* loca lStream)
63 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) { 59 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
60 , fLocalStream(localStream) {
64 // we default to empty fFamilyName and fIdentity 61 // we default to empty fFamilyName and fIdentity
65 fLocalStream = localStream;
66 SkSafeRef(localStream);
67 } 62 }
68 63
69 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; 64 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE;
70 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; 65 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
71 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; 66 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
72 67
73 private: 68 private:
74 typedef SkTypeface_FreeType INHERITED; 69 typedef SkTypeface_FreeType INHERITED;
75 }; 70 };
OLDNEW
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698