mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
parent
61a7671de1
commit
7ada79b5ca
@ -79,23 +79,21 @@ class Genode::Vfs_font : public Text_painter::Font
|
||||
Area const _bounding_box;
|
||||
unsigned const _height;
|
||||
|
||||
struct Glyph_buffer
|
||||
struct Glyph_buffer : Byte_range_ptr
|
||||
{
|
||||
Allocator &_alloc;
|
||||
|
||||
size_t const num_bytes;
|
||||
Glyph_header &header { *(Glyph_header *)start };
|
||||
|
||||
Glyph_header &header;
|
||||
static size_t _bytes(Area size) { return sizeof(Glyph_buffer) + size.count()*4; }
|
||||
|
||||
Glyph_buffer(Allocator &alloc, Area size)
|
||||
:
|
||||
_alloc(alloc), num_bytes(sizeof(Glyph_header) + size.count()*4),
|
||||
header(*(Glyph_header *)alloc.alloc(num_bytes))
|
||||
Byte_range_ptr((char *)alloc.alloc(_bytes(size)), _bytes(size)),
|
||||
_alloc(alloc)
|
||||
{ }
|
||||
|
||||
~Glyph_buffer() { _alloc.free(&header, num_bytes); }
|
||||
|
||||
char *ptr() { return (char *)&header; }
|
||||
~Glyph_buffer() { _alloc.free(start, num_bytes); }
|
||||
};
|
||||
|
||||
Glyph_buffer mutable _buffer;
|
||||
@ -110,7 +108,7 @@ class Genode::Vfs_font : public Text_painter::Font
|
||||
try {
|
||||
Readonly_file const file(dir, path);
|
||||
char buf[MAX_LEN + 1] { };
|
||||
if (file.read(buf, sizeof(buf)) <= MAX_LEN)
|
||||
if (file.read(Byte_range_ptr { buf, sizeof(buf) }) <= MAX_LEN)
|
||||
if (ascii_to(buf, result))
|
||||
return result;
|
||||
}
|
||||
@ -149,14 +147,16 @@ class Genode::Vfs_font : public Text_painter::Font
|
||||
|
||||
void _apply_glyph(Codepoint c, Apply_fn const &fn) const override
|
||||
{
|
||||
_glyphs_file.read(_file_pos(c), _buffer.ptr(), _buffer.num_bytes);
|
||||
_glyphs_file.read(_file_pos(c), _buffer);
|
||||
|
||||
fn.apply(_buffer.header.glyph());
|
||||
}
|
||||
|
||||
Advance_info advance_info(Codepoint c) const override
|
||||
{
|
||||
_glyphs_file.read(_file_pos(c), _buffer.ptr(), sizeof(Glyph_header));
|
||||
Byte_range_ptr header_buffer { _buffer.start, sizeof(Glyph_header) };
|
||||
|
||||
_glyphs_file.read(_file_pos(c), header_buffer);
|
||||
|
||||
Glyph const glyph = _buffer.header.glyph();
|
||||
|
||||
|
@ -146,7 +146,8 @@ class Vfs_import::File_system : public Vfs::File_system
|
||||
|
||||
while (true) {
|
||||
|
||||
file_size bytes_from_source { src_file.read(at, buf, sizeof(buf)) };
|
||||
file_size const bytes_from_source =
|
||||
src_file.read(at, Genode::Byte_range_ptr(buf, sizeof(buf)));
|
||||
|
||||
if (!bytes_from_source) break;
|
||||
|
||||
|
@ -168,8 +168,8 @@ struct Test::Main
|
||||
{ }
|
||||
|
||||
Affected_rects capture() {
|
||||
_capture_file.read(_capture_ds.local_addr<char>(),
|
||||
_capture_ds_size);
|
||||
_capture_file.read(Byte_range_ptr(_capture_ds.local_addr<char>(),
|
||||
_capture_ds_size));
|
||||
Affected_rects affected { };
|
||||
affected.rects[0] = Rect(_at, _area);
|
||||
return affected;
|
||||
|
Loading…
Reference in New Issue
Block a user