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

Unified Diff: src/ports/SkFontMgr_FontConfigInterface.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_win.cpp ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_FontConfigInterface.cpp
diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp
index a6a055a9d2f24f4aa7723a2797fae5df460e8661..c432a6b93fe61388dd531993295bf201bdf46c47 100644
--- a/src/ports/SkFontMgr_FontConfigInterface.cpp
+++ b/src/ports/SkFontMgr_FontConfigInterface.cpp
@@ -10,7 +10,6 @@
#include "SkFontDescriptor.h"
#include "SkFontMgr.h"
#include "SkFontStyle.h"
-#include "SkMakeUnique.h"
#include "SkMutex.h"
#include "SkString.h"
#include "SkTypeface.h"
@@ -31,14 +30,13 @@
return fFCI->openStream(this->getIdentity());
}
-std::unique_ptr<SkFontData> SkTypeface_FCI::onMakeFontData() const {
+SkFontData* SkTypeface_FCI::onCreateFontData() const {
if (fFontData) {
- return skstd::make_unique<SkFontData>(*fFontData);
+ return new SkFontData(*fFontData.get());
}
const SkFontConfigInterface::FontIdentity& id = this->getIdentity();
- return skstd::make_unique<SkFontData>(std::unique_ptr<SkStreamAsset>(fFCI->openStream(id)),
- id.fTTCIndex, nullptr, 0);
+ return new SkFontData( fFCI->openStream(id), id.fTTCIndex, nullptr, 0);
}
void SkTypeface_FCI::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocalStream) const {
@@ -201,7 +199,7 @@
SkTypeface* onCreateFromData(SkData*, int ttcIndex) const override { return nullptr; }
SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
- std::unique_ptr<SkStreamAsset> stream(bareStream);
+ SkAutoTDelete<SkStreamAsset> stream(bareStream);
const size_t length = stream->getLength();
if (!length) {
return nullptr;
@@ -213,17 +211,18 @@
// TODO should the caller give us the style or should we get it from freetype?
SkFontStyle style;
bool isFixedPitch = false;
- if (!fScanner.scanFont(stream.get(), 0, nullptr, &style, &isFixedPitch, nullptr)) {
- return nullptr;
- }
-
- auto fontData = skstd::make_unique<SkFontData>(std::move(stream), ttcIndex, nullptr, 0);
+ if (!fScanner.scanFont(stream, 0, nullptr, &style, &isFixedPitch, nullptr)) {
+ return nullptr;
+ }
+
+ std::unique_ptr<SkFontData> fontData(new SkFontData(stream.release(), ttcIndex,
+ nullptr, 0));
return SkTypeface_FCI::Create(std::move(fontData), style, isFixedPitch);
}
SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& params) const override {
using Scanner = SkTypeface_FreeType::Scanner;
- std::unique_ptr<SkStreamAsset> stream(s);
+ SkAutoTDelete<SkStreamAsset> stream(s);
const size_t length = stream->getLength();
if (!length) {
return nullptr;
@@ -236,8 +235,8 @@
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;
}
@@ -247,15 +246,15 @@
SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, axisValues, name);
- auto fontData = skstd::make_unique<SkFontData>(std::move(stream),
- params.getCollectionIndex(),
- axisValues.get(),
- axisDefinitions.count());
+ std::unique_ptr<SkFontData> fontData(new SkFontData(stream.release(),
+ params.getCollectionIndex(),
+ axisValues.get(),
+ axisDefinitions.count()));
return SkTypeface_FCI::Create(std::move(fontData), style, isFixedPitch);
}
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;
}
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698