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

Side by Side Diff: src/ports/SkFontHost_mac.cpp

Issue 419113002: Fix thread unsafe mutex initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 /* 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 #include <vector> 9 #include <vector>
10 #ifdef SK_BUILD_FOR_MAC 10 #ifdef SK_BUILD_FOR_MAC
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 CTFontDescriptorCreateWithAttributes(cfAttributes)); 519 CTFontDescriptorCreateWithAttributes(cfAttributes));
520 520
521 if (ctFontDesc != NULL) { 521 if (ctFontDesc != NULL) {
522 ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL); 522 ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL);
523 } 523 }
524 } 524 }
525 525
526 return ctFont ? NewFromFontRef(ctFont, familyName, false) : NULL; 526 return ctFont ? NewFromFontRef(ctFont, familyName, false) : NULL;
527 } 527 }
528 528
529 SK_DECLARE_STATIC_MUTEX(gGetDefaultFaceMutex);
529 static SkTypeface* GetDefaultFace() { 530 static SkTypeface* GetDefaultFace() {
530 SK_DECLARE_STATIC_MUTEX(gMutex); 531 SkAutoMutexAcquire ma(gGetDefaultFaceMutex);
531 SkAutoMutexAcquire ma(gMutex);
532 532
533 static SkTypeface* gDefaultFace; 533 static SkTypeface* gDefaultFace;
534 534
535 if (NULL == gDefaultFace) { 535 if (NULL == gDefaultFace) {
536 gDefaultFace = NewFromName(FONT_DEFAULT_NAME, SkTypeface::kNormal); 536 gDefaultFace = NewFromName(FONT_DEFAULT_NAME, SkTypeface::kNormal);
537 SkTypefaceCache::Add(gDefaultFace, SkTypeface::kNormal); 537 SkTypefaceCache::Add(gDefaultFace, SkTypeface::kNormal);
538 } 538 }
539 return gDefaultFace; 539 return gDefaultFace;
540 } 540 }
541 541
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); 2304 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
2305 } 2305 }
2306 }; 2306 };
2307 2307
2308 /////////////////////////////////////////////////////////////////////////////// 2308 ///////////////////////////////////////////////////////////////////////////////
2309 2309
2310 SkFontMgr* SkFontMgr::Factory() { 2310 SkFontMgr* SkFontMgr::Factory() {
2311 return SkNEW(SkFontMgr_Mac); 2311 return SkNEW(SkFontMgr_Mac);
2312 } 2312 }
2313 #endif 2313 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698