LibGfx: Switch a bunch of API's from taking StringView to String

These were all getting converted into String internally anyway.
This commit is contained in:
Andreas Kling 2021-04-16 23:40:49 +02:00
parent 050648b270
commit e873d27ab1
12 changed files with 17 additions and 17 deletions

View file

@ -186,7 +186,7 @@ struct BMPLoadingContext {
static RefPtr<Bitmap> load_bmp_impl(const u8*, size_t);
RefPtr<Gfx::Bitmap> load_bmp(const StringView& path)
RefPtr<Gfx::Bitmap> load_bmp(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())

View file

@ -31,7 +31,7 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_bmp(const StringView& path);
RefPtr<Gfx::Bitmap> load_bmp(String const& path);
RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8*, size_t);
struct BMPLoadingContext;

View file

@ -143,7 +143,7 @@ RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size,
return adopt(*new Bitmap(format, size, scale_factor, pitch, data));
}
RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path, int scale_factor)
RefPtr<Bitmap> Bitmap::load_from_file(String const& path, int scale_factor)
{
if (scale_factor > 1 && path.starts_with("/res/")) {
LexicalPath lexical_path { path };
@ -439,11 +439,11 @@ Bitmap::~Bitmap()
delete[] m_palette;
}
void Bitmap::set_mmap_name([[maybe_unused]] const StringView& name)
void Bitmap::set_mmap_name([[maybe_unused]] String const& name)
{
VERIFY(m_needs_munmap);
#ifdef __serenity__
::set_mmap_name(m_data, size_in_bytes(), name.to_string().characters());
::set_mmap_name(m_data, size_in_bytes(), name.characters());
#endif
}

View file

@ -117,7 +117,7 @@ public:
static RefPtr<Bitmap> create_shareable(BitmapFormat, const IntSize&, int intrinsic_scale = 1);
static RefPtr<Bitmap> create_purgeable(BitmapFormat, const IntSize&, int intrinsic_scale = 1);
static RefPtr<Bitmap> create_wrapper(BitmapFormat, const IntSize&, int intrinsic_scale, size_t pitch, void*);
static RefPtr<Bitmap> load_from_file(const StringView& path, int scale_factor = 1);
static RefPtr<Bitmap> load_from_file(String const& path, int scale_factor = 1);
static RefPtr<Bitmap> create_with_anon_fd(BitmapFormat, int anon_fd, const IntSize&, int intrinsic_scale, const Vector<RGBA32>& palette, ShouldCloseAnonymousFile);
static RefPtr<Bitmap> create_from_serialized_byte_buffer(ByteBuffer&& buffer);
static bool is_path_a_supported_image_format(const StringView& path)
@ -221,7 +221,7 @@ public:
bool has_alpha_channel() const { return m_format == BitmapFormat::BGRA8888; }
BitmapFormat format() const { return m_format; }
void set_mmap_name(const StringView&);
void set_mmap_name(String const&);
static constexpr size_t size_in_bytes(size_t pitch, int physical_height) { return pitch * physical_height; }
size_t size_in_bytes() const { return size_in_bytes(m_pitch, physical_height()); }

View file

@ -190,7 +190,7 @@ String BitmapFont::type_name_by_type(FontTypes type)
VERIFY_NOT_REACHED();
}
RefPtr<BitmapFont> BitmapFont::load_from_file(const StringView& path)
RefPtr<BitmapFont> BitmapFont::load_from_file(String const& path)
{
if (Core::File::is_device(path))
return nullptr;
@ -207,7 +207,7 @@ RefPtr<BitmapFont> BitmapFont::load_from_file(const StringView& path)
return font;
}
bool BitmapFont::write_to_file(const StringView& path)
bool BitmapFont::write_to_file(String const& path)
{
FontFileHeader header;
memset(&header, 0, sizeof(FontFileHeader));

View file

@ -50,8 +50,8 @@ public:
NonnullRefPtr<Font> clone() const;
static NonnullRefPtr<BitmapFont> create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type);
static RefPtr<BitmapFont> load_from_file(const StringView& path);
bool write_to_file(const StringView& path);
static RefPtr<BitmapFont> load_from_file(String const& path);
bool write_to_file(String const& path);
~BitmapFont();

View file

@ -104,7 +104,7 @@ struct GIFLoadingContext {
RefPtr<Gfx::Bitmap> prev_frame_buffer;
};
RefPtr<Gfx::Bitmap> load_gif(const StringView& path)
RefPtr<Gfx::Bitmap> load_gif(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())

View file

@ -31,7 +31,7 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_gif(const StringView& path);
RefPtr<Gfx::Bitmap> load_gif(String const& path);
RefPtr<Gfx::Bitmap> load_gif_from_memory(const u8*, size_t);
struct GIFLoadingContext;

View file

@ -1252,7 +1252,7 @@ static RefPtr<Gfx::Bitmap> load_jpg_impl(const u8* data, size_t data_size)
return context.bitmap;
}
RefPtr<Gfx::Bitmap> load_jpg(const StringView& path)
RefPtr<Gfx::Bitmap> load_jpg(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())

View file

@ -33,7 +33,7 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_jpg(const StringView& path);
RefPtr<Gfx::Bitmap> load_jpg(String const& path);
RefPtr<Gfx::Bitmap> load_jpg_from_memory(const u8* data, size_t length);
struct JPGLoadingContext;

View file

@ -190,7 +190,7 @@ private:
static RefPtr<Gfx::Bitmap> load_png_impl(const u8*, size_t);
static bool process_chunk(Streamer&, PNGLoadingContext& context);
RefPtr<Gfx::Bitmap> load_png(const StringView& path)
RefPtr<Gfx::Bitmap> load_png(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())

View file

@ -31,7 +31,7 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_png(const StringView& path);
RefPtr<Gfx::Bitmap> load_png(String const& path);
RefPtr<Gfx::Bitmap> load_png_from_memory(const u8*, size_t);
struct PNGLoadingContext;