forked from X547/wayland-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHaikuShm.h
71 lines (52 loc) · 1.65 KB
/
HaikuShm.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <optional>
#include "WlGlobal.h"
#include "Wayland.h"
#include <Bitmap.h>
#include <Referenceable.h>
#include <AutoDeleter.h>
#include <AutoDeleterOS.h>
class HaikuShmGlobal: public WlGlocal {
public:
static HaikuShmGlobal *Create(struct wl_display *display);
virtual ~HaikuShmGlobal() = default;
void Bind(struct wl_client *wl_client, uint32_t version, uint32_t id) final;
};
class HaikuShm: public WlShm {
public:
virtual ~HaikuShm() = default;
void HandleCreatePool(uint32_t id, int32_t fd, int32_t size) final;
};
class HaikuShmAreaRef: public BReferenceable {
private:
AreaDeleter fArea;
public:
HaikuShmAreaRef(area_id area): fArea(area) {}
area_id Area() const {return fArea.Get();}
};
class HaikuShmPool: public WlShmPool {
private:
friend class HaikuShm;
friend class HaikuShmBuffer;
FileDescriptorCloser fFd;
BReference<HaikuShmAreaRef> fAreaRef;
void *fAddress {};
size_t fSize {};
void Remap(int32_t size);
public:
virtual ~HaikuShmPool() = default;
void HandleCreateBuffer(uint32_t id, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) final;
void HandleResize(int32_t size) final;
};
class HaikuShmBuffer: public WlBuffer, public BReferenceable {
private:
friend class HaikuShmPool;
BReference<HaikuShmAreaRef> fAreaRef;
std::optional<BBitmap> fBitmap;
public:
static HaikuShmBuffer *FromResource(struct wl_resource *resource) {return (HaikuShmBuffer*)WlResource::FromResource(resource);}
virtual ~HaikuShmBuffer() = default;
void HandleDestroy() final {ReleaseReference();}
void LastReferenceReleased() final {Destroy();}
inline BBitmap &Bitmap() {return fBitmap.value();}
};