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

Unified Diff: src/core/SkFontDescriptor.cpp

Issue 2030683002: Update typeface serialization style. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 6 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/SkTypeface.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 69fdc154326936a56d46b1b1dc00e78f9990d3de..85629efa7ec640bf53d5a6d9533b0916c8d3afd7 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -23,7 +23,7 @@ enum {
kSentinel = 0xFF,
};
-SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fStyle(style) { }
+SkFontDescriptor::SkFontDescriptor() { }
static void read_string(SkStream* stream, SkString* string) {
const uint32_t length = SkToU32(stream->readPackedUInt());
@@ -59,7 +59,15 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) {
}
bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
- result->fStyle = (SkTypeface::Style)stream->readPackedUInt();
+ size_t styleBits = stream->readPackedUInt();
+ if (styleBits <= 2) {
+ // Remove this branch when MIN_PICTURE_VERSION > 45
+ result->fStyle = SkFontStyle::FromOldStyle(styleBits);
+ } else {
+ result->fStyle = SkFontStyle((styleBits >> 16) & 0xFFFF,
+ (styleBits >> 8 ) & 0xFF,
+ static_cast<SkFontStyle::Slant>(styleBits & 0xFF));
+ }
SkAutoSTMalloc<4, SkFixed> axis;
size_t axisCount = 0;
@@ -109,7 +117,8 @@ bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
}
void SkFontDescriptor::serialize(SkWStream* stream) {
- stream->writePackedUInt(fStyle);
+ uint32_t styleBits = (fStyle.weight() << 16) | (fStyle.width() << 8) | (fStyle.slant());
+ stream->writePackedUInt(styleBits);
write_string(stream, fFamilyName, kFontFamilyName);
write_string(stream, fFullName, kFullName);
« no previous file with comments | « src/core/SkFontDescriptor.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698