Revert of Update typeface serialization style. (patchset #3 id:40001 of https://codereview.chromium.org/2030683002/ )
Reason for revert: serialize-8888 broken for typefacestyles on Mac. (Bold weighting goes missing.) Original issue's description: > Update typeface serialization style. > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2030683002 > > Committed: https://skia.googlesource.com/skia/+/7ae1c72e593823e6e300e4199558555765bcec17 TBR=reed@google.com,bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2067583002
This commit is contained in:
parent
be36d59e66
commit
f8f9c07c28
@ -219,10 +219,7 @@ private:
|
||||
|
||||
static_assert(MIN_PICTURE_VERSION <= 43,
|
||||
"Remove SkBitmapSourceDeserializer.");
|
||||
|
||||
static_assert(MIN_PICTURE_VERSION <= 45,
|
||||
"Remove decoding of old SkTypeface::Style from SkFontDescriptor.cpp.");
|
||||
|
||||
|
||||
static bool IsValidPictInfo(const SkPictInfo& info);
|
||||
static sk_sp<SkPicture> Forwardport(const SkPictInfo&,
|
||||
const SkPictureData*,
|
||||
|
@ -23,7 +23,7 @@ enum {
|
||||
kSentinel = 0xFF,
|
||||
};
|
||||
|
||||
SkFontDescriptor::SkFontDescriptor() { }
|
||||
SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fStyle(style) { }
|
||||
|
||||
static void read_string(SkStream* stream, SkString* string) {
|
||||
const uint32_t length = SkToU32(stream->readPackedUInt());
|
||||
@ -59,15 +59,7 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) {
|
||||
}
|
||||
|
||||
bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
|
||||
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));
|
||||
}
|
||||
result->fStyle = (SkTypeface::Style)stream->readPackedUInt();
|
||||
|
||||
SkAutoSTMalloc<4, SkFixed> axis;
|
||||
size_t axisCount = 0;
|
||||
@ -117,8 +109,7 @@ bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
|
||||
}
|
||||
|
||||
void SkFontDescriptor::serialize(SkWStream* stream) {
|
||||
uint32_t styleBits = (fStyle.weight() << 16) | (fStyle.width() << 8) | (fStyle.slant());
|
||||
stream->writePackedUInt(styleBits);
|
||||
stream->writePackedUInt(fStyle);
|
||||
|
||||
write_string(stream, fFamilyName, kFontFamilyName);
|
||||
write_string(stream, fFullName, kFullName);
|
||||
|
@ -50,14 +50,14 @@ private:
|
||||
|
||||
class SkFontDescriptor : SkNoncopyable {
|
||||
public:
|
||||
SkFontDescriptor();
|
||||
SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal);
|
||||
// Does not affect ownership of SkStream.
|
||||
static bool Deserialize(SkStream*, SkFontDescriptor* result);
|
||||
|
||||
void serialize(SkWStream*);
|
||||
|
||||
SkFontStyle getStyle() { return fStyle; }
|
||||
void setStyle(SkFontStyle style) { fStyle = style; }
|
||||
SkTypeface::Style getStyle() { return fStyle; }
|
||||
void setStyle(SkTypeface::Style style) { fStyle = style; }
|
||||
|
||||
const char* getFamilyName() const { return fFamilyName.c_str(); }
|
||||
const char* getFullName() const { return fFullName.c_str(); }
|
||||
@ -78,7 +78,7 @@ private:
|
||||
SkString fPostscriptName;
|
||||
SkAutoTDelete<SkFontData> fFontData;
|
||||
|
||||
SkFontStyle fStyle;
|
||||
SkTypeface::Style fStyle;
|
||||
};
|
||||
|
||||
#endif // SkFontDescriptor_DEFINED
|
||||
|
@ -167,7 +167,7 @@ void SkTypeface::serialize(SkWStream* wstream) const {
|
||||
return;
|
||||
}
|
||||
bool isLocal = false;
|
||||
SkFontDescriptor desc;
|
||||
SkFontDescriptor desc(this->style());
|
||||
this->onGetFontDescriptor(&desc, &isLocal);
|
||||
|
||||
// Embed font data if it's a local font.
|
||||
@ -195,7 +195,8 @@ sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
|
||||
}
|
||||
}
|
||||
|
||||
return SkTypeface::MakeFromName(desc.getFamilyName(), desc.getStyle());
|
||||
return SkTypeface::MakeFromName(desc.getFamilyName(),
|
||||
SkFontStyle::FromOldStyle(desc.getStyle()));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,7 +31,6 @@ void SkTypeface_FCI::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocalSt
|
||||
SkString name;
|
||||
this->getFamilyName(&name);
|
||||
desc->setFamilyName(name.c_str());
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocalStream = SkToBool(this->getLocalStream());
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,6 @@ SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics(
|
||||
|
||||
void SkTestTypeface::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const {
|
||||
desc->setFamilyName(fTestFont->fName);
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocal = false;
|
||||
}
|
||||
|
||||
|
@ -2036,7 +2036,6 @@ void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc,
|
||||
desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr));
|
||||
desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr));
|
||||
desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr));
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocalStream = fIsLocalStream;
|
||||
}
|
||||
|
||||
|
@ -1714,7 +1714,6 @@ void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
|
||||
SkString familyName;
|
||||
this->onGetFamilyName(&familyName);
|
||||
desc->setFamilyName(familyName.c_str());
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocalStream = this->fSerializeAsStream;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,6 @@ public:
|
||||
SkASSERT(desc);
|
||||
SkASSERT(serialize);
|
||||
desc->setFamilyName(fFamilyName.c_str());
|
||||
desc->setStyle(this->fontStyle());
|
||||
*serialize = false;
|
||||
}
|
||||
SkStreamAsset* onOpenStream(int* ttcIndex) const override {
|
||||
|
@ -43,7 +43,6 @@ protected:
|
||||
|
||||
void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const override {
|
||||
desc->setFamilyName(fFamilyName.c_str());
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocal = !this->isSysFont();
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,6 @@ public:
|
||||
desc->setFamilyName(get_string(fPattern, FC_FAMILY));
|
||||
desc->setFullName(get_string(fPattern, FC_FULLNAME));
|
||||
desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
|
||||
desc->setStyle(this->fontStyle());
|
||||
*serialize = false;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
|
||||
sk_get_locale_string(familyNames.get(), nullptr/*fMgr->fLocaleName.get()*/, &utf8FamilyName);
|
||||
|
||||
desc->setFamilyName(utf8FamilyName.c_str());
|
||||
desc->setStyle(this->fontStyle());
|
||||
*isLocalStream = SkToBool(fDWriteFontFileLoader.get());
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,12 @@ static uint32_t compute_checksum(const SkTypeface* tf) {
|
||||
return SkChecksum::Murmur3(data.begin(), length);
|
||||
}
|
||||
|
||||
static void serialize_sub(const char* fontName, SkFontStyle style, SkWStream* wstream) {
|
||||
SkFontDescriptor desc;
|
||||
static void serialize_sub(const char* fontName, SkTypeface::Style style, SkWStream* wstream) {
|
||||
SkFontDescriptor desc(style);
|
||||
SkString subName(SUBNAME_PREFIX);
|
||||
subName.append(fontName);
|
||||
const char* familyName = subName.c_str();
|
||||
desc.setFamilyName(familyName);
|
||||
desc.setStyle(style);
|
||||
desc.serialize(wstream);
|
||||
#if WHITELIST_DEBUG
|
||||
for (int i = 0; i < whitelistCount; ++i) {
|
||||
@ -106,14 +105,14 @@ static void serialize_sub(const char* fontName, SkFontStyle style, SkWStream* ws
|
||||
|
||||
static bool is_local(const SkTypeface* tf) {
|
||||
bool isLocal = false;
|
||||
SkFontDescriptor desc;
|
||||
SkFontDescriptor desc(tf->style());
|
||||
tf->getFontDescriptor(&desc, &isLocal);
|
||||
return isLocal;
|
||||
}
|
||||
|
||||
static void serialize_full(const SkTypeface* tf, SkWStream* wstream) {
|
||||
bool isLocal = false;
|
||||
SkFontDescriptor desc;
|
||||
SkFontDescriptor desc(tf->style());
|
||||
tf->getFontDescriptor(&desc, &isLocal);
|
||||
|
||||
// Embed font data if it's a local font.
|
||||
@ -125,7 +124,7 @@ static void serialize_full(const SkTypeface* tf, SkWStream* wstream) {
|
||||
|
||||
static void serialize_name_only(const SkTypeface* tf, SkWStream* wstream) {
|
||||
bool isLocal = false;
|
||||
SkFontDescriptor desc;
|
||||
SkFontDescriptor desc(tf->style());
|
||||
tf->getFontDescriptor(&desc, &isLocal);
|
||||
SkASSERT(!isLocal);
|
||||
#if WHITELIST_DEBUG
|
||||
@ -181,7 +180,7 @@ void WhitelistSerializeTypeface(const SkTypeface* tf, SkWStream* wstream) {
|
||||
#endif
|
||||
whitelist[whitelistIndex].fChecksum = checksum;
|
||||
}
|
||||
serialize_sub(fontName, tf->fontStyle(), wstream);
|
||||
serialize_sub(fontName, tf->style(), wstream);
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> WhitelistDeserializeTypeface(SkStream* stream) {
|
||||
@ -201,7 +200,7 @@ sk_sp<SkTypeface> WhitelistDeserializeTypeface(SkStream* stream) {
|
||||
if (!strncmp(SUBNAME_PREFIX, familyName, sizeof(SUBNAME_PREFIX) - 1)) {
|
||||
familyName += sizeof(SUBNAME_PREFIX) - 1;
|
||||
}
|
||||
return SkTypeface::MakeFromName(familyName, desc.getStyle());
|
||||
return SkTypeface::MakeFromName(familyName, SkFontStyle::FromOldStyle(desc.getStyle()));
|
||||
}
|
||||
|
||||
bool CheckChecksums() {
|
||||
|
Loading…
Reference in New Issue
Block a user