aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_mac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ports/SkFontHost_mac.cpp')
-rw-r--r--src/ports/SkFontHost_mac.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 0c2e5c2628..7d1ef750bd 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -28,6 +28,7 @@
#include "SkFontDescriptor.h"
#include "SkFontMgr.h"
#include "SkGlyph.h"
+#include "SkMakeUnique.h"
#include "SkMaskGamma.h"
#include "SkMathPriv.h"
#include "SkMutex.h"
@@ -511,7 +512,7 @@ public:
protected:
int onGetUPEM() const override;
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
- SkFontData* onCreateFontData() const override;
+ std::unique_ptr<SkFontData> onMakeFontData() const override;
void onGetFamilyName(SkString* familyName) const override;
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
int onGetTableTags(SkFontTableTag tags[]) const override;
@@ -1885,16 +1886,17 @@ static bool get_variations(CTFontRef fFontRef, CFIndex* cgAxisCount,
return true;
}
-SkFontData* SkTypeface_Mac::onCreateFontData() const {
+std::unique_ptr<SkFontData> SkTypeface_Mac::onMakeFontData() const {
int index;
- SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
+ std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
CFIndex cgAxisCount;
SkAutoSTMalloc<4, SkFixed> axisValues;
if (get_variations(fFontRef, &cgAxisCount, &axisValues)) {
- return new SkFontData(stream.release(), index, axisValues.get(), cgAxisCount);
+ return skstd::make_unique<SkFontData>(std::move(stream), index,
+ axisValues.get(), cgAxisCount);
}
- return new SkFontData(stream.release(), index, nullptr, 0);
+ return skstd::make_unique<SkFontData>(std::move(stream), index, nullptr, 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2367,15 +2369,16 @@ protected:
}
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
- AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
+ AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(sk_ref_sp(data)));
if (nullptr == pr) {
return nullptr;
}
return create_from_dataProvider(pr);
}
- SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override {
- AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
+ SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
+ std::unique_ptr<SkStreamAsset> stream(bareStream);
+ AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(std::move(stream)));
if (nullptr == pr) {
return nullptr;
}
@@ -2493,8 +2496,9 @@ protected:
}
return dict;
}
- SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& params) const override {
- AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(s));
+ SkTypeface* onCreateFromStream(SkStreamAsset* bs, const FontParameters& params) const override {
+ std::unique_ptr<SkStreamAsset> s(bs);
+ AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(std::move(s)));
if (nullptr == provider) {
return nullptr;
}
@@ -2574,10 +2578,9 @@ protected:
}
return dict;
}
- SkTypeface* onCreateFromFontData(SkFontData* data) const override {
- SkAutoTDelete<SkFontData> fontData(data);
- SkStreamAsset* stream = fontData->detachStream();
- AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(stream));
+ SkTypeface* onCreateFromFontData(std::unique_ptr<SkFontData> fontData) const override {
+ AutoCFRelease<CGDataProviderRef> provider(
+ SkCreateDataProviderFromStream(fontData->detachStream()));
if (nullptr == provider) {
return nullptr;
}
@@ -2586,7 +2589,7 @@ protected:
return nullptr;
}
- AutoCFRelease<CFDictionaryRef> cgVariations(get_axes(cg, fontData));
+ AutoCFRelease<CFDictionaryRef> cgVariations(get_axes(cg, fontData.get()));
// The CGFontRef returned by CGFontCreateCopyWithVariations when the passed CGFontRef was
// created from a data provider does not appear to have any ownership of the underlying
// data. The original CGFontRef must be kept alive until the copy will no longer be used.