mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibGfx+LibIPC: Add Gfx::ShareableBitmap, a bitmap for easy IPC usage
With this patch, it's now possible to pass a Gfx::ShareableBitmap in an IPC message. As long as the message itself is synchronous, the bitmap will be adopted by the receiving end, and disowned by the sender nicely without any accounting effort like we've had to do in the past. Use this in NotificationServer to allow sending arbitrary bitmaps as icons instead of paths-to-icons.
This commit is contained in:
parent
24a0354ce8
commit
7cfe712f4d
17 changed files with 115 additions and 17 deletions
35
Libraries/LibGfx/ShareableBitmap.h
Normal file
35
Libraries/LibGfx/ShareableBitmap.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
class ShareableBitmap {
|
||||
public:
|
||||
ShareableBitmap() {}
|
||||
explicit ShareableBitmap(const Gfx::Bitmap&);
|
||||
|
||||
bool is_valid() const { return m_bitmap; }
|
||||
|
||||
i32 shbuf_id() const { return m_bitmap ? m_bitmap->shbuf_id() : -1; }
|
||||
|
||||
const Bitmap* bitmap() const { return m_bitmap; }
|
||||
Bitmap* bitmap() { return m_bitmap; }
|
||||
|
||||
Size size() const { return m_bitmap ? m_bitmap->size() : Size(); }
|
||||
Rect rect() const { return m_bitmap ? m_bitmap->rect() : Rect(); }
|
||||
|
||||
int width() const { return size().width(); }
|
||||
int height() const { return size().height(); }
|
||||
|
||||
private:
|
||||
RefPtr<Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
bool decode(Decoder&, Gfx::ShareableBitmap&);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue