mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibTTF: Use ReadonlyBytes where possible to avoid copies
This commit is contained in:
parent
187acd8f21
commit
0f6cf9caa1
6 changed files with 48 additions and 48 deletions
|
@ -76,7 +76,7 @@ public:
|
|||
Gfx::FloatPoint point;
|
||||
};
|
||||
|
||||
PointIterator(const ByteBuffer& slice, u16 num_points, u32 flags_offset, u32 x_offset, u32 y_offset, Gfx::AffineTransform affine)
|
||||
PointIterator(const ReadonlyBytes& slice, u16 num_points, u32 flags_offset, u32 x_offset, u32 y_offset, Gfx::AffineTransform affine)
|
||||
: m_slice(slice)
|
||||
, m_points_remaining(num_points)
|
||||
, m_flags_offset(flags_offset)
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ByteBuffer m_slice;
|
||||
ReadonlyBytes m_slice;
|
||||
u16 m_points_remaining;
|
||||
u8 m_flag { 0 };
|
||||
Gfx::FloatPoint m_last_point = { 0.0f, 0.0f };
|
||||
|
@ -337,7 +337,7 @@ void Rasterizer::draw_line(Gfx::FloatPoint p0, Gfx::FloatPoint p1)
|
|||
}
|
||||
}
|
||||
|
||||
Optional<Loca> Loca::from_slice(const ByteBuffer& slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format)
|
||||
Optional<Loca> Loca::from_slice(const ReadonlyBytes& slice, u32 num_glyphs, IndexToLocFormat index_to_loc_format)
|
||||
{
|
||||
switch (index_to_loc_format) {
|
||||
case IndexToLocFormat::Offset16:
|
||||
|
@ -367,7 +367,7 @@ u32 Loca::get_glyph_offset(u32 glyph_id) const
|
|||
}
|
||||
}
|
||||
|
||||
static void get_ttglyph_offsets(const ByteBuffer& slice, u32 num_points, u32 flags_offset, u32* x_offset, u32* y_offset)
|
||||
static void get_ttglyph_offsets(const ReadonlyBytes& slice, u32 num_points, u32 flags_offset, u32* x_offset, u32* y_offset)
|
||||
{
|
||||
u32 flags_size = 0;
|
||||
u32 x_size = 0;
|
||||
|
@ -512,7 +512,7 @@ Glyf::Glyph Glyf::glyph(u32 offset) const
|
|||
i16 ymin = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::YMin));
|
||||
i16 xmax = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::XMax));
|
||||
i16 ymax = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::YMax));
|
||||
auto slice = ByteBuffer::copy(m_slice.offset_pointer(offset + (u32)Sizes::GlyphHeader), m_slice.size() - offset - (u32)Sizes::GlyphHeader);
|
||||
auto slice = ReadonlyBytes(m_slice.offset_pointer(offset + (u32)Sizes::GlyphHeader), m_slice.size() - offset - (u32)Sizes::GlyphHeader);
|
||||
return Glyph(slice, xmin, ymin, xmax, ymax, num_contours);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue