OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/font_cache_dispatcher_win.h" | 5 #include "content/common/font_cache_dispatcher_win.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 static FontCache* GetInstance() { | 22 static FontCache* GetInstance() { |
23 return Singleton<FontCache>::get(); | 23 return Singleton<FontCache>::get(); |
24 } | 24 } |
25 | 25 |
26 void PreCacheFont(const LOGFONT& font, FontCacheDispatcher* dispatcher) { | 26 void PreCacheFont(const LOGFONT& font, FontCacheDispatcher* dispatcher) { |
27 // TODO(ananta): Remove ScopedTracker below once crbug.com/90127 is fixed. | 27 // TODO(ananta): Remove ScopedTracker below once crbug.com/90127 is fixed. |
28 tracked_objects::ScopedTracker tracking_profile( | 28 tracked_objects::ScopedTracker tracking_profile( |
29 FROM_HERE_WITH_EXPLICIT_FUNCTION("90127 FontCache::PreCacheFont")); | 29 FROM_HERE_WITH_EXPLICIT_FUNCTION("90127 FontCache::PreCacheFont")); |
30 | 30 |
31 typedef std::map<base::string16, FontCache::CacheElement> FontNameToElement; | |
32 | |
33 base::AutoLock lock(mutex_); | 31 base::AutoLock lock(mutex_); |
34 | 32 |
35 // Fetch the font into memory. | 33 // Fetch the font into memory. |
36 // No matter the font is cached or not, we load it to avoid GDI swapping out | 34 // No matter the font is cached or not, we load it to avoid GDI swapping out |
37 // that font file. | 35 // that font file. |
38 HDC hdc = GetDC(NULL); | 36 HDC hdc = GetDC(NULL); |
39 HFONT font_handle = CreateFontIndirect(&font); | 37 HFONT font_handle = CreateFontIndirect(&font); |
40 DCHECK(NULL != font_handle); | 38 DCHECK(NULL != font_handle); |
41 | 39 |
42 HGDIOBJ old_font = SelectObject(hdc, font_handle); | 40 HGDIOBJ old_font = SelectObject(hdc, font_handle); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 FontCache::GetInstance()->PreCacheFont(font, this); | 188 FontCache::GetInstance()->PreCacheFont(font, this); |
191 } | 189 } |
192 | 190 |
193 void FontCacheDispatcher::OnReleaseCachedFonts() { | 191 void FontCacheDispatcher::OnReleaseCachedFonts() { |
194 // Release cached fonts that requested from a pid by decrementing the ref | 192 // Release cached fonts that requested from a pid by decrementing the ref |
195 // count. When ref count is zero, the handles are released. | 193 // count. When ref count is zero, the handles are released. |
196 FontCache::GetInstance()->ReleaseCachedFonts(this); | 194 FontCache::GetInstance()->ReleaseCachedFonts(this); |
197 } | 195 } |
198 | 196 |
199 } // namespace content | 197 } // namespace content |
OLD | NEW |