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

Unified Diff: src/core/SkFontDescriptor.cpp

Issue 1732263003: Make skpinfo able to inspect SK_PICT_TYPEFACE_TAG blocks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review issues Created 4 years, 10 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/SkPaint.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 8348d5fdba44ce16451964eb43fc31e9fc40f886..f477a2d69546efc15a52ecc7805b8163f209cf08 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -58,8 +58,8 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) {
stream->writePackedUInt(n);
}
-SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
- fStyle = (SkTypeface::Style)stream->readPackedUInt();
+bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
+ result->fStyle = (SkTypeface::Style)stream->readPackedUInt();
SkAutoSTMalloc<4, SkFixed> axis;
size_t axisCount = 0;
@@ -67,13 +67,13 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
for (size_t id; (id = stream->readPackedUInt()) != kSentinel;) {
switch (id) {
case kFontFamilyName:
- read_string(stream, &fFamilyName);
+ read_string(stream, &result->fFamilyName);
break;
case kFullName:
- read_string(stream, &fFullName);
+ read_string(stream, &result->fFullName);
break;
case kPostscriptName:
- read_string(stream, &fPostscriptName);
+ read_string(stream, &result->fPostscriptName);
break;
case kFontAxes:
axisCount = read_uint(stream);
@@ -90,7 +90,7 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
break;
default:
SkDEBUGFAIL("Unknown id used by a font descriptor");
- return;
+ return false;
}
}
@@ -98,9 +98,14 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
if (length > 0) {
SkAutoTUnref<SkData> data(SkData::NewUninitialized(length));
if (stream->read(data->writable_data(), length) == length) {
- fFontData.reset(new SkFontData(new SkMemoryStream(data), index, axis, axisCount));
+ result->fFontData.reset(new SkFontData(new SkMemoryStream(data),
+ index, axis, axisCount));
+ } else {
+ SkDEBUGFAIL("Could not read font data");
+ return false;
}
}
+ return true;
}
void SkFontDescriptor::serialize(SkWStream* stream) {
« no previous file with comments | « src/core/SkFontDescriptor.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698