OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 } // namespace | 148 } // namespace |
149 | 149 |
150 // static | 150 // static |
151 bool WebFontDecoder::supportsFormat(const String& format) | 151 bool WebFontDecoder::supportsFormat(const String& format) |
152 { | 152 { |
153 return equalIgnoringCase(format, "woff") || equalIgnoringCase(format, "woff2
"); | 153 return equalIgnoringCase(format, "woff") || equalIgnoringCase(format, "woff2
"); |
154 } | 154 } |
155 | 155 |
156 PassRefPtr<SkTypeface> WebFontDecoder::decode(SharedBuffer* buffer) | 156 sk_sp<SkTypeface> WebFontDecoder::decode(SharedBuffer* buffer) |
157 { | 157 { |
158 if (!buffer) { | 158 if (!buffer) { |
159 setErrorString("Empty Buffer"); | 159 setErrorString("Empty Buffer"); |
160 return nullptr; | 160 return nullptr; |
161 } | 161 } |
162 | 162 |
163 // This is the largest web font size which we'll try to transcode. | 163 // This is the largest web font size which we'll try to transcode. |
164 // TODO(bashi): 30MB seems low. Update the limit if necessary. | 164 // TODO(bashi): 30MB seems low. Update the limit if necessary. |
165 static const size_t maxWebFontSize = 30 * 1024 * 1024; // 30 MB | 165 static const size_t maxWebFontSize = 30 * 1024 * 1024; // 30 MB |
166 if (buffer->size() > maxWebFontSize) { | 166 if (buffer->size() > maxWebFontSize) { |
(...skipping 16 matching lines...) Expand all Loading... |
183 setErrorString(otsContext.getErrorString()); | 183 setErrorString(otsContext.getErrorString()); |
184 return nullptr; | 184 return nullptr; |
185 } | 185 } |
186 | 186 |
187 const size_t decodedLength = output.Tell(); | 187 const size_t decodedLength = output.Tell(); |
188 recordDecodeSpeedHistogram(data, buffer->size(), currentTime() - start, deco
dedLength); | 188 recordDecodeSpeedHistogram(data, buffer->size(), currentTime() - start, deco
dedLength); |
189 | 189 |
190 sk_sp<SkData> skData = SkData::MakeWithCopy(output.get(), decodedLength); | 190 sk_sp<SkData> skData = SkData::MakeWithCopy(output.get(), decodedLength); |
191 SkMemoryStream* stream = new SkMemoryStream(skData); | 191 SkMemoryStream* stream = new SkMemoryStream(skData); |
192 #if OS(WIN) | 192 #if OS(WIN) |
193 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager()
->createFromStream(stream)); | 193 sk_sp<SkTypeface> typeface(FontCache::fontCache()->fontManager()->createFrom
Stream(stream)); |
194 #else | 194 #else |
195 RefPtr<SkTypeface> typeface = fromSkSp(SkTypeface::MakeFromStream(stream)); | 195 sk_sp<SkTypeface> typeface = SkTypeface::MakeFromStream(stream); |
196 #endif | 196 #endif |
197 if (!typeface) { | 197 if (!typeface) { |
198 setErrorString("Not a valid font data"); | 198 setErrorString("Not a valid font data"); |
199 return nullptr; | 199 return nullptr; |
200 } | 200 } |
201 | 201 |
202 return typeface.release(); | 202 return typeface; |
203 } | 203 } |
204 | 204 |
205 } // namespace blink | 205 } // namespace blink |
OLD | NEW |