aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-05-19 07:43:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-19 07:43:52 -0700
commitde3c3568ee5137fa8752491362893ae1d701d709 (patch)
tree96ac018d68c15d49f0b5c6690bc92c457f820dad
parent0876158ecddf5966beb839dcf5da514790685681 (diff)
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
-rw-r--r--src/core/SkGlyphCache.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 9725c0179a..072541d146 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -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;