| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 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 "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 FontConfigTypeface* cachedFCTypeface = static_cast<FontConfigTypeface*>(cach
edTypeface); | 63 FontConfigTypeface* cachedFCTypeface = static_cast<FontConfigTypeface*>(cach
edTypeface); |
| 64 FontIdentity* identity = static_cast<FontIdentity*>(ctx); | 64 FontIdentity* identity = static_cast<FontIdentity*>(ctx); |
| 65 | 65 |
| 66 return cachedFCTypeface->getIdentity() == *identity; | 66 return cachedFCTypeface->getIdentity() == *identity; |
| 67 } | 67 } |
| 68 | 68 |
| 69 SK_DECLARE_STATIC_MUTEX(gSkFontHostRequestCacheMutex); | 69 SK_DECLARE_STATIC_MUTEX(gSkFontHostRequestCacheMutex); |
| 70 class SkFontHostRequestCache { | 70 class SkFontHostRequestCache { |
| 71 | 71 |
| 72 // The value of maxSize here is a compromise between cache hits and cache si
ze. | 72 // The value of maxSize here is a compromise between cache hits and cache si
ze. |
| 73 static const size_t gMaxSize = 1 << 12; | 73 // See https://crbug.com/424082#63 for reason for current size. |
| 74 static const size_t gMaxSize = 1 << 15; |
| 74 | 75 |
| 75 static SkFontHostRequestCache& Get() { | 76 static SkFontHostRequestCache& Get() { |
| 76 gSkFontHostRequestCacheMutex.assertHeld(); | 77 gSkFontHostRequestCacheMutex.assertHeld(); |
| 77 static SkFontHostRequestCache gCache(gMaxSize); | 78 static SkFontHostRequestCache gCache(gMaxSize); |
| 78 return gCache; | 79 return gCache; |
| 79 } | 80 } |
| 80 | 81 |
| 81 public: | 82 public: |
| 82 struct Request : public SkResourceCache::Key { | 83 struct Request : public SkResourceCache::Key { |
| 83 private: | 84 private: |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 *familyName = fFamilyName; | 228 *familyName = fFamilyName; |
| 228 } | 229 } |
| 229 | 230 |
| 230 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 231 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 231 bool* isLocalStream) const { | 232 bool* isLocalStream) const { |
| 232 SkString name; | 233 SkString name; |
| 233 this->getFamilyName(&name); | 234 this->getFamilyName(&name); |
| 234 desc->setFamilyName(name.c_str()); | 235 desc->setFamilyName(name.c_str()); |
| 235 *isLocalStream = SkToBool(this->getLocalStream()); | 236 *isLocalStream = SkToBool(this->getLocalStream()); |
| 236 } | 237 } |
| OLD | NEW |