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

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

Issue 306063004: Revert of Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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/SkFontHost.cpp ('k') | src/core/SkLazyPtr.h » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkGlyphCache.h" 10 #include "SkGlyphCache.h"
11 #include "SkGlyphCache_Globals.h" 11 #include "SkGlyphCache_Globals.h"
12 #include "SkDistanceFieldGen.h" 12 #include "SkDistanceFieldGen.h"
13 #include "SkGraphics.h" 13 #include "SkGraphics.h"
14 #include "SkLazyPtr.h" 14 #include "SkOnce.h"
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #include "SkTemplates.h" 17 #include "SkTemplates.h"
18 #include "SkTLS.h" 18 #include "SkTLS.h"
19 #include "SkTypeface.h" 19 #include "SkTypeface.h"
20 20
21 //#define SPEW_PURGE_STATUS 21 //#define SPEW_PURGE_STATUS
22 //#define RECORD_HASH_EFFICIENCY 22 //#define RECORD_HASH_EFFICIENCY
23 23
24 namespace { 24 static void create_globals(SkGlyphCache_Globals** globals) {
25 25 *globals = SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseM utex));
26 SkGlyphCache_Globals* create_globals() {
27 return SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseMutex ));
28 } 26 }
29 27
30 } // namespace
31
32 // Returns the shared globals 28 // Returns the shared globals
33 static SkGlyphCache_Globals& getSharedGlobals() { 29 static SkGlyphCache_Globals& getSharedGlobals() {
34 SK_DECLARE_STATIC_LAZY_PTR(SkGlyphCache_Globals, globals, create_globals); 30 // we leak this, so we don't incur any shutdown cost of the destructor
35 return *globals.get(); 31 static SkGlyphCache_Globals* gGlobals = NULL;
32 SK_DECLARE_STATIC_ONCE(once);
33 SkOnce(&once, create_globals, &gGlobals);
34 SkASSERT(NULL != gGlobals);
35 return *gGlobals;
36 } 36 }
37 37
38 // Returns the TLS globals (if set), or the shared globals 38 // Returns the TLS globals (if set), or the shared globals
39 static SkGlyphCache_Globals& getGlobals() { 39 static SkGlyphCache_Globals& getGlobals() {
40 SkGlyphCache_Globals* tls = SkGlyphCache_Globals::FindTLS(); 40 SkGlyphCache_Globals* tls = SkGlyphCache_Globals::FindTLS();
41 return tls ? *tls : getSharedGlobals(); 41 return tls ? *tls : getSharedGlobals();
42 } 42 }
43 43
44 /////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////
45 45
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 return tls ? tls->getCacheSizeLimit() : 0; 757 return tls ? tls->getCacheSizeLimit() : 0;
758 } 758 }
759 759
760 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { 760 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) {
761 if (0 == bytes) { 761 if (0 == bytes) {
762 SkGlyphCache_Globals::DeleteTLS(); 762 SkGlyphCache_Globals::DeleteTLS();
763 } else { 763 } else {
764 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); 764 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes);
765 } 765 }
766 } 766 }
OLDNEW
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | src/core/SkLazyPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698