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

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 2343933002: Revert of SkFontData to use smart pointers. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 7d1ef750bd5d3f74336fe7e0a14d25c942103f53..0c2e5c26281851030e53f41930f3406722310c90 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -28,7 +28,6 @@
#include "SkFontDescriptor.h"
#include "SkFontMgr.h"
#include "SkGlyph.h"
-#include "SkMakeUnique.h"
#include "SkMaskGamma.h"
#include "SkMathPriv.h"
#include "SkMutex.h"
@@ -512,7 +511,7 @@
protected:
int onGetUPEM() const override;
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
- std::unique_ptr<SkFontData> onMakeFontData() const override;
+ SkFontData* onCreateFontData() const override;
void onGetFamilyName(SkString* familyName) const override;
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
int onGetTableTags(SkFontTableTag tags[]) const override;
@@ -1886,17 +1885,16 @@
return true;
}
-std::unique_ptr<SkFontData> SkTypeface_Mac::onMakeFontData() const {
+SkFontData* SkTypeface_Mac::onCreateFontData() const {
int index;
- std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
+ SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
CFIndex cgAxisCount;
SkAutoSTMalloc<4, SkFixed> axisValues;
if (get_variations(fFontRef, &cgAxisCount, &axisValues)) {
- return skstd::make_unique<SkFontData>(std::move(stream), index,
- axisValues.get(), cgAxisCount);
- }
- return skstd::make_unique<SkFontData>(std::move(stream), index, nullptr, 0);
+ return new SkFontData(stream.release(), index, axisValues.get(), cgAxisCount);
+ }
+ return new SkFontData(stream.release(), index, nullptr, 0);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2369,16 +2367,15 @@
}
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
- AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(sk_ref_sp(data)));
+ AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
if (nullptr == pr) {
return nullptr;
}
return create_from_dataProvider(pr);
}
- SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
- std::unique_ptr<SkStreamAsset> stream(bareStream);
- AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(std::move(stream)));
+ SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override {
+ AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
if (nullptr == pr) {
return nullptr;
}
@@ -2496,9 +2493,8 @@
}
return dict;
}
- SkTypeface* onCreateFromStream(SkStreamAsset* bs, const FontParameters& params) const override {
- std::unique_ptr<SkStreamAsset> s(bs);
- AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(std::move(s)));
+ SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& params) const override {
+ AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(s));
if (nullptr == provider) {
return nullptr;
}
@@ -2578,9 +2574,10 @@
}
return dict;
}
- SkTypeface* onCreateFromFontData(std::unique_ptr<SkFontData> fontData) const override {
- AutoCFRelease<CGDataProviderRef> provider(
- SkCreateDataProviderFromStream(fontData->detachStream()));
+ SkTypeface* onCreateFromFontData(SkFontData* data) const override {
+ SkAutoTDelete<SkFontData> fontData(data);
+ SkStreamAsset* stream = fontData->detachStream();
+ AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(stream));
if (nullptr == provider) {
return nullptr;
}
@@ -2589,7 +2586,7 @@
return nullptr;
}
- AutoCFRelease<CFDictionaryRef> cgVariations(get_axes(cg, fontData.get()));
+ AutoCFRelease<CFDictionaryRef> cgVariations(get_axes(cg, fontData));
// 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.
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698