Bug 1574066 - Correctly count glyphs when determining text decoration intercepts. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D43396

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2019-08-26 09:26:22 +00:00
Родитель 7f5a19c884
Коммит 1ca68445da
1 изменённых файлов: 3 добавлений и 8 удалений

Просмотреть файл

@ -3820,13 +3820,8 @@ static uint32_t CountAllGlyphs(
const gfxTextRun* aTextRun, const gfxTextRun* aTextRun,
const gfxTextRun::CompressedGlyph* aCompressedGlyph, uint32_t aStringStart, const gfxTextRun::CompressedGlyph* aCompressedGlyph, uint32_t aStringStart,
uint32_t aStringEnd) { uint32_t aStringEnd) {
bool hasDetailed = aTextRun->HasDetailedGlyphs();
uint32_t totalGlyphCount = 0; uint32_t totalGlyphCount = 0;
if (!hasDetailed) {
return aStringEnd - aStringStart;
}
for (const gfxTextRun::CompressedGlyph* cg = aCompressedGlyph + aStringStart; for (const gfxTextRun::CompressedGlyph* cg = aCompressedGlyph + aStringStart;
cg < aCompressedGlyph + aStringEnd; ++cg) { cg < aCompressedGlyph + aStringEnd; ++cg) {
totalGlyphCount += cg->IsSimpleGlyph() ? 1 : cg->GetGlyphCount(); totalGlyphCount += cg->IsSimpleGlyph() ? 1 : cg->GetGlyphCount();
@ -3884,8 +3879,6 @@ static sk_sp<const SkTextBlob> CreateTextBlob(
SkTextBlobBuilder builder; SkTextBlobBuilder builder;
const SkTextBlobBuilder::RunBuffer& run = builder.allocRunPos(aFont, len); const SkTextBlobBuilder::RunBuffer& run = builder.allocRunPos(aFont, len);
bool hasDetailed = aTextRun->HasDetailedGlyphs();
// RTL text should be read in by glyph starting at aStringEnd - 1 down until // RTL text should be read in by glyph starting at aStringEnd - 1 down until
// aStringStart. // aStringStart.
bool isRTL = aTextRun->IsRightToLeft(); bool isRTL = aTextRun->IsRightToLeft();
@ -3907,7 +3900,7 @@ static sk_sp<const SkTextBlob> CreateTextBlob(
AddSimpleGlyph(run, aCompressedGlyph[currIndex], i, aAppUnitsPerDevPixel, AddSimpleGlyph(run, aCompressedGlyph[currIndex], i, aAppUnitsPerDevPixel,
aTextPos); aTextPos);
i++; i++;
} else if (hasDetailed) { } else {
// if it's detailed, potentially add multiple into run.glyphs // if it's detailed, potentially add multiple into run.glyphs
uint32_t count = aCompressedGlyph[currIndex].GetGlyphCount(); uint32_t count = aCompressedGlyph[currIndex].GetGlyphCount();
if (count > 0) { if (count > 0) {
@ -3932,6 +3925,8 @@ static sk_sp<const SkTextBlob> CreateTextBlob(
currIndex += step; currIndex += step;
} }
MOZ_ASSERT(i == len, "glyph count error!");
return builder.make(); return builder.make();
} }