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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontCache.h

Issue 1591883002: Add plumbing in blink to allow overriding the default font collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up extra headers and declarations Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2007-2008 Torch Mobile, Inc. 3 * Copyright (C) 2007-2008 Torch Mobile, Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 28 matching lines...) Expand all
39 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
40 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
41 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
42 #include "wtf/text/CString.h" 42 #include "wtf/text/CString.h"
43 #include "wtf/text/Unicode.h" 43 #include "wtf/text/Unicode.h"
44 #include "wtf/text/WTFString.h" 44 #include "wtf/text/WTFString.h"
45 #include <limits.h> 45 #include <limits.h>
46 46
47 #if OS(WIN) 47 #if OS(WIN)
48 #include "SkFontMgr.h" 48 #include "SkFontMgr.h"
49 #include "skia/ext/refptr.h"
49 struct IDWriteFactory; 50 struct IDWriteFactory;
50 #endif 51 #endif
51 52
52 class SkTypeface; 53 class SkTypeface;
53 54
54 namespace blink { 55 namespace blink {
55 56
56 class FontCacheClient; 57 class FontCacheClient;
57 class FontFaceCreationParams; 58 class FontFaceCreationParams;
58 class FontPlatformData; 59 class FontPlatformData;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 unsigned short generation(); 102 unsigned short generation();
102 void invalidate(); 103 void invalidate();
103 104
104 #if OS(WIN) 105 #if OS(WIN)
105 bool useSubpixelPositioning() const { return s_useSubpixelPositioning; } 106 bool useSubpixelPositioning() const { return s_useSubpixelPositioning; }
106 SkFontMgr* fontManager() { return m_fontManager.get(); } 107 SkFontMgr* fontManager() { return m_fontManager.get(); }
107 static bool useDirectWrite() { return s_useDirectWrite; } 108 static bool useDirectWrite() { return s_useDirectWrite; }
108 static float deviceScaleFactor() { return s_deviceScaleFactor; } 109 static float deviceScaleFactor() { return s_deviceScaleFactor; }
109 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD irectWrite; } 110 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD irectWrite; }
110 static void setDirectWriteFactory(IDWriteFactory* factory) { s_directWriteFa ctory = factory; } 111 static void setFontManager(const skia::RefPtr<SkFontMgr>&);
112 static void setDirectWriteFactory(IDWriteFactory*);
111 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac tor = deviceScaleFactor; } 113 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac tor = deviceScaleFactor; }
112 static void setUseSubpixelPositioning(bool useSubpixelPositioning) { s_useSu bpixelPositioning = useSubpixelPositioning; } 114 static void setUseSubpixelPositioning(bool useSubpixelPositioning) { s_useSu bpixelPositioning = useSubpixelPositioning; }
113 static void addSideloadedFontForTesting(SkTypeface*); 115 static void addSideloadedFontForTesting(SkTypeface*);
114 // Functions to cache and retrieve the system font metrics. 116 // Functions to cache and retrieve the system font metrics.
115 static void setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight ); 117 static void setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight );
116 static void setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fo ntHeight); 118 static void setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fo ntHeight);
117 static void setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeig ht); 119 static void setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeig ht);
118 static int32_t menuFontHeight() { return s_menuFontHeight; } 120 static int32_t menuFontHeight() { return s_menuFontHeight; }
119 static const AtomicString& menuFontFamily() { return *s_smallCaptionFontFami lyName; } 121 static const AtomicString& menuFontFamily() { return *s_smallCaptionFontFami lyName; }
120 static int32_t smallCaptionFontHeight() { return s_smallCaptionFontHeight; } 122 static int32_t smallCaptionFontHeight() { return s_smallCaptionFontHeight; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 171
170 // Implemented on skia platforms. 172 // Implemented on skia platforms.
171 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace CreationParams&, CString& name); 173 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace CreationParams&, CString& name);
172 174
173 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription &, UChar32); 175 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription &, UChar32);
174 176
175 // Don't purge if this count is > 0; 177 // Don't purge if this count is > 0;
176 int m_purgePreventCount; 178 int m_purgePreventCount;
177 179
178 #if OS(WIN) 180 #if OS(WIN)
179 OwnPtr<SkFontMgr> m_fontManager; 181 skia::RefPtr<SkFontMgr> m_fontManager;
jbroman 2016/01/21 15:51:31 drive-by: Blink currently uses WTF::RefPtr for Ski
Ilya Kulshin 2016/01/21 20:59:22 Done. I switched back to raw pointers for the publ
180 static bool s_useDirectWrite; 182 static bool s_useDirectWrite;
181 static IDWriteFactory* s_directWriteFactory; 183 static IDWriteFactory* s_directWriteFactory;
184 static SkFontMgr* s_fontManager;
182 static float s_deviceScaleFactor; 185 static float s_deviceScaleFactor;
183 static bool s_useSubpixelPositioning; 186 static bool s_useSubpixelPositioning;
184 static HashMap<String, RefPtr<SkTypeface>>* s_sideloadedFonts; 187 static HashMap<String, RefPtr<SkTypeface>>* s_sideloadedFonts;
185 // The system font metrics cache. 188 // The system font metrics cache.
186 static AtomicString* s_menuFontFamilyName; 189 static AtomicString* s_menuFontFamilyName;
187 static int32_t s_menuFontHeight; 190 static int32_t s_menuFontHeight;
188 static AtomicString* s_smallCaptionFontFamilyName; 191 static AtomicString* s_smallCaptionFontFamilyName;
189 static int32_t s_smallCaptionFontHeight; 192 static int32_t s_smallCaptionFontHeight;
190 static AtomicString* s_statusFontFamilyName; 193 static AtomicString* s_statusFontFamilyName;
191 static int32_t s_statusFontHeight; 194 static int32_t s_statusFontHeight;
192 #endif 195 #endif
193 196
194 friend class SimpleFontData; // For fontDataFromFontPlatformData 197 friend class SimpleFontData; // For fontDataFromFontPlatformData
195 friend class FontFallbackList; 198 friend class FontFallbackList;
196 }; 199 };
197 200
198 class PLATFORM_EXPORT FontCachePurgePreventer { 201 class PLATFORM_EXPORT FontCachePurgePreventer {
199 USING_FAST_MALLOC(FontCachePurgePreventer); 202 USING_FAST_MALLOC(FontCachePurgePreventer);
200 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer); 203 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer);
201 public: 204 public:
202 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } 205 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); }
203 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } 206 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); }
204 }; 207 };
205 208
206 } // namespace blink 209 } // namespace blink
207 210
208 #endif 211 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698