De-templetize ShapeResultBloberizer
Update ShapeResultBloberizer to remove use of templates and instead call ToStringView on TextRuns to allow the same implementation to be used for both legacy layout and LayoutNG. A StringView has extremely low overhead both in terms of creation and memory usage, should have no perf impact. Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng Change-Id: Iaebcb3a5893d619950d1e7cc8c77fcef2015fffe Reviewed-on: https://chromium-review.googlesource.com/1207095 Reviewed-by: Christian Biesinger <cbiesinger@chromium.org> Commit-Queue: Emil A Eklund <eae@chromium.org> Cr-Commit-Position: refs/heads/master@{#589030}
This commit is contained in:

committed by
Commit Bot

parent
1b020ae4a4
commit
aabd29f7cb
third_party/blink/renderer/platform/fonts/shaping
@@ -93,15 +93,15 @@ float ShapeResultBloberizer::FillGlyphs(
|
|||||||
const scoped_refptr<const ShapeResult>& word_result = results[resolved_index];
|
const scoped_refptr<const ShapeResult>& word_result = results[resolved_index];
|
||||||
word_offset -= word_result->NumCharacters();
|
word_offset -= word_result->NumCharacters();
|
||||||
advance =
|
advance =
|
||||||
FillGlyphsForResult(word_result.get(), run_info.run, run_info.from,
|
FillGlyphsForResult(word_result.get(), run_info.run.ToStringView(),
|
||||||
run_info.to, advance, word_offset);
|
run_info.from, run_info.to, advance, word_offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned word_offset = 0;
|
unsigned word_offset = 0;
|
||||||
for (const auto& word_result : results) {
|
for (const auto& word_result : results) {
|
||||||
advance =
|
advance =
|
||||||
FillGlyphsForResult(word_result.get(), run_info.run, run_info.from,
|
FillGlyphsForResult(word_result.get(), run_info.run.ToStringView(),
|
||||||
run_info.to, advance, word_offset);
|
run_info.from, run_info.to, advance, word_offset);
|
||||||
word_offset += word_result->NumCharacters();
|
word_offset += word_result->NumCharacters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ void ShapeResultBloberizer::FillTextEmphasisGlyphs(
|
|||||||
unsigned resolved_offset =
|
unsigned resolved_offset =
|
||||||
word_offset - (run_info.run.Rtl() ? word_result->NumCharacters() : 0);
|
word_offset - (run_info.run.Rtl() ? word_result->NumCharacters() : 0);
|
||||||
advance += FillTextEmphasisGlyphsForRun(
|
advance += FillTextEmphasisGlyphsForRun(
|
||||||
word_result->runs_[i].get(), run_info.run,
|
word_result->runs_[i].get(), run_info.run.ToStringView(),
|
||||||
run_info.run.CharactersLength(), run_info.run.Direction(),
|
run_info.run.CharactersLength(), run_info.run.Direction(),
|
||||||
run_info.from, run_info.to, emphasis_data, advance, resolved_offset);
|
run_info.from, run_info.to, emphasis_data, advance, resolved_offset);
|
||||||
}
|
}
|
||||||
@@ -164,9 +164,8 @@ void ShapeResultBloberizer::FillTextEmphasisGlyphs(const StringView& text,
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename TextContainerType>
|
|
||||||
inline bool IsSkipInkException(const ShapeResultBloberizer& bloberizer,
|
inline bool IsSkipInkException(const ShapeResultBloberizer& bloberizer,
|
||||||
const TextContainerType& text,
|
const StringView& text,
|
||||||
unsigned character_index) {
|
unsigned character_index) {
|
||||||
// We want to skip descenders in general, but it is undesirable renderings for
|
// We want to skip descenders in general, but it is undesirable renderings for
|
||||||
// CJK characters.
|
// CJK characters.
|
||||||
@@ -175,14 +174,13 @@ inline bool IsSkipInkException(const ShapeResultBloberizer& bloberizer,
|
|||||||
text.CodepointAt(character_index));
|
text.CodepointAt(character_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TextContainerType>
|
|
||||||
inline void AddGlyphToBloberizer(ShapeResultBloberizer& bloberizer,
|
inline void AddGlyphToBloberizer(ShapeResultBloberizer& bloberizer,
|
||||||
float advance,
|
float advance,
|
||||||
hb_direction_t direction,
|
hb_direction_t direction,
|
||||||
CanvasRotationInVertical canvas_rotation,
|
CanvasRotationInVertical canvas_rotation,
|
||||||
const SimpleFontData* font_data,
|
const SimpleFontData* font_data,
|
||||||
const HarfBuzzRunGlyphData& glyph_data,
|
const HarfBuzzRunGlyphData& glyph_data,
|
||||||
const TextContainerType& text,
|
const StringView& text,
|
||||||
unsigned character_index) {
|
unsigned character_index) {
|
||||||
FloatPoint start_offset = HB_DIRECTION_IS_HORIZONTAL(direction)
|
FloatPoint start_offset = HB_DIRECTION_IS_HORIZONTAL(direction)
|
||||||
? FloatPoint(advance, 0)
|
? FloatPoint(advance, 0)
|
||||||
@@ -243,9 +241,8 @@ inline unsigned CountGraphemesInCluster(const UChar* str,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template <typename TextContainerType>
|
|
||||||
float ShapeResultBloberizer::FillGlyphsForResult(const ShapeResult* result,
|
float ShapeResultBloberizer::FillGlyphsForResult(const ShapeResult* result,
|
||||||
const TextContainerType& text,
|
const StringView& text,
|
||||||
unsigned from,
|
unsigned from,
|
||||||
unsigned to,
|
unsigned to,
|
||||||
float initial_advance,
|
float initial_advance,
|
||||||
@@ -328,10 +325,9 @@ float ShapeResultBloberizer::FillFastHorizontalGlyphs(
|
|||||||
return advance;
|
return advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TextContainerType>
|
|
||||||
float ShapeResultBloberizer::FillTextEmphasisGlyphsForRun(
|
float ShapeResultBloberizer::FillTextEmphasisGlyphsForRun(
|
||||||
const ShapeResult::RunInfo* run,
|
const ShapeResult::RunInfo* run,
|
||||||
const TextContainerType& text,
|
const StringView& text,
|
||||||
unsigned text_length,
|
unsigned text_length,
|
||||||
TextDirection direction,
|
TextDirection direction,
|
||||||
unsigned from,
|
unsigned from,
|
||||||
|
@@ -108,11 +108,8 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
|
|||||||
private:
|
private:
|
||||||
friend class ShapeResultBloberizerTestInfo;
|
friend class ShapeResultBloberizerTestInfo;
|
||||||
|
|
||||||
// Where TextContainerType can be either a TextRun or a StringView.
|
|
||||||
// For legacy layout and LayoutNG respectively.
|
|
||||||
template <typename TextContainerType>
|
|
||||||
float FillGlyphsForResult(const ShapeResult*,
|
float FillGlyphsForResult(const ShapeResult*,
|
||||||
const TextContainerType&,
|
const StringView&,
|
||||||
unsigned from,
|
unsigned from,
|
||||||
unsigned to,
|
unsigned to,
|
||||||
float initial_advance,
|
float initial_advance,
|
||||||
@@ -128,9 +125,8 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
|
|||||||
float FillFastHorizontalGlyphs(const ShapeResultBuffer&, TextDirection);
|
float FillFastHorizontalGlyphs(const ShapeResultBuffer&, TextDirection);
|
||||||
float FillFastHorizontalGlyphs(const ShapeResult*, float advance = 0);
|
float FillFastHorizontalGlyphs(const ShapeResult*, float advance = 0);
|
||||||
|
|
||||||
template <typename TextContainerType>
|
|
||||||
float FillTextEmphasisGlyphsForRun(const ShapeResult::RunInfo*,
|
float FillTextEmphasisGlyphsForRun(const ShapeResult::RunInfo*,
|
||||||
const TextContainerType&,
|
const StringView&,
|
||||||
unsigned text_length,
|
unsigned text_length,
|
||||||
TextDirection,
|
TextDirection,
|
||||||
unsigned from,
|
unsigned from,
|
||||||
|
Reference in New Issue
Block a user