1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

PixelPaint: Guarantee that constructed Layer always has a Gfx::Bitmap

Hoist any allocation failures so that layer factories never return a
bitmap-less layer.
This commit is contained in:
Andreas Kling 2021-06-12 10:24:04 +02:00
parent c7f7c1f7f0
commit 9038bc675f
2 changed files with 16 additions and 20 deletions

View file

@ -25,7 +25,7 @@ class Layer
public:
static RefPtr<Layer> try_create_with_size(Image&, Gfx::IntSize const&, String name);
static RefPtr<Layer> try_create_with_bitmap(Image&, Gfx::Bitmap const&, String name);
static RefPtr<Layer> try_create_with_bitmap(Image&, NonnullRefPtr<Gfx::Bitmap>, String name);
static RefPtr<Layer> try_create_snapshot(Image&, Layer const&);
~Layer() { }
@ -57,14 +57,13 @@ public:
void set_opacity_percent(int);
private:
Layer(Image&, Gfx::IntSize const&, String name);
Layer(Image&, Gfx::Bitmap const&, String name);
Layer(Image&, NonnullRefPtr<Gfx::Bitmap>, String name);
Image& m_image;
String m_name;
Gfx::IntPoint m_location;
RefPtr<Gfx::Bitmap> m_bitmap;
NonnullRefPtr<Gfx::Bitmap> m_bitmap;
bool m_selected { false };
bool m_visible { true };