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

Unified Diff: src/ports/SkFontHost_FreeType.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/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 71ce865f080c78698f5d61c292ffd4c4aa87fe63..84a74af469b35b81f01d9fb168982065f478092b 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -234,11 +234,12 @@
SkFaceRec* fNext;
FT_Face fFace;
FT_StreamRec fFTStream;
- std::unique_ptr<SkStreamAsset> fSkStream;
+ SkAutoTDelete<SkStreamAsset> fSkStream;
uint32_t fRefCnt;
uint32_t fFontID;
- SkFaceRec(std::unique_ptr<SkStreamAsset> stream, uint32_t fontID);
+ // assumes ownership of the stream, will delete when its done
+ SkFaceRec(SkStreamAsset* strm, uint32_t fontID);
};
extern "C" {
@@ -261,12 +262,12 @@
static void sk_ft_stream_close(FT_Stream) {}
}
-SkFaceRec::SkFaceRec(std::unique_ptr<SkStreamAsset> stream, uint32_t fontID)
- : fNext(nullptr), fSkStream(std::move(stream)), fRefCnt(1), fFontID(fontID)
+SkFaceRec::SkFaceRec(SkStreamAsset* stream, uint32_t fontID)
+ : fNext(nullptr), fSkStream(stream), fRefCnt(1), fFontID(fontID)
{
sk_bzero(&fFTStream, sizeof(fFTStream));
fFTStream.size = fSkStream->getLength();
- fFTStream.descriptor.pointer = fSkStream.get();
+ fFTStream.descriptor.pointer = fSkStream;
fFTStream.read = sk_ft_stream_io;
fFTStream.close = sk_ft_stream_close;
}
@@ -318,11 +319,12 @@
rec = rec->fNext;
}
- std::unique_ptr<SkFontData> data = typeface->makeFontData();
+ SkAutoTDelete<SkFontData> data(typeface->createFontData());
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;
@@ -1562,7 +1564,7 @@
}
}
-FT_Face SkTypeface_FreeType::Scanner::openFace(SkStreamAsset* stream, int ttcIndex,
+FT_Face SkTypeface_FreeType::Scanner::openFace(SkStream* stream, int ttcIndex,
FT_Stream ftStream) const
{
if (fLibrary == nullptr) {
@@ -1596,7 +1598,7 @@
return face;
}
-bool SkTypeface_FreeType::Scanner::recognizedFont(SkStreamAsset* stream, int* numFaces) const {
+bool SkTypeface_FreeType::Scanner::recognizedFont(SkStream* stream, int* numFaces) const {
SkAutoMutexAcquire libraryLock(fLibraryMutex);
FT_StreamRec streamRec;
@@ -1613,7 +1615,7 @@
#include "SkTSearch.h"
bool SkTypeface_FreeType::Scanner::scanFont(
- SkStreamAsset* stream, int ttcIndex,
+ SkStream* 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