mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibGfx: Add try_ prefix to Bitmap::try_allocate_backing_store()
This commit is contained in:
parent
deff554096
commit
deec79b3c6
2 changed files with 4 additions and 4 deletions
|
@ -67,7 +67,7 @@ static bool size_would_overflow(BitmapFormat format, const IntSize& size, int sc
|
||||||
|
|
||||||
RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int scale_factor)
|
RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int scale_factor)
|
||||||
{
|
{
|
||||||
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::No);
|
auto backing_store = Bitmap::try_allocate_backing_store(format, size, scale_factor, Purgeable::No);
|
||||||
if (!backing_store.has_value())
|
if (!backing_store.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return adopt_ref(*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()));
|
||||||
|
@ -75,7 +75,7 @@ RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int
|
||||||
|
|
||||||
RefPtr<Bitmap> Bitmap::try_create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor)
|
RefPtr<Bitmap> Bitmap::try_create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor)
|
||||||
{
|
{
|
||||||
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::Yes);
|
auto backing_store = Bitmap::try_allocate_backing_store(format, size, scale_factor, Purgeable::Yes);
|
||||||
if (!backing_store.has_value())
|
if (!backing_store.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return adopt_ref(*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()));
|
||||||
|
@ -576,7 +576,7 @@ ShareableBitmap Bitmap::to_shareable_bitmap() const
|
||||||
return ShareableBitmap(*bitmap);
|
return ShareableBitmap(*bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, const IntSize& size, int scale_factor, [[maybe_unused]] Purgeable purgeable)
|
Optional<BackingStore> Bitmap::try_allocate_backing_store(BitmapFormat format, IntSize const& size, int scale_factor, [[maybe_unused]] Purgeable purgeable)
|
||||||
{
|
{
|
||||||
if (size_would_overflow(format, size, scale_factor))
|
if (size_would_overflow(format, size, scale_factor))
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -243,7 +243,7 @@ private:
|
||||||
Bitmap(BitmapFormat, const IntSize&, int, size_t pitch, void*);
|
Bitmap(BitmapFormat, const IntSize&, int, size_t pitch, void*);
|
||||||
Bitmap(BitmapFormat, Core::AnonymousBuffer, const IntSize&, int, const Vector<RGBA32>& palette);
|
Bitmap(BitmapFormat, Core::AnonymousBuffer, const IntSize&, int, const Vector<RGBA32>& palette);
|
||||||
|
|
||||||
static Optional<BackingStore> allocate_backing_store(BitmapFormat, const IntSize&, int, Purgeable);
|
static Optional<BackingStore> try_allocate_backing_store(BitmapFormat format, IntSize const& size, int scale_factor, Purgeable);
|
||||||
|
|
||||||
void allocate_palette_from_format(BitmapFormat, const Vector<RGBA32>& source_palette);
|
void allocate_palette_from_format(BitmapFormat, const Vector<RGBA32>& source_palette);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue