| Index: src/ports/SkFontMgr_custom.cpp
|
| diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
|
| index 9a8aa4946fcb8cc3f900a16eba1819ab067bdcde..97489de50d6fba69b71303722349a2d304379941 100644
|
| --- a/src/ports/SkFontMgr_custom.cpp
|
| +++ b/src/ports/SkFontMgr_custom.cpp
|
| @@ -10,7 +10,6 @@
|
| #include "SkFontMgr.h"
|
| #include "SkFontMgr_custom.h"
|
| #include "SkFontStyle.h"
|
| -#include "SkMakeUnique.h"
|
| #include "SkOSFile.h"
|
| #include "SkRefCnt.h"
|
| #include "SkStream.h"
|
| @@ -85,15 +84,15 @@
|
| protected:
|
| SkStreamAsset* onOpenStream(int* ttcIndex) const override {
|
| *ttcIndex = fData->getIndex();
|
| - return fData->getStream()->duplicate();
|
| - }
|
| -
|
| - std::unique_ptr<SkFontData> onMakeFontData() const override {
|
| - return skstd::make_unique<SkFontData>(*fData);
|
| - }
|
| -
|
| -private:
|
| - const std::unique_ptr<const SkFontData> fData;
|
| + return fData->duplicateStream();
|
| + }
|
| +
|
| + SkFontData* onCreateFontData() const override {
|
| + return new SkFontData(*fData.get());
|
| + }
|
| +
|
| +private:
|
| + std::unique_ptr<const SkFontData> fData;
|
|
|
| typedef SkTypeface_Custom INHERITED;
|
| };
|
| @@ -110,7 +109,7 @@
|
| protected:
|
| SkStreamAsset* onOpenStream(int* ttcIndex) const override {
|
| *ttcIndex = this->getIndex();
|
| - return SkStream::MakeFromFile(fPath.c_str()).release();
|
| + return SkStream::NewFromFile(fPath.c_str());
|
| }
|
|
|
| private:
|
| @@ -271,13 +270,13 @@
|
|
|
| SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& params) const override {
|
| using Scanner = SkTypeface_FreeType::Scanner;
|
| - std::unique_ptr<SkStreamAsset> stream(s);
|
| + SkAutoTDelete<SkStreamAsset> stream(s);
|
| bool isFixedPitch;
|
| SkFontStyle style;
|
| SkString name;
|
| Scanner::AxisDefinitions axisDefinitions;
|
| - if (!fScanner.scanFont(stream.get(), params.getCollectionIndex(),
|
| - &name, &style, &isFixedPitch, &axisDefinitions))
|
| + if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &style, &isFixedPitch,
|
| + &axisDefinitions))
|
| {
|
| return nullptr;
|
| }
|
| @@ -287,12 +286,13 @@
|
| SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
|
| Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, axisValues, name);
|
|
|
| - auto data = skstd::make_unique<SkFontData>(std::move(stream), params.getCollectionIndex(),
|
| - axisValues.get(), axisDefinitions.count());
|
| + std::unique_ptr<SkFontData> data(new SkFontData(stream.release(),
|
| + params.getCollectionIndex(),
|
| + axisValues.get(), axisDefinitions.count()));
|
| return new SkTypeface_Stream(std::move(data), style, isFixedPitch, false, name);
|
| }
|
|
|
| - SkTypeface* onCreateFromFontData(std::unique_ptr<SkFontData> data) const override {
|
| + SkTypeface* onCreateFromFontData(SkFontData* data) const override {
|
| bool isFixedPitch;
|
| SkFontStyle style;
|
| SkString name;
|
| @@ -301,11 +301,12 @@
|
| {
|
| return nullptr;
|
| }
|
| - return new SkTypeface_Stream(std::move(data), style, isFixedPitch, false, name);
|
| + std::unique_ptr<SkFontData> unique_data(data);
|
| + return new SkTypeface_Stream(std::move(unique_data), style, isFixedPitch, false, name);
|
| }
|
|
|
| SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
|
| - std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(path);
|
| + SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
|
| return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;
|
| }
|
|
|
| @@ -371,14 +372,14 @@
|
|
|
| while (iter.next(&name, false)) {
|
| SkString filename(SkOSPath::Join(directory.c_str(), name.c_str()));
|
| - std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(filename.c_str());
|
| - if (!stream) {
|
| + SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(filename.c_str()));
|
| + if (!stream.get()) {
|
| SkDebugf("---- failed to open <%s>\n", filename.c_str());
|
| continue;
|
| }
|
|
|
| int numFaces;
|
| - if (!scanner.recognizedFont(stream.get(), &numFaces)) {
|
| + if (!scanner.recognizedFont(stream, &numFaces)) {
|
| SkDebugf("---- failed to open <%s> as a font\n", filename.c_str());
|
| continue;
|
| }
|
| @@ -387,9 +388,7 @@
|
| bool isFixedPitch;
|
| SkString realname;
|
| SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
|
| - if (!scanner.scanFont(stream.get(), faceIndex,
|
| - &realname, &style, &isFixedPitch, nullptr))
|
| - {
|
| + if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, nullptr)) {
|
| SkDebugf("---- failed to open <%s> <%d> as a font\n",
|
| filename.c_str(), faceIndex);
|
| continue;
|
| @@ -463,10 +462,10 @@
|
| const uint8_t* data, size_t size, int index,
|
| SkFontMgr_Custom::Families* families)
|
| {
|
| - auto stream = skstd::make_unique<SkMemoryStream>(data, size, false);
|
| + SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(data, size, false));
|
|
|
| int numFaces;
|
| - if (!scanner.recognizedFont(stream.get(), &numFaces)) {
|
| + if (!scanner.recognizedFont(stream, &numFaces)) {
|
| SkDebugf("---- failed to open <%d> as a font\n", index);
|
| return;
|
| }
|
| @@ -475,9 +474,7 @@
|
| bool isFixedPitch;
|
| SkString realname;
|
| SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
|
| - if (!scanner.scanFont(stream.get(), faceIndex,
|
| - &realname, &style, &isFixedPitch, nullptr))
|
| - {
|
| + if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, nullptr)) {
|
| SkDebugf("---- failed to open <%d> <%d> as a font\n", index, faceIndex);
|
| return;
|
| }
|
| @@ -487,7 +484,8 @@
|
| addTo = new SkFontStyleSet_Custom(realname);
|
| families->push_back().reset(addTo);
|
| }
|
| - auto data = skstd::make_unique<SkFontData>(std::move(stream), faceIndex, nullptr, 0);
|
| + std::unique_ptr<SkFontData> data(
|
| + new SkFontData(stream.release(), faceIndex, nullptr, 0));
|
| addTo->appendTypeface(sk_make_sp<SkTypeface_Stream>(std::move(data),
|
| style, isFixedPitch,
|
| true, realname));
|
|
|