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

Unified Diff: src/core/SkFontDescriptor.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/core/SkFontDescriptor.h ('k') | src/core/SkFontMgr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontDescriptor.cpp
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp
index 85629efa7ec640bf53d5a6d9533b0916c8d3afd7..73ea2058ce79c618022334b970b6d702035e3f67 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -6,6 +6,7 @@
*/
#include "SkFontDescriptor.h"
+#include "SkMakeUnique.h"
#include "SkStream.h"
#include "SkData.h"
@@ -106,8 +107,8 @@ bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
if (length > 0) {
sk_sp<SkData> data(SkData::MakeUninitialized(length));
if (stream->read(data->writable_data(), length) == length) {
- result->fFontData.reset(new SkFontData(new SkMemoryStream(data),
- index, axis, axisCount));
+ result->fFontData = skstd::make_unique<SkFontData>(
+ skstd::make_unique<SkMemoryStream>(data), index, axis, axisCount);
} else {
SkDEBUGFAIL("Could not read font data");
return false;
@@ -138,10 +139,10 @@ void SkFontDescriptor::serialize(SkWStream* stream) {
stream->writePackedUInt(kSentinel);
if (fFontData.get() && fFontData->hasStream()) {
- SkAutoTDelete<SkStreamAsset> fontData(fFontData->detachStream());
- size_t length = fontData->getLength();
+ std::unique_ptr<SkStreamAsset> fontStream = fFontData->detachStream();
+ size_t length = fontStream->getLength();
stream->writePackedUInt(length);
- stream->writeStream(fontData, length);
+ stream->writeStream(fontStream.get(), length);
} else {
stream->writePackedUInt(0);
}
« no previous file with comments | « src/core/SkFontDescriptor.h ('k') | src/core/SkFontMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698