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

Side by Side Diff: src/ports/SkFontMgr_android.cpp

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 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/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_android_parser.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 2014 Google Inc. 2 * Copyright 2014 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 "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 continue; 381 continue;
382 } 382 }
383 383
384 SkPaint paint; 384 SkPaint paint;
385 paint.setTypeface(face); 385 paint.setTypeface(face);
386 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); 386 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
387 387
388 uint16_t glyphID; 388 uint16_t glyphID;
389 paint.textToGlyphs(&character, sizeof(character), &glyphID); 389 paint.textToGlyphs(&character, sizeof(character), &glyphID);
390 if (glyphID != 0) { 390 if (glyphID != 0) {
391 return face.detach(); 391 return face.release();
392 } 392 }
393 } 393 }
394 return nullptr; 394 return nullptr;
395 } 395 }
396 396
397 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], 397 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[],
398 const SkFontStyle& style, 398 const SkFontStyle& style,
399 const char* bcp47[], 399 const char* bcp47[],
400 int bcp47Count, 400 int bcp47Count,
401 SkUnichar character) const o verride 401 SkUnichar character) const o verride
(...skipping 29 matching lines...) Expand all
431 } 431 }
432 return nullptr; 432 return nullptr;
433 } 433 }
434 434
435 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { 435 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
436 return this->createFromStream(new SkMemoryStream(data), ttcIndex); 436 return this->createFromStream(new SkMemoryStream(data), ttcIndex);
437 } 437 }
438 438
439 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override { 439 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
440 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); 440 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
441 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr; 441 return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;
442 } 442 }
443 443
444 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons t override { 444 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons t override {
445 SkAutoTDelete<SkStreamAsset> stream(bareStream); 445 SkAutoTDelete<SkStreamAsset> stream(bareStream);
446 bool isFixedPitch; 446 bool isFixedPitch;
447 SkFontStyle style; 447 SkFontStyle style;
448 SkString name; 448 SkString name;
449 if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, n ullptr)) { 449 if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, n ullptr)) {
450 return nullptr; 450 return nullptr;
451 } 451 }
452 SkFontData* data(new SkFontData(stream.detach(), ttcIndex, nullptr, 0)); 452 SkFontData* data(new SkFontData(stream.release(), ttcIndex, nullptr, 0)) ;
453 return new SkTypeface_AndroidStream(data, style, isFixedPitch, name); 453 return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
454 } 454 }
455 455
456 SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& param s) const override { 456 SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& param s) const override {
457 using Scanner = SkTypeface_FreeType::Scanner; 457 using Scanner = SkTypeface_FreeType::Scanner;
458 SkAutoTDelete<SkStreamAsset> stream(s); 458 SkAutoTDelete<SkStreamAsset> stream(s);
459 bool isFixedPitch; 459 bool isFixedPitch;
460 SkFontStyle style; 460 SkFontStyle style;
461 SkString name; 461 SkString name;
462 Scanner::AxisDefinitions axisDefinitions; 462 Scanner::AxisDefinitions axisDefinitions;
463 if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &styl e, &isFixedPitch, 463 if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &styl e, &isFixedPitch,
464 &axisDefinitions)) 464 &axisDefinitions))
465 { 465 {
466 return nullptr; 466 return nullptr;
467 } 467 }
468 468
469 int paramAxisCount; 469 int paramAxisCount;
470 const FontParameters::Axis* paramAxes = params.getAxes(&paramAxisCount); 470 const FontParameters::Axis* paramAxes = params.getAxes(&paramAxisCount);
471 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); 471 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
472 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a xisValues, name); 472 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a xisValues, name);
473 473
474 SkFontData* data(new SkFontData(stream.detach(), params.getCollectionInd ex(), 474 SkFontData* data(new SkFontData(stream.release(), params.getCollectionIn dex(),
475 axisValues.get(), axisDefinitions.count( ))); 475 axisValues.get(), axisDefinitions.count( )));
476 return new SkTypeface_AndroidStream(data, style, isFixedPitch, name); 476 return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
477 } 477 }
478 478
479 SkTypeface* onCreateFromFontData(SkFontData* data) const override { 479 SkTypeface* onCreateFromFontData(SkFontData* data) const override {
480 SkStreamAsset* stream(data->getStream()); 480 SkStreamAsset* stream(data->getStream());
481 bool isFixedPitch; 481 bool isFixedPitch;
482 SkFontStyle style; 482 SkFontStyle style;
483 SkString name; 483 SkString name;
484 if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixed Pitch, nullptr)) { 484 if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixed Pitch, nullptr)) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings)) ; 582 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings)) ;
583 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n" , 583 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n" ,
584 gSystemFontUseStrings[custom->fSystemFontUse], 584 gSystemFontUseStrings[custom->fSystemFontUse],
585 custom->fBasePath, 585 custom->fBasePath,
586 custom->fFontsXml, 586 custom->fFontsXml,
587 custom->fFallbackFontsXml)); 587 custom->fFallbackFontsXml));
588 } 588 }
589 589
590 return new SkFontMgr_Android(custom); 590 return new SkFontMgr_Android(custom);
591 } 591 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_android_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698