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

Unified Diff: src/core/SkTypeface.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/core/SkStream.cpp ('k') | src/images/SkMovie.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 3c4f5cb7e7929eb856f35713437ff4450ba52777..0c960d591510a4b7992164208ac985587ec8b482 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -9,7 +9,6 @@
#include "SkEndian.h"
#include "SkFontDescriptor.h"
#include "SkFontMgr.h"
-#include "SkMakeUnique.h"
#include "SkMutex.h"
#include "SkOTTable_OS_2.h"
#include "SkOnce.h"
@@ -151,9 +150,9 @@
return sk_sp<SkTypeface>(fm->createFromStream(stream, index));
}
-sk_sp<SkTypeface> SkTypeface::MakeFromFontData(std::unique_ptr<SkFontData> data) {
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->createFromFontData(std::move(data)));
+sk_sp<SkTypeface> SkTypeface::MakeFromFontData(SkFontData* data) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return sk_sp<SkTypeface>(fm->createFromFontData(data));
}
sk_sp<SkTypeface> SkTypeface::MakeFromFile(const char path[], int index) {
@@ -174,7 +173,7 @@
// Embed font data if it's a local font.
if (isLocal && !desc.hasFontData()) {
- desc.setFontData(this->onMakeFontData());
+ desc.setFontData(this->onCreateFontData());
}
desc.serialize(wstream);
}
@@ -189,9 +188,9 @@
return nullptr;
}
- std::unique_ptr<SkFontData> data = desc.detachFontData();
+ SkFontData* data = desc.detachFontData();
if (data) {
- sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(std::move(data)));
+ sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(data));
if (typeface) {
return typeface;
}
@@ -228,15 +227,15 @@
return this->onOpenStream(ttcIndex);
}
-std::unique_ptr<SkFontData> SkTypeface::makeFontData() const {
- return this->onMakeFontData();
+SkFontData* SkTypeface::createFontData() const {
+ return this->onCreateFontData();
}
// This implementation is temporary until this method can be made pure virtual.
-std::unique_ptr<SkFontData> SkTypeface::onMakeFontData() const {
+SkFontData* SkTypeface::onCreateFontData() const {
int index;
- std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
- return skstd::make_unique<SkFontData>(std::move(stream), index, nullptr, 0);
+ SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
+ return new SkFontData(stream.release(), index, nullptr, 0);
};
int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,
« no previous file with comments | « src/core/SkStream.cpp ('k') | src/images/SkMovie.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698