#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h"
#include <hb.h>
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
#include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h"
#include "third_party/blink/renderer/platform/text/text_break_iterator.h"
#include "third_party/blink/renderer/platform/text/text_run.h"
namespace blink {
ShapeResultBloberizer::ShapeResultBloberizer(
const FontDescription& font_description,
Type type)
: … { … }
bool ShapeResultBloberizer::HasPendingVerticalOffsets() const { … }
void ShapeResultBloberizer::SetText(const StringView& text,
unsigned from,
unsigned to,
base::span<const unsigned> cluster_starts) { … }
void ShapeResultBloberizer::CommitText() { … }
void ShapeResultBloberizer::CommitPendingRun() { … }
void ShapeResultBloberizer::CommitPendingBlob() { … }
const ShapeResultBloberizer::BlobBuffer& ShapeResultBloberizer::Blobs() { … }
inline bool ShapeResultBloberizer::IsSkipInkException(
const StringView& text,
unsigned character_index) { … }
inline void ShapeResultBloberizer::AddEmphasisMark(
const GlyphData& emphasis_data,
CanvasRotationInVertical canvas_rotation,
gfx::PointF glyph_center,
float mid_glyph_offset) { … }
namespace {
class GlyphCallbackContext { … };
}
void ShapeResultBloberizer::AddGlyphToBloberizer(
void* context,
unsigned character_index,
Glyph glyph,
gfx::Vector2dF glyph_offset,
float advance,
bool is_horizontal,
CanvasRotationInVertical rotation,
const SimpleFontData* font_data) { … }
void ShapeResultBloberizer::AddFastHorizontalGlyphToBloberizer(
void* context,
unsigned character_index,
Glyph glyph,
gfx::Vector2dF glyph_offset,
float advance,
bool is_horizontal,
CanvasRotationInVertical canvas_rotation,
const SimpleFontData* font_data) { … }
float ShapeResultBloberizer::FillGlyphsForResult(const ShapeResult* result,
const StringView& text,
unsigned from,
unsigned to,
float initial_advance,
unsigned run_offset) { … }
namespace {
class ClusterCallbackContext { … };
}
void ShapeResultBloberizer::AddEmphasisMarkToBloberizer(
void* context,
unsigned character_index,
float advance_so_far,
unsigned graphemes_in_cluster,
float cluster_advance,
CanvasRotationInVertical canvas_rotation) { … }
namespace {
class ClusterStarts { … };
}
ShapeResultBloberizer::FillGlyphs::FillGlyphs(
const FontDescription& font_description,
const TextRunPaintInfo& run_info,
const ShapeResultBuffer& result_buffer,
const Type type)
: … { … }
ShapeResultBloberizer::FillGlyphsNG::FillGlyphsNG(
const FontDescription& font_description,
const StringView& text,
unsigned from,
unsigned to,
const ShapeResultView* result,
const Type type)
: … { … }
ShapeResultBloberizer::FillTextEmphasisGlyphs::FillTextEmphasisGlyphs(
const FontDescription& font_description,
const TextRunPaintInfo& run_info,
const ShapeResultBuffer& result_buffer,
const GlyphData& emphasis)
: … { … }
ShapeResultBloberizer::FillTextEmphasisGlyphsNG::FillTextEmphasisGlyphsNG(
const FontDescription& font_description,
const StringView& text,
unsigned from,
unsigned to,
const ShapeResultView* result,
const GlyphData& emphasis)
: … { … }
bool ShapeResultBloberizer::CanUseFastPath(unsigned from,
unsigned to,
unsigned length,
bool has_vertical_offsets) { … }
bool ShapeResultBloberizer::CanUseFastPath(
unsigned from,
unsigned to,
const ShapeResultView* shape_result) { … }
float ShapeResultBloberizer::FillFastHorizontalGlyphs(
const ShapeResultBuffer& result_buffer,
TextDirection text_direction) { … }
float ShapeResultBloberizer::FillFastHorizontalGlyphs(const ShapeResult* result,
float initial_advance) { … }
}