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

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 2339273002: SkFontData to use smart pointers. (Closed)
Patch Set: Add trivial bodies to the trivial implementations. 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/SkFontConfigTypeface.h ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 84a74af469b35b81f01d9fb168982065f478092b..71ce865f080c78698f5d61c292ffd4c4aa87fe63 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -234,12 +234,11 @@ struct SkFaceRec {
SkFaceRec* fNext;
FT_Face fFace;
FT_StreamRec fFTStream;
- SkAutoTDelete<SkStreamAsset> fSkStream;
+ std::unique_ptr<SkStreamAsset> fSkStream;
uint32_t fRefCnt;
uint32_t fFontID;
- // assumes ownership of the stream, will delete when its done
- SkFaceRec(SkStreamAsset* strm, uint32_t fontID);
+ SkFaceRec(std::unique_ptr<SkStreamAsset> stream, uint32_t fontID);
};
extern "C" {
@@ -262,12 +261,12 @@ extern "C" {
static void sk_ft_stream_close(FT_Stream) {}
}
-SkFaceRec::SkFaceRec(SkStreamAsset* stream, uint32_t fontID)
- : fNext(nullptr), fSkStream(stream), fRefCnt(1), fFontID(fontID)
+SkFaceRec::SkFaceRec(std::unique_ptr<SkStreamAsset> stream, uint32_t fontID)
+ : fNext(nullptr), fSkStream(std::move(stream)), fRefCnt(1), fFontID(fontID)
{
sk_bzero(&fFTStream, sizeof(fFTStream));
fFTStream.size = fSkStream->getLength();
- fFTStream.descriptor.pointer = fSkStream;
+ fFTStream.descriptor.pointer = fSkStream.get();
fFTStream.read = sk_ft_stream_io;
fFTStream.close = sk_ft_stream_close;
}
@@ -319,12 +318,11 @@ static FT_Face ref_ft_face(const SkTypeface* typeface) {
rec = rec->fNext;
}
- SkAutoTDelete<SkFontData> data(typeface->createFontData());
+ std::unique_ptr<SkFontData> data = typeface->makeFontData();
if (nullptr == data || !data->hasStream()) {
return nullptr;
}
- // this passes ownership of stream to the rec
rec = new SkFaceRec(data->detachStream(), fontID);
FT_Open_Args args;
@@ -1564,7 +1562,7 @@ SkTypeface_FreeType::Scanner::~Scanner() {
}
}
-FT_Face SkTypeface_FreeType::Scanner::openFace(SkStream* stream, int ttcIndex,
+FT_Face SkTypeface_FreeType::Scanner::openFace(SkStreamAsset* stream, int ttcIndex,
FT_Stream ftStream) const
{
if (fLibrary == nullptr) {
@@ -1598,7 +1596,7 @@ FT_Face SkTypeface_FreeType::Scanner::openFace(SkStream* stream, int ttcIndex,
return face;
}
-bool SkTypeface_FreeType::Scanner::recognizedFont(SkStream* stream, int* numFaces) const {
+bool SkTypeface_FreeType::Scanner::recognizedFont(SkStreamAsset* stream, int* numFaces) const {
SkAutoMutexAcquire libraryLock(fLibraryMutex);
FT_StreamRec streamRec;
@@ -1615,7 +1613,7 @@ bool SkTypeface_FreeType::Scanner::recognizedFont(SkStream* stream, int* numFace
#include "SkTSearch.h"
bool SkTypeface_FreeType::Scanner::scanFont(
- SkStream* stream, int ttcIndex,
+ SkStreamAsset* stream, int ttcIndex,
SkString* name, SkFontStyle* style, bool* isFixedPitch, AxisDefinitions* axes) const
{
SkAutoMutexAcquire libraryLock(fLibraryMutex);
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698