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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp

Issue 2533503002: Report decoded webfont blob size to memory-infra (Closed)
Patch Set: Created 4 years 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 (C) 2007 Apple Computer, Inc. 2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * Copyright (C) 2010 Company 100, Inc. 4 * Copyright (C) 2010 Company 100, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 26 matching lines...) Expand all
37 #include "platform/fonts/FontCache.h" 37 #include "platform/fonts/FontCache.h"
38 #include "platform/fonts/FontPlatformData.h" 38 #include "platform/fonts/FontPlatformData.h"
39 #include "platform/fonts/WebFontDecoder.h" 39 #include "platform/fonts/WebFontDecoder.h"
40 #include "third_party/skia/include/core/SkStream.h" 40 #include "third_party/skia/include/core/SkStream.h"
41 #include "third_party/skia/include/core/SkTypeface.h" 41 #include "third_party/skia/include/core/SkTypeface.h"
42 #include "wtf/PtrUtil.h" 42 #include "wtf/PtrUtil.h"
43 #include <memory> 43 #include <memory>
44 44
45 namespace blink { 45 namespace blink {
46 46
47 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface) 47 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface,
48 : m_typeface(typeface) {} 48 size_t dataSize)
49 : m_typeface(typeface), m_dataSize(dataSize) {}
49 50
50 FontCustomPlatformData::~FontCustomPlatformData() {} 51 FontCustomPlatformData::~FontCustomPlatformData() {}
51 52
52 FontPlatformData FontCustomPlatformData::fontPlatformData( 53 FontPlatformData FontCustomPlatformData::fontPlatformData(
53 float size, 54 float size,
54 bool bold, 55 bool bold,
55 bool italic, 56 bool italic,
56 FontOrientation orientation) { 57 FontOrientation orientation) {
57 ASSERT(m_typeface); 58 ASSERT(m_typeface);
58 return FontPlatformData(m_typeface, "", size, bold && !m_typeface->isBold(), 59 return FontPlatformData(m_typeface, "", size, bold && !m_typeface->isBold(),
59 italic && !m_typeface->isItalic(), orientation); 60 italic && !m_typeface->isItalic(), orientation);
60 } 61 }
61 62
62 std::unique_ptr<FontCustomPlatformData> FontCustomPlatformData::create( 63 std::unique_ptr<FontCustomPlatformData> FontCustomPlatformData::create(
63 SharedBuffer* buffer, 64 SharedBuffer* buffer,
64 String& otsParseMessage) { 65 String& otsParseMessage) {
65 DCHECK(buffer); 66 DCHECK(buffer);
66 WebFontDecoder decoder; 67 WebFontDecoder decoder;
67 sk_sp<SkTypeface> typeface = decoder.decode(buffer); 68 sk_sp<SkTypeface> typeface = decoder.decode(buffer);
68 if (!typeface) { 69 if (!typeface) {
69 otsParseMessage = decoder.getErrorString(); 70 otsParseMessage = decoder.getErrorString();
70 return nullptr; 71 return nullptr;
71 } 72 }
72 return wrapUnique(new FontCustomPlatformData(std::move(typeface))); 73 return wrapUnique(
74 new FontCustomPlatformData(std::move(typeface), decoder.decodedSize()));
73 } 75 }
74 76
75 bool FontCustomPlatformData::supportsFormat(const String& format) { 77 bool FontCustomPlatformData::supportsFormat(const String& format) {
76 return equalIgnoringCase(format, "truetype") || 78 return equalIgnoringCase(format, "truetype") ||
77 equalIgnoringCase(format, "opentype") || 79 equalIgnoringCase(format, "opentype") ||
78 WebFontDecoder::supportsFormat(format); 80 WebFontDecoder::supportsFormat(format);
79 } 81 }
80 82
81 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698