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

Side by Side Diff: src/pdf/SkPDFFont.cpp

Issue 419113002: Fix thread unsafe mutex initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return NULL; // Default: no support. 885 return NULL; // Default: no support.
886 } 886 }
887 887
888 // static 888 // static
889 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() { 889 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() {
890 SkPDFFont::CanonicalFontsMutex().assertHeld(); 890 SkPDFFont::CanonicalFontsMutex().assertHeld();
891 static SkTDArray<FontRec> gCanonicalFonts; 891 static SkTDArray<FontRec> gCanonicalFonts;
892 return gCanonicalFonts; 892 return gCanonicalFonts;
893 } 893 }
894 894
895 SK_DECLARE_STATIC_MUTEX(gCanonicalFontsMutex);
895 // static 896 // static
896 SkBaseMutex& SkPDFFont::CanonicalFontsMutex() { 897 SkBaseMutex& SkPDFFont::CanonicalFontsMutex() {
897 SK_DECLARE_STATIC_MUTEX(gCanonicalFontsMutex);
898 return gCanonicalFontsMutex; 898 return gCanonicalFontsMutex;
899 } 899 }
900 900
901 // static 901 // static
902 bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) { 902 bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) {
903 // TODO(vandebo): Optimize this, do only one search? 903 // TODO(vandebo): Optimize this, do only one search?
904 FontRec search(NULL, fontID, glyphID); 904 FontRec search(NULL, fontID, glyphID);
905 *index = CanonicalFonts().find(search); 905 *index = CanonicalFonts().find(search);
906 if (*index >= 0) { 906 if (*index >= 0) {
907 return true; 907 return true;
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1490
1491 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); 1491 insert("FontBBox", makeFontBBox(bbox, 1000))->unref();
1492 insertInt("FirstChar", 1); 1492 insertInt("FirstChar", 1);
1493 insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); 1493 insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1);
1494 insert("Widths", widthArray.get()); 1494 insert("Widths", widthArray.get());
1495 insertName("CIDToGIDMap", "Identity"); 1495 insertName("CIDToGIDMap", "Identity");
1496 1496
1497 populateToUnicodeTable(NULL); 1497 populateToUnicodeTable(NULL);
1498 return true; 1498 return true;
1499 } 1499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698