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

Unified Diff: src/pdf/SkPDFFont.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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
Index: src/pdf/SkPDFFont.cpp
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 2fc408efc7fa735cf73d7b7df9caf40a81341cd9..0481963029f81781c71129a6b3b9431c5f1359df 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -152,8 +152,8 @@ int8_t hexToBin(uint8_t c) {
return -1;
}
-static SkData* handle_type1_stream(SkStream* srcStream, size_t* headerLen,
- size_t* dataLen, size_t* trailerLen) {
+static sk_sp<SkData> handle_type1_stream(SkStream* srcStream, size_t* headerLen,
+ size_t* dataLen, size_t* trailerLen) {
// srcStream may be backed by a file or a unseekable fd, so we may not be
// able to use skip(), rewind(), or getMemoryBase(). read()ing through
// the input only once is doable, but very ugly. Furthermore, it'd be nice
@@ -161,7 +161,7 @@ static SkData* handle_type1_stream(SkStream* srcStream, size_t* headerLen,
// Make as few copies as possible given these constraints.
SkDynamicMemoryWStream dynamicStream;
std::unique_ptr<SkMemoryStream> staticStream;
- SkData* data = nullptr;
+ sk_sp<SkData> data;
const uint8_t* src;
size_t srcLen;
if ((srcLen = srcStream->getLength()) > 0) {
@@ -191,22 +191,18 @@ static SkData* handle_type1_stream(SkStream* srcStream, size_t* headerLen,
}
amount = 0;
dynamicStream.write(&amount, 1); // nullptr terminator.
- data = dynamicStream.copyToData();
+ data.reset(dynamicStream.copyToData());
src = data->bytes();
srcLen = data->size() - 1;
}
- // this handles releasing the data we may have gotten from dynamicStream.
- // if data is null, it is a no-op
- SkAutoDataUnref aud(data);
-
if (parsePFB(src, srcLen, headerLen, dataLen, trailerLen)) {
static const int kPFBSectionHeaderLength = 6;
const size_t length = *headerLen + *dataLen + *trailerLen;
SkASSERT(length > 0);
SkASSERT(length + (2 * kPFBSectionHeaderLength) <= srcLen);
- SkData* data = SkData::NewUninitialized(length);
+ sk_sp<SkData> data(SkData::MakeUninitialized(length));
const uint8_t* const srcHeader = src + kPFBSectionHeaderLength;
// There is a six-byte section header before header and data
@@ -265,7 +261,7 @@ static SkData* handle_type1_stream(SkStream* srcStream, size_t* headerLen,
uint8_t* const resultTrailer = &(buffer[SkToInt(*headerLen + outputOffset)]);
memcpy(resultTrailer, src + *headerLen + hexDataLen, *trailerLen);
- return SkData::NewFromMalloc(buffer.release(), length);
+ return SkData::MakeFromMalloc(buffer.release(), length);
}
return nullptr;
}
@@ -1191,8 +1187,7 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) {
if (!rawFontData || 0 == rawFontData->getLength()) {
return false;
}
- sk_sp<SkData> fontData(handle_type1_stream(rawFontData.get(), &header,
- &data, &trailer));
+ sk_sp<SkData> fontData(handle_type1_stream(rawFontData.get(), &header, &data, &trailer));
if (fontData.get() == nullptr) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698