// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/351564777): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_GLYPH_DATA_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_GLYPH_DATA_H_ #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/assertions.h" #include "ui/gfx/geometry/vector2d_f.h" namespace blink { // Because glyph offsets are often zero, particularly for Latin runs, we hold it // in |ShapeResult::RunInfo::GlyphDataCollection::offsets_| for reducing memory // usage. struct HarfBuzzRunGlyphData { … }; static_assert …; GlyphOffset; // Represents a range of HarfBuzzRunGlyphData. |begin| and |end| follow the // iterator pattern; i.e., |begin| is lower or equal to |end| in the address // space regardless of LTR/RTL. |begin| is inclusive, |end| is exclusive. struct GlyphDataRange { … }; // Find the range of HarfBuzzRunGlyphData for the specified character index // range. This function uses binary search twice, hence O(2 log n). inline GlyphDataRange GlyphDataRange::FindGlyphDataRange( bool is_rtl, unsigned start_character_index, unsigned end_character_index) const { … } // A array of glyph offsets. If all offsets are zero, we don't allocate // storage for reducing memory usage. class GlyphOffsetArray final { … }; // For non-zero glyph offset array template <> struct GlyphOffsetArray::iterator<true> final { … }; // For zero glyph offset array template <> struct GlyphOffsetArray::iterator<false> final { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_GLYPH_DATA_H_