Do not pass full buffer to minikin for big performance improvements.

Change-Id: I411d6168e45204774d4776aa241feeaf19dad818
This commit is contained in:
Gary Qian
2017-07-20 13:10:35 -07:00
parent 85bd669eac
commit 264a66f3f3
2 changed files with 8 additions and 4 deletions

View File

@@ -270,9 +270,13 @@ static void BM_ParagraphSkTextBlobAlloc(benchmark::State& state) {
while (state.KeepRunning()) {
SkTextBlobBuilder builder;
builder.allocRunPos(paint, 100);
builder.allocRunPos(paint, state.range(0));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK(BM_ParagraphSkTextBlobAlloc);
BENCHMARK(BM_ParagraphSkTextBlobAlloc)
->RangeMultiplier(4)
->Range(1 << 7, 1 << 14)
->Complexity(benchmark::oN);
} // namespace txt

View File

@@ -300,8 +300,8 @@ void Paragraph::Layout(double width, bool force) {
const size_t layout_end = std::min(run.end, next_break);
bool bidiFlags = paragraph_style_.rtl;
layout.doLayout(text_.data(), layout_start, layout_end - layout_start,
text_.size(), bidiFlags, font, minikin_paint,
layout.doLayout(text_.data() + layout_start, 0, layout_end - layout_start,
layout_end - layout_start, bidiFlags, font, minikin_paint,
font_collection_->GetMinikinFontCollectionForFamily(
run.style.font_family));
FillWhitespaceSet(layout_start, layout_end,