mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
PixelPaint: Add mask Bitmap to Layer and expose it
This commit is contained in:
parent
31a9196bfe
commit
82bfdec790
2 changed files with 15 additions and 1 deletions
|
@ -153,10 +153,16 @@ void Layer::update_cached_bitmap()
|
||||||
if (!is_masked()) {
|
if (!is_masked()) {
|
||||||
if (m_content_bitmap.ptr() == m_cached_display_bitmap.ptr())
|
if (m_content_bitmap.ptr() == m_cached_display_bitmap.ptr())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_cached_display_bitmap = m_content_bitmap;
|
m_cached_display_bitmap = m_content_bitmap;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer::create_mask()
|
||||||
|
{
|
||||||
|
m_mask_bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, size()));
|
||||||
|
m_mask_bitmap->fill(Gfx::Color::White);
|
||||||
|
update_cached_bitmap();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,11 @@ public:
|
||||||
Gfx::Bitmap const& content_bitmap() const { return m_content_bitmap; }
|
Gfx::Bitmap const& content_bitmap() const { return m_content_bitmap; }
|
||||||
Gfx::Bitmap& content_bitmap() { return m_content_bitmap; }
|
Gfx::Bitmap& content_bitmap() { return m_content_bitmap; }
|
||||||
|
|
||||||
|
Gfx::Bitmap const* mask_bitmap() const { return m_mask_bitmap; }
|
||||||
|
Gfx::Bitmap* mask_bitmap() { return m_mask_bitmap; }
|
||||||
|
|
||||||
|
void create_mask();
|
||||||
|
|
||||||
Gfx::IntSize size() const { return content_bitmap().size(); }
|
Gfx::IntSize size() const { return content_bitmap().size(); }
|
||||||
|
|
||||||
Gfx::IntRect relative_rect() const { return { location(), size() }; }
|
Gfx::IntRect relative_rect() const { return { location(), size() }; }
|
||||||
|
@ -67,6 +72,8 @@ public:
|
||||||
|
|
||||||
void erase_selection(Selection const&);
|
void erase_selection(Selection const&);
|
||||||
|
|
||||||
|
bool is_masked() { return !m_mask_bitmap.is_null(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Layer(Image&, NonnullRefPtr<Gfx::Bitmap>, String name);
|
Layer(Image&, NonnullRefPtr<Gfx::Bitmap>, String name);
|
||||||
|
|
||||||
|
@ -75,6 +82,7 @@ private:
|
||||||
String m_name;
|
String m_name;
|
||||||
Gfx::IntPoint m_location;
|
Gfx::IntPoint m_location;
|
||||||
NonnullRefPtr<Gfx::Bitmap> m_content_bitmap;
|
NonnullRefPtr<Gfx::Bitmap> m_content_bitmap;
|
||||||
|
RefPtr<Gfx::Bitmap> m_mask_bitmap { nullptr };
|
||||||
NonnullRefPtr<Gfx::Bitmap> m_cached_display_bitmap;
|
NonnullRefPtr<Gfx::Bitmap> m_cached_display_bitmap;
|
||||||
|
|
||||||
bool m_selected { false };
|
bool m_selected { false };
|
||||||
|
|
Loading…
Add table
Reference in a new issue