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

Side by Side Diff: src/core/SkGlyphCache.cpp

Issue 1953533002: SkOncePtr -> SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hide sk_num_cores() Created 4 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
« no previous file with comments | « src/core/SkFontMgr.cpp ('k') | src/core/SkImageFilterCache.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkGlyphCache.h" 8 #include "SkGlyphCache.h"
9 #include "SkGlyphCache_Globals.h" 9 #include "SkGlyphCache_Globals.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
11 #include "SkOncePtr.h" 11 #include "SkOnce.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkTemplates.h" 13 #include "SkTemplates.h"
14 #include "SkTraceMemoryDump.h" 14 #include "SkTraceMemoryDump.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 16
17 #include <cctype> 17 #include <cctype>
18 18
19 //#define SPEW_PURGE_STATUS 19 //#define SPEW_PURGE_STATUS
20 20
21 namespace { 21 namespace {
22 const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache"; 22 const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache";
23 } // namespace 23 } // namespace
24 24
25 // Returns the shared globals 25 // Returns the shared globals
26 SK_DECLARE_STATIC_ONCE_PTR(SkGlyphCache_Globals, globals);
27 static SkGlyphCache_Globals& get_globals() { 26 static SkGlyphCache_Globals& get_globals() {
28 return *globals.get([]{ return new SkGlyphCache_Globals; }); 27 static SkOnce once;
28 static SkGlyphCache_Globals* globals;
29
30 once([]{ globals = new SkGlyphCache_Globals; });
31 return *globals;
29 } 32 }
30 33
31 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
32 35
33 // so we don't grow our arrays a lot 36 // so we don't grow our arrays a lot
34 #define kMinGlyphCount 16 37 #define kMinGlyphCount 16
35 #define kMinGlyphImageSize (16*2) 38 #define kMinGlyphImageSize (16*2)
36 #define kMinAllocAmount ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphC ount) 39 #define kMinAllocAmount ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphC ount)
37 40
38 SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca lerContext* ctx) 41 SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca lerContext* ctx)
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 817 }
815 818
816 void SkGraphics::PurgeFontCache() { 819 void SkGraphics::PurgeFontCache() {
817 get_globals().purgeAll(); 820 get_globals().purgeAll();
818 SkTypefaceCache::PurgeAll(); 821 SkTypefaceCache::PurgeAll();
819 } 822 }
820 823
821 // TODO(herb): clean up TLS apis. 824 // TODO(herb): clean up TLS apis.
822 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } 825 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; }
823 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } 826 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { }
OLDNEW
« no previous file with comments | « src/core/SkFontMgr.cpp ('k') | src/core/SkImageFilterCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698