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

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 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
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return NULL; 301 return NULL;
302 } 302 }
303 if (length >= 1024 * 1024 * 1024) { 303 if (length >= 1024 * 1024 * 1024) {
304 return NULL; // don't accept too large fonts (>= 1GB) for safety. 304 return NULL; // don't accept too large fonts (>= 1GB) for safety.
305 } 305 }
306 306
307 // TODO should the caller give us the style or should we get it from fre etype? 307 // TODO should the caller give us the style or should we get it from fre etype?
308 SkFontStyle style; 308 SkFontStyle style;
309 bool isFixedWidth = false; 309 bool isFixedWidth = false;
310 if (!fScanner.scanFont(stream, 0, NULL, &style, &isFixedWidth)) { 310 if (!fScanner.scanFont(stream, 0, NULL, &style, &isFixedWidth)) {
311 return NULL; 311 return NULL;
bungeman-skia 2015/01/20 21:41:48 Looks like we need to delete the stream here?
scroggo 2015/01/20 22:19:09 Done with SkAutoTDelete.
312 } 312 }
313 313
314 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea m); 314 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea m);
315 return face; 315 return face;
316 } 316 }
317 317
318 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE { 318 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE {
319 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 319 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
bungeman-skia 2015/01/20 21:41:48 I don't think this guy should be deleting the stre
scroggo 2015/01/20 22:19:09 Done.
320 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; 320 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL;
321 } 321 }
322 322
323 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 323 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
324 unsigned styleBits) const SK_OVER RIDE { 324 unsigned styleBits) const SK_OVER RIDE {
325 FCLocker lock; 325 FCLocker lock;
326 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName, 326 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName,
327 (SkTypeface::Style)styleBits); 327 (SkTypeface::Style)styleBits);
328 } 328 }
329 }; 329 };
330 330
331 SkFontMgr* SkFontMgr::Factory() { 331 SkFontMgr* SkFontMgr::Factory() {
332 SkFontConfigInterface* fci = RefFCI(); 332 SkFontConfigInterface* fci = RefFCI();
333 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; 333 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
334 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698