mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:57:45 +00:00
AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
This commit is contained in:
parent
b3db01e20e
commit
b91c49364d
228 changed files with 461 additions and 461 deletions
|
@ -73,7 +73,7 @@ RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size, int scal
|
|||
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::No);
|
||||
if (!backing_store.has_value())
|
||||
return nullptr;
|
||||
return adopt(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value()));
|
||||
return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value()));
|
||||
}
|
||||
|
||||
RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor)
|
||||
|
@ -81,7 +81,7 @@ RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size
|
|||
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::Yes);
|
||||
if (!backing_store.has_value())
|
||||
return nullptr;
|
||||
return adopt(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value()));
|
||||
return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value()));
|
||||
}
|
||||
|
||||
#ifdef __serenity__
|
||||
|
@ -120,7 +120,7 @@ RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size,
|
|||
{
|
||||
if (size_would_overflow(format, size, scale_factor))
|
||||
return nullptr;
|
||||
return adopt(*new Bitmap(format, size, scale_factor, pitch, data));
|
||||
return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data));
|
||||
}
|
||||
|
||||
RefPtr<Bitmap> Bitmap::load_from_file(String const& path, int scale_factor)
|
||||
|
@ -219,7 +219,7 @@ RefPtr<Bitmap> Bitmap::create_with_anon_fd(BitmapFormat format, int anon_fd, con
|
|||
}
|
||||
}
|
||||
|
||||
return adopt(*new Bitmap(format, anon_fd, size, scale_factor, data, palette));
|
||||
return adopt_ref(*new Bitmap(format, anon_fd, size, scale_factor, data, palette));
|
||||
}
|
||||
|
||||
/// Read a bitmap as described by:
|
||||
|
|
|
@ -44,7 +44,7 @@ NonnullRefPtr<Font> BitmapFont::clone() const
|
|||
memcpy(new_rows, m_rows, bytes_per_glyph * m_glyph_count);
|
||||
auto* new_widths = static_cast<u8*>(malloc(m_glyph_count));
|
||||
memcpy(new_widths, m_glyph_widths, m_glyph_count);
|
||||
return adopt(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
|
||||
return adopt_ref(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type)
|
||||
|
@ -55,7 +55,7 @@ NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bo
|
|||
memset(new_rows, 0, bytes_per_glyph * count);
|
||||
auto* new_widths = static_cast<u8*>(malloc(count));
|
||||
memset(new_widths, 0, count);
|
||||
return adopt(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true));
|
||||
return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true));
|
||||
}
|
||||
|
||||
BitmapFont::BitmapFont(String name, String family, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays)
|
||||
|
@ -137,7 +137,7 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data)
|
|||
|
||||
auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
|
||||
u8* widths = (u8*)(rows) + count * bytes_per_glyph;
|
||||
return adopt(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight));
|
||||
return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight));
|
||||
}
|
||||
|
||||
size_t BitmapFont::glyph_count_by_type(FontTypes type)
|
||||
|
|
|
@ -20,7 +20,7 @@ CharacterBitmap::~CharacterBitmap()
|
|||
|
||||
NonnullRefPtr<CharacterBitmap> CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height)
|
||||
{
|
||||
return adopt(*new CharacterBitmap(asciiData, width, height));
|
||||
return adopt_ref(*new CharacterBitmap(asciiData, width, height));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ RefPtr<Typeface> FontDatabase::get_or_create_typeface(const String& family, cons
|
|||
if (typeface->family() == family && typeface->variant() == variant)
|
||||
return typeface;
|
||||
}
|
||||
auto typeface = adopt(*new Typeface(family, variant));
|
||||
auto typeface = adopt_ref(*new Typeface(family, variant));
|
||||
m_private->typefaces.append(typeface);
|
||||
return typeface;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ protected:
|
|||
|
||||
class ImageDecoder : public RefCounted<ImageDecoder> {
|
||||
public:
|
||||
static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); }
|
||||
static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); }
|
||||
static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt_ref(*new ImageDecoder(data, size)); }
|
||||
static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt_ref(*new ImageDecoder(data.data(), data.size())); }
|
||||
~ImageDecoder();
|
||||
|
||||
bool is_valid() const { return m_plugin; }
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Gfx {
|
|||
|
||||
NonnullRefPtr<PaletteImpl> PaletteImpl::create_with_anonymous_buffer(Core::AnonymousBuffer buffer)
|
||||
{
|
||||
return adopt(*new PaletteImpl(move(buffer)));
|
||||
return adopt_ref(*new PaletteImpl(move(buffer)));
|
||||
}
|
||||
|
||||
PaletteImpl::PaletteImpl(Core::AnonymousBuffer buffer)
|
||||
|
@ -45,7 +45,7 @@ NonnullRefPtr<PaletteImpl> PaletteImpl::clone() const
|
|||
{
|
||||
auto new_theme_buffer = Core::AnonymousBuffer::create_with_size(m_theme_buffer.size());
|
||||
memcpy(new_theme_buffer.data<SystemTheme>(), &theme(), m_theme_buffer.size());
|
||||
return adopt(*new PaletteImpl(move(new_theme_buffer)));
|
||||
return adopt_ref(*new PaletteImpl(move(new_theme_buffer)));
|
||||
}
|
||||
|
||||
void Palette::set_color(ColorRole role, Color color)
|
||||
|
|
|
@ -197,7 +197,7 @@ private:
|
|||
template<typename T, typename... Args>
|
||||
void append_segment(Args&&... args)
|
||||
{
|
||||
m_segments.append(adopt(*new T(forward<Args>(args)...)));
|
||||
m_segments.append(adopt_ref(*new T(forward<Args>(args)...)));
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<Segment> m_segments {};
|
||||
|
|
|
@ -46,7 +46,7 @@ RefPtr<Font> Typeface::get_font(unsigned size)
|
|||
}
|
||||
|
||||
if (m_ttf_font)
|
||||
return adopt(*new TTF::ScaledFont(*m_ttf_font, size, size));
|
||||
return adopt_ref(*new TTF::ScaledFont(*m_ttf_font, size, size));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue