summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx/ShareableBitmap.h
blob: 498ab64c377995150f7c6ec4b2f87a17d25fda1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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&);
}