Skip to content

Commit

Permalink
Bug 1560582 - Limit Skia glyph batch sizes. r=jrmuizel, a=RyanVM
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D36148

--HG--
extra : source : e57ef2080d3fe256ed188285f178ab97729af28d
  • Loading branch information
lsalzman committed Jun 27, 2019
1 parent b8c8d61 commit 7a8a2f2
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions gfx/2d/DrawTargetSkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,14 +1374,22 @@ void DrawTargetSkia::DrawGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,

font.setSubpixel(useSubpixelText);

SkTextBlobBuilder builder;
auto runBuffer = builder.allocRunPos(font, aBuffer.mNumGlyphs);
for (uint32_t i = 0; i < aBuffer.mNumGlyphs; i++) {
runBuffer.glyphs[i] = aBuffer.mGlyphs[i].mIndex;
runBuffer.points()[i] = PointToSkPoint(aBuffer.mGlyphs[i].mPosition);
}
sk_sp<SkTextBlob> text = builder.make();
mCanvas->drawTextBlob(text, 0, 0, paint.mPaint);
// Limit the amount of internal batch allocations Skia does.
const uint32_t kMaxGlyphBatchSize = 8192;

for (uint32_t offset = 0; offset < aBuffer.mNumGlyphs;) {
uint32_t batchSize =
std::min(aBuffer.mNumGlyphs - offset, kMaxGlyphBatchSize);
SkTextBlobBuilder builder;
auto runBuffer = builder.allocRunPos(font, batchSize);
for (uint32_t i = 0; i < batchSize; i++, offset++) {
runBuffer.glyphs[i] = aBuffer.mGlyphs[offset].mIndex;
runBuffer.points()[i] = PointToSkPoint(aBuffer.mGlyphs[offset].mPosition);
}

sk_sp<SkTextBlob> text = builder.make();
mCanvas->drawTextBlob(text, 0, 0, paint.mPaint);
}
}

void DrawTargetSkia::FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
Expand Down

0 comments on commit 7a8a2f2

Please sign in to comment.