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

Unified Diff: src/ports/SkFontMgr_fontconfig.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/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_fontconfig.cpp
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 1e17cb67747fec7bacda2ee6eb877951ec92513b..5cfd81e411eca1f81bea113bd5e99ba1f4bbb3a7 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -12,7 +12,6 @@
#include "SkFontHost_FreeType_common.h"
#include "SkFontMgr.h"
#include "SkFontStyle.h"
-#include "SkMakeUnique.h"
#include "SkMath.h"
#include "SkMutex.h"
#include "SkOSFile.h"
@@ -406,9 +405,9 @@
class SkTypeface_stream : public SkTypeface_FreeType {
public:
/** @param data takes ownership of the font data.*/
- SkTypeface_stream(std::unique_ptr<SkFontData> data, const SkFontStyle& style, bool fixedWidth)
+ SkTypeface_stream(SkFontData* data, const SkFontStyle& style, bool fixedWidth)
: INHERITED(style, fixedWidth)
- , fData(std::move(data))
+ , fData(data)
{ };
void onGetFamilyName(SkString* familyName) const override {
@@ -421,15 +420,15 @@
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);
+ return fData->duplicateStream();
+ }
+
+ SkFontData* onCreateFontData() const override {
+ return new SkFontData(*fData.get());
}
private:
- const std::unique_ptr<const SkFontData> fData;
+ const SkAutoTDelete<const SkFontData> fData;
typedef SkTypeface_FreeType INHERITED;
};
@@ -458,7 +457,7 @@
SkStreamAsset* onOpenStream(int* ttcIndex) const override {
FCLocker lock;
*ttcIndex = get_int(fPattern, FC_INDEX, 0);
- return SkStream::MakeFromFile(get_string(fPattern, FC_FILE)).release();
+ return SkStream::NewFromFile(get_string(fPattern, FC_FILE));
}
void onFilterRec(SkScalerContextRec* rec) const override {
@@ -879,7 +878,7 @@
}
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 <= 0 || (1u << 30) < length) {
return nullptr;
@@ -887,23 +886,23 @@
SkFontStyle style;
bool isFixedWidth = false;
- if (!fScanner.scanFont(stream.get(), ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) {
+ if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) {
return nullptr;
}
- auto data = skstd::make_unique<SkFontData>(std::move(stream), ttcIndex, nullptr, 0);
- return new SkTypeface_stream(std::move(data), style, isFixedWidth);
+ return new SkTypeface_stream(new SkFontData(stream.release(), ttcIndex, nullptr, 0), style,
+ isFixedWidth);
}
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;
}
@@ -913,9 +912,9 @@
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());
- return new SkTypeface_stream(std::move(data), style, isFixedPitch);
+ SkFontData* data(new SkFontData(stream.release(), params.getCollectionIndex(),
+ axisValues.get(), axisDefinitions.count()));
+ return new SkTypeface_stream(data, style, isFixedPitch);
}
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
@@ -923,10 +922,10 @@
}
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
- return this->createFromStream(SkStream::MakeFromFile(path).release(), ttcIndex);
- }
-
- SkTypeface* onCreateFromFontData(std::unique_ptr<SkFontData> fontData) const override {
+ return this->createFromStream(SkStream::NewFromFile(path), ttcIndex);
+ }
+
+ SkTypeface* onCreateFromFontData(SkFontData* fontData) const override {
SkStreamAsset* stream(fontData->getStream());
const size_t length = stream->getLength();
if (length <= 0 || (1u << 30) < length) {
@@ -940,7 +939,7 @@
return nullptr;
}
- return new SkTypeface_stream(std::move(fontData), style, isFixedWidth);
+ return new SkTypeface_stream(fontData, style, isFixedWidth);
}
SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle style) const override {
« no previous file with comments | « src/ports/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698