Assert complex precondition in SkGlyphCache::Visit.
SkGlyphCache::Visit takes a descriptor and a typeface, but it is implied that the fFontID in the descriptor is the id of the typeface. This seems to be handled correctly by current callers but this is a subtle requirement which if violated could lead to subtle bugs. Review-Url: https://codereview.chromium.org/1992053002
This commit is contained in:
parent
0876158ecd
commit
de3c3568ee
@ -520,6 +520,16 @@ SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface,
|
||||
}
|
||||
SkASSERT(desc);
|
||||
|
||||
// Precondition: the typeface id must be the fFontID in the descriptor
|
||||
SkDEBUGCODE(
|
||||
uint32_t length;
|
||||
const SkScalerContext::Rec* rec = static_cast<const SkScalerContext::Rec*>(
|
||||
desc->findEntry(kRec_SkDescriptorTag, &length));
|
||||
SkASSERT(rec);
|
||||
SkASSERT(length == sizeof(*rec));
|
||||
SkASSERT(typeface->uniqueID() == rec->fFontID);
|
||||
)
|
||||
|
||||
SkGlyphCache_Globals& globals = get_globals();
|
||||
SkGlyphCache* cache;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user