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

Side by Side Diff: src/fonts/SkFontMgr_fontconfig.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 months 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
« no previous file with comments | « src/device/xps/SkXPSDevice.cpp ('k') | src/fonts/SkFontMgr_indirect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkFontMgr.h" 8 #include "SkFontMgr.h"
9 #include "SkFontStyle.h" 9 #include "SkFontStyle.h"
10 #include "SkFontConfigInterface.h" 10 #include "SkFontConfigInterface.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const char* bcp47[], int bcp 47Count, 289 const char* bcp47[], int bcp 47Count,
290 SkUnichar character) const S K_OVERRIDE { 290 SkUnichar character) const S K_OVERRIDE {
291 return NULL; 291 return NULL;
292 } 292 }
293 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, 293 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
294 const SkFontStyle&) const SK_OVERRIDE { return NULL; } 294 const SkFontStyle&) const SK_OVERRIDE { return NULL; }
295 295
296 SkTypeface* onCreateFromData(SkData*, int ttcIndex) const SK_OVERRIDE { retu rn NULL; } 296 SkTypeface* onCreateFromData(SkData*, int ttcIndex) const SK_OVERRIDE { retu rn NULL; }
297 297
298 SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER RIDE { 298 SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER RIDE {
299 SkAutoTDelete<SkStream> streamDeleter(stream);
299 const size_t length = stream->getLength(); 300 const size_t length = stream->getLength();
300 if (!length) { 301 if (!length) {
301 return NULL; 302 return NULL;
302 } 303 }
303 if (length >= 1024 * 1024 * 1024) { 304 if (length >= 1024 * 1024 * 1024) {
304 return NULL; // don't accept too large fonts (>= 1GB) for safety. 305 return NULL; // don't accept too large fonts (>= 1GB) for safety.
305 } 306 }
306 307
307 // TODO should the caller give us the style or should we get it from fre etype? 308 // TODO should the caller give us the style or should we get it from fre etype?
308 SkFontStyle style; 309 SkFontStyle style;
309 bool isFixedWidth = false; 310 bool isFixedWidth = false;
310 if (!fScanner.scanFont(stream, 0, NULL, &style, &isFixedWidth)) { 311 if (!fScanner.scanFont(stream, 0, NULL, &style, &isFixedWidth)) {
311 return NULL; 312 return NULL;
312 } 313 }
313 314
314 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea m); 315 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea mDeleter.detach());
315 return face; 316 return face;
316 } 317 }
317 318
318 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE { 319 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE {
319 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 320 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
320 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; 321 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL;
321 } 322 }
322 323
323 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 324 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
324 unsigned styleBits) const SK_OVER RIDE { 325 unsigned styleBits) const SK_OVER RIDE {
325 FCLocker lock; 326 FCLocker lock;
326 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName, 327 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName,
327 (SkTypeface::Style)styleBits); 328 (SkTypeface::Style)styleBits);
328 } 329 }
329 }; 330 };
330 331
331 SkFontMgr* SkFontMgr::Factory() { 332 SkFontMgr* SkFontMgr::Factory() {
332 SkFontConfigInterface* fci = RefFCI(); 333 SkFontConfigInterface* fci = RefFCI();
333 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; 334 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
334 } 335 }
OLDNEW
« no previous file with comments | « src/device/xps/SkXPSDevice.cpp ('k') | src/fonts/SkFontMgr_indirect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698