OLD | NEW |
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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 CanonicalFonts().push(newEntry); | 865 CanonicalFonts().push(newEntry); |
866 return font; // Return the reference new SkPDFFont() created. | 866 return font; // Return the reference new SkPDFFont() created. |
867 } | 867 } |
868 | 868 |
869 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { | 869 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { |
870 return NULL; // Default: no support. | 870 return NULL; // Default: no support. |
871 } | 871 } |
872 | 872 |
873 // static | 873 // static |
874 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() { | 874 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() { |
875 // This initialization is only thread safe with gcc. | 875 SkPDFFont::CanonicalFontsMutex().assertHeld(); |
876 static SkTDArray<FontRec> gCanonicalFonts; | 876 static SkTDArray<FontRec> gCanonicalFonts; |
877 return gCanonicalFonts; | 877 return gCanonicalFonts; |
878 } | 878 } |
879 | 879 |
880 // static | 880 // static |
881 SkBaseMutex& SkPDFFont::CanonicalFontsMutex() { | 881 SkBaseMutex& SkPDFFont::CanonicalFontsMutex() { |
882 // This initialization is only thread safe with gcc, or when | |
883 // POD-style mutex initialization is used. | |
884 SK_DECLARE_STATIC_MUTEX(gCanonicalFontsMutex); | 882 SK_DECLARE_STATIC_MUTEX(gCanonicalFontsMutex); |
885 return gCanonicalFontsMutex; | 883 return gCanonicalFontsMutex; |
886 } | 884 } |
887 | 885 |
888 // static | 886 // static |
889 bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) { | 887 bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) { |
890 // TODO(vandebo): Optimize this, do only one search? | 888 // TODO(vandebo): Optimize this, do only one search? |
891 FontRec search(NULL, fontID, glyphID); | 889 FontRec search(NULL, fontID, glyphID); |
892 *index = CanonicalFonts().find(search); | 890 *index = CanonicalFonts().find(search); |
893 if (*index >= 0) { | 891 if (*index >= 0) { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1473 |
1476 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); | 1474 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); |
1477 insertInt("FirstChar", 1); | 1475 insertInt("FirstChar", 1); |
1478 insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); | 1476 insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); |
1479 insert("Widths", widthArray.get()); | 1477 insert("Widths", widthArray.get()); |
1480 insertName("CIDToGIDMap", "Identity"); | 1478 insertName("CIDToGIDMap", "Identity"); |
1481 | 1479 |
1482 populateToUnicodeTable(NULL); | 1480 populateToUnicodeTable(NULL); |
1483 return true; | 1481 return true; |
1484 } | 1482 } |
OLD | NEW |