| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 Google Inc. | 2 * Copyright 2009 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 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ | 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 #include <fcntl.h> | 12 #include <fcntl.h> |
| 13 | 13 |
| 14 #include <fontconfig/fontconfig.h> | 14 #include <fontconfig/fontconfig.h> |
| 15 | 15 |
| 16 #include "SkBuffer.h" | 16 #include "SkBuffer.h" |
| 17 #include "SkFontConfigInterface.h" | 17 #include "SkFontConfigInterface.h" |
| 18 #include "SkLazyPtr.h" | 18 #include "SkOnce.h" |
| 19 #include "SkStream.h" | 19 #include "SkStream.h" |
| 20 | 20 |
| 21 size_t SkFontConfigInterface::FontIdentity::writeToMemory(void* addr) const { | 21 size_t SkFontConfigInterface::FontIdentity::writeToMemory(void* addr) const { |
| 22 size_t size = sizeof(fID) + sizeof(fTTCIndex); | 22 size_t size = sizeof(fID) + sizeof(fTTCIndex); |
| 23 size += sizeof(int32_t) + sizeof(int32_t) + sizeof(uint8_t); // weight, widt
h, italic | 23 size += sizeof(int32_t) + sizeof(int32_t) + sizeof(uint8_t); // weight, widt
h, italic |
| 24 size += sizeof(int32_t) + fString.size(); // store length+data | 24 size += sizeof(int32_t) + fString.size(); // store length+data |
| 25 if (addr) { | 25 if (addr) { |
| 26 SkWBuffer buffer(addr, size); | 26 SkWBuffer buffer(addr, size); |
| 27 | 27 |
| 28 buffer.write32(fID); | 28 buffer.write32(fID); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // new APIs | 117 // new APIs |
| 118 virtual SkDataTable* getFamilyNames() SK_OVERRIDE; | 118 virtual SkDataTable* getFamilyNames() SK_OVERRIDE; |
| 119 virtual bool matchFamilySet(const char inFamilyName[], | 119 virtual bool matchFamilySet(const char inFamilyName[], |
| 120 SkString* outFamilyName, | 120 SkString* outFamilyName, |
| 121 SkTArray<FontIdentity>*) SK_OVERRIDE; | 121 SkTArray<FontIdentity>*) SK_OVERRIDE; |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 SkMutex mutex_; | 124 SkMutex mutex_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 namespace { | 127 static void create_singleton_direct_interface(SkFontConfigInterface** singleton)
{ |
| 128 SkFontConfigInterface* create_direct() { return SkNEW(SkFontConfigInterfaceDirec
t); } | 128 *singleton = new SkFontConfigInterfaceDirect; |
| 129 } // namespace | 129 } |
| 130 | |
| 131 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() { | 130 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() { |
| 132 SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterface, direct, create_direct); | 131 static SkFontConfigInterface* gDirect; |
| 133 return direct.get(); | 132 SK_DECLARE_STATIC_ONCE(once); |
| 133 SkOnce(&once, create_singleton_direct_interface, &gDirect); |
| 134 return gDirect; |
| 134 } | 135 } |
| 135 | 136 |
| 136 /////////////////////////////////////////////////////////////////////////////// | 137 /////////////////////////////////////////////////////////////////////////////// |
| 137 | 138 |
| 138 // Returns the string from the pattern, or NULL | 139 // Returns the string from the pattern, or NULL |
| 139 static const char* get_name(FcPattern* pattern, const char field[], | 140 static const char* get_name(FcPattern* pattern, const char field[], |
| 140 int index = 0) { | 141 int index = 0) { |
| 141 const char* name; | 142 const char* name; |
| 142 if (FcPatternGetString(pattern, field, index, | 143 if (FcPatternGetString(pattern, field, index, |
| 143 (FcChar8**)&name) != FcResultMatch) { | 144 (FcChar8**)&name) != FcResultMatch) { |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 *trimmedMatches.append() = match[i]; | 725 *trimmedMatches.append() = match[i]; |
| 725 } | 726 } |
| 726 } | 727 } |
| 727 | 728 |
| 728 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, | 729 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, |
| 729 (trimmedMatches.begin(), | 730 (trimmedMatches.begin(), |
| 730 trimmedMatches.count())); | 731 trimmedMatches.count())); |
| 731 #endif | 732 #endif |
| 732 return false; | 733 return false; |
| 733 } | 734 } |
| OLD | NEW |