@@ -56,11 +56,18 @@ uint32_t ParagraphCache::KeyHash::mix(uint32_t hash, uint32_t data) const {
5656uint32_t ParagraphCache::KeyHash::operator ()(const ParagraphCacheKey& key) const {
5757 uint32_t hash = 0 ;
5858 for (auto & ph : key.fPlaceholders ) {
59+ if (&ph == &key.fPlaceholders .back ()) {
60+ // Skip the last "dummy" placeholder
61+ break ;
62+ }
5963 hash = mix (hash, SkGoodHash ()(ph.fRange .start ));
6064 hash = mix (hash, SkGoodHash ()(ph.fRange .end ));
6165 hash = mix (hash, SkGoodHash ()(relax (ph.fStyle .fBaselineOffset )));
6266 hash = mix (hash, SkGoodHash ()(ph.fStyle .fBaseline ));
6367 hash = mix (hash, SkGoodHash ()(ph.fStyle .fAlignment ));
68+ if (ph.fStyle .fAlignment == PlaceholderAlignment::kBaseline ) {
69+ hash = mix (hash, SkGoodHash ()(relax (ph.fStyle .fBaselineOffset )));
70+ }
6471 hash = mix (hash, SkGoodHash ()(relax (ph.fStyle .fHeight )));
6572 hash = mix (hash, SkGoodHash ()(relax (ph.fStyle .fWidth )));
6673 }
@@ -99,8 +106,8 @@ bool operator==(const ParagraphCacheKey& a, const ParagraphCacheKey& b) {
99106 return false ;
100107 }
101108
102- if (!(a. fParagraphStyle == b. fParagraphStyle )) {
103- // This is too strong, but at least we will not lose lines
109+ // There is no need to compare default paragraph styles - they are included into fTextStyles
110+ if (a. fParagraphStyle . getHeight () != b. fParagraphStyle . getHeight ()) {
104111 return false ;
105112 }
106113
@@ -120,7 +127,7 @@ bool operator==(const ParagraphCacheKey& a, const ParagraphCacheKey& b) {
120127 return false ;
121128 }
122129 }
123- for (size_t i = 0 ; i < a.fPlaceholders .size (); ++i) {
130+ for (size_t i = 0 ; i < a.fPlaceholders .size () - 1 ; ++i) {
124131 auto & tsa = a.fPlaceholders [i];
125132 auto & tsb = b.fPlaceholders [i];
126133 if (!(tsa.fStyle .equals (tsb.fStyle ))) {
@@ -222,6 +229,7 @@ bool ParagraphCache::findParagraph(ParagraphImpl* paragraph) {
222229 SkAutoMutexExclusive lock (fParagraphMutex );
223230 ParagraphCacheKey key (paragraph);
224231 std::unique_ptr<Entry>* entry = fLRUCacheMap .find (key);
232+
225233 if (!entry) {
226234 // We have a cache miss
227235#ifdef PARAGRAPH_CACHE_STATS
0 commit comments