| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "platform/fonts/FontCache.h" | 30 #include "platform/fonts/FontCache.h" |
| 31 | 31 |
| 32 #include <memory> |
| 32 #include "base/trace_event/process_memory_dump.h" | 33 #include "base/trace_event/process_memory_dump.h" |
| 33 #include "platform/FontFamilyNames.h" | 34 #include "platform/FontFamilyNames.h" |
| 34 #include "platform/Histogram.h" | 35 #include "platform/Histogram.h" |
| 35 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
| 36 #include "platform/fonts/AcceptLanguagesResolver.h" | 37 #include "platform/fonts/AcceptLanguagesResolver.h" |
| 37 #include "platform/fonts/AlternateFontFamily.h" | 38 #include "platform/fonts/AlternateFontFamily.h" |
| 38 #include "platform/fonts/FontCacheClient.h" | 39 #include "platform/fonts/FontCacheClient.h" |
| 39 #include "platform/fonts/FontCacheKey.h" | 40 #include "platform/fonts/FontCacheKey.h" |
| 40 #include "platform/fonts/FontDataCache.h" | 41 #include "platform/fonts/FontDataCache.h" |
| 41 #include "platform/fonts/FontDescription.h" | 42 #include "platform/fonts/FontDescription.h" |
| 42 #include "platform/fonts/FontPlatformData.h" | 43 #include "platform/fonts/FontPlatformData.h" |
| 43 #include "platform/fonts/FontSmoothingMode.h" | 44 #include "platform/fonts/FontSmoothingMode.h" |
| 44 #include "platform/fonts/SimpleFontData.h" | 45 #include "platform/fonts/SimpleFontData.h" |
| 45 #include "platform/fonts/TextRenderingMode.h" | 46 #include "platform/fonts/TextRenderingMode.h" |
| 46 #include "platform/fonts/opentype/OpenTypeVerticalData.h" | 47 #include "platform/fonts/opentype/OpenTypeVerticalData.h" |
| 47 #include "platform/fonts/shaping/ShapeCache.h" | 48 #include "platform/fonts/shaping/ShapeCache.h" |
| 48 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" | 49 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" |
| 49 #include "platform/instrumentation/tracing/web_process_memory_dump.h" | 50 #include "platform/instrumentation/tracing/web_process_memory_dump.h" |
| 50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
| 51 #include "ui/gfx/font_list.h" | 52 #include "ui/gfx/font_list.h" |
| 52 #include "wtf/HashMap.h" | 53 #include "wtf/HashMap.h" |
| 53 #include "wtf/ListHashSet.h" | 54 #include "wtf/ListHashSet.h" |
| 54 #include "wtf/PtrUtil.h" | 55 #include "wtf/PtrUtil.h" |
| 55 #include "wtf/StdLibExtras.h" | 56 #include "wtf/StdLibExtras.h" |
| 56 #include "wtf/Vector.h" | 57 #include "wtf/Vector.h" |
| 58 #include "wtf/debug/Alias.h" |
| 57 #include "wtf/text/AtomicStringHash.h" | 59 #include "wtf/text/AtomicStringHash.h" |
| 58 #include "wtf/text/StringHash.h" | 60 #include "wtf/text/StringHash.h" |
| 59 #include <memory> | |
| 60 | 61 |
| 61 using namespace WTF; | 62 using namespace WTF; |
| 62 | 63 |
| 63 namespace blink { | 64 namespace blink { |
| 64 | 65 |
| 65 #if !OS(WIN) && !OS(LINUX) | 66 #if !OS(WIN) && !OS(LINUX) |
| 66 FontCache::FontCache() : m_purgePreventCount(0), m_fontManager(nullptr) {} | 67 FontCache::FontCache() : m_purgePreventCount(0), m_fontManager(nullptr) {} |
| 67 #endif // !OS(WIN) && !OS(LINUX) | 68 #endif // !OS(WIN) && !OS(LINUX) |
| 68 | 69 |
| 69 typedef HashMap<unsigned, | 70 typedef HashMap<unsigned, |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 it != end; ++it) | 449 it != end; ++it) |
| 449 clients.push_back(*it); | 450 clients.push_back(*it); |
| 450 | 451 |
| 451 ASSERT(numClients == clients.size()); | 452 ASSERT(numClients == clients.size()); |
| 452 for (size_t i = 0; i < numClients; ++i) | 453 for (size_t i = 0; i < numClients; ++i) |
| 453 clients[i]->fontCacheInvalidated(); | 454 clients[i]->fontCacheInvalidated(); |
| 454 | 455 |
| 455 purge(ForcePurge); | 456 purge(ForcePurge); |
| 456 } | 457 } |
| 457 | 458 |
| 459 void FontCache::crashWithFontInfo(const FontDescription* fontDescription) { |
| 460 FontCache* fontCache = FontCache::fontCache(); |
| 461 SkFontMgr* fontMgr = nullptr; |
| 462 int numFamilies = std::numeric_limits<int>::min(); |
| 463 if (fontCache) { |
| 464 fontMgr = fontCache->m_fontManager.get(); |
| 465 if (fontMgr) |
| 466 numFamilies = fontMgr->countFamilies(); |
| 467 } |
| 468 |
| 469 debug::alias(&fontDescription); |
| 470 debug::alias(&fontCache); |
| 471 debug::alias(&fontMgr); |
| 472 debug::alias(&numFamilies); |
| 473 |
| 474 CHECK(false); |
| 475 } |
| 476 |
| 458 void FontCache::dumpFontPlatformDataCache( | 477 void FontCache::dumpFontPlatformDataCache( |
| 459 base::trace_event::ProcessMemoryDump* memoryDump) { | 478 base::trace_event::ProcessMemoryDump* memoryDump) { |
| 460 ASSERT(isMainThread()); | 479 ASSERT(isMainThread()); |
| 461 if (!gFontPlatformDataCache) | 480 if (!gFontPlatformDataCache) |
| 462 return; | 481 return; |
| 463 base::trace_event::MemoryAllocatorDump* dump = | 482 base::trace_event::MemoryAllocatorDump* dump = |
| 464 memoryDump->CreateAllocatorDump("font_caches/font_platform_data_cache"); | 483 memoryDump->CreateAllocatorDump("font_caches/font_platform_data_cache"); |
| 465 size_t fontPlatformDataObjectsSize = | 484 size_t fontPlatformDataObjectsSize = |
| 466 gFontPlatformDataCache->size() * sizeof(FontPlatformData); | 485 gFontPlatformDataCache->size() * sizeof(FontPlatformData); |
| 467 dump->AddScalar("size", "bytes", fontPlatformDataObjectsSize); | 486 dump->AddScalar("size", "bytes", fontPlatformDataObjectsSize); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 482 for (iter = gFallbackListShaperCache->begin(); | 501 for (iter = gFallbackListShaperCache->begin(); |
| 483 iter != gFallbackListShaperCache->end(); ++iter) { | 502 iter != gFallbackListShaperCache->end(); ++iter) { |
| 484 shapeResultCacheSize += iter->value->byteSize(); | 503 shapeResultCacheSize += iter->value->byteSize(); |
| 485 } | 504 } |
| 486 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 505 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
| 487 memoryDump->AddSuballocation(dump->guid(), | 506 memoryDump->AddSuballocation(dump->guid(), |
| 488 WTF::Partitions::kAllocatedObjectPoolName); | 507 WTF::Partitions::kAllocatedObjectPoolName); |
| 489 } | 508 } |
| 490 | 509 |
| 491 } // namespace blink | 510 } // namespace blink |
| OLD | NEW |