-
Notifications
You must be signed in to change notification settings - Fork 2
/
HaikuCompositor.h
124 lines (104 loc) · 3.59 KB
/
HaikuCompositor.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#pragma once
#include "Wayland.h"
#include "WlGlobal.h"
#include "HaikuSubcompositor.h"
#include "HaikuShm.h"
#include <AutoDeleter.h>
#include <Point.h>
#include <Region.h>
#include <optional>
class HaikuXdgSurface;
class HaikuServerDecoration;
class WaylandView;
class BBitmap;
class BWindow;
class BView;
class HaikuCompositorGlobal: public WlGlocal {
public:
static HaikuCompositorGlobal *Create(struct wl_display *display);
virtual ~HaikuCompositorGlobal() = default;
void Bind(struct wl_client *wl_client, uint32_t version, uint32_t id) override;
};
class HaikuSurface: public WlSurface {
public:
class Hook {
private:
friend class HaikuSurface;
HaikuSurface *fBase{};
public:
virtual ~Hook() = default;
HaikuSurface *Base() {return fBase;}
virtual void HandleCommit() = 0;
};
private:
friend class HaikuXdgSurface;
friend class HaikuXdgToplevel;
friend class HaikuServerDecoration;
friend class HaikuSubsurface;
friend class WaylandView;
class FrameCallback: public WlCallback {
private:
DoublyLinkedListLink<FrameCallback> fLink;
public:
typedef DoublyLinkedList<FrameCallback, DoublyLinkedListMemberGetLink<FrameCallback, &FrameCallback::fLink>> List;
static FrameCallback *Create(struct wl_client *client, uint32_t version, uint32_t id);
virtual ~FrameCallback() = default;
};
enum StateField {
fieldBuffer,
fieldOffset,
fieldTransform,
fieldScale,
fieldOpaqueRgn,
fieldInputRgn,
fieldFrameCallbacks
};
struct State {
BReference<HaikuShmBuffer> buffer;
int32_t dx, dy;
int32_t transform = WlOutput::transformNormal;
int32_t scale = 1;
std::optional<BRegion> opaqueRgn;
std::optional<BRegion> inputRgn;
FrameCallback::List frameCallbacks;
};
ObjectDeleter<Hook> fHook;
State fState{};
State fPendingState{};
uint32 fPendingFields{};
BRegion fDirty;
WaylandView *fView{};
HaikuXdgSurface *fXdgSurface{};
HaikuServerDecoration *fServerDecoration{};
HaikuSubsurface *fSubsurface{};
HaikuSubsurface::SurfaceList fSurfaceList;
public:
static HaikuSurface *Create(struct wl_client *client, uint32_t version, uint32_t id);
static HaikuSurface *FromResource(struct wl_resource *resource) {return (HaikuSurface*)WlResource::FromResource(resource);}
virtual ~HaikuSurface();
BView *View() {return (BView*)fView;}
BBitmap *Bitmap() {return fState.buffer == NULL ? NULL : &fState.buffer->Bitmap();}
bool InputRgnContains(BPoint p) {return !fState.inputRgn ? true : fState.inputRgn->Contains(p);}
void GetOffset(int32_t &x, int32_t &y) {x = fState.dx; y = fState.dy;}
HaikuXdgSurface *XdgSurface() {return fXdgSurface;}
HaikuSubsurface *Subsurface() {return fSubsurface;}
HaikuServerDecoration *ServerDecoration() {return fServerDecoration;}
HaikuSubsurface::SurfaceList &SurfaceList() {return fSurfaceList;}
void AttachWindow(BWindow *window);
void AttachView(BView *view);
void AttachViewsToEarlierSubsurfaces();
void Detach();
void Invalidate();
void CallFrameCallbacks();
void SetHook(Hook *hook);
void HandleAttach(struct wl_resource *buffer_resource, int32_t dx, int32_t dy) override;
void HandleDamage(int32_t x, int32_t y, int32_t width, int32_t height) override;
void HandleFrame(uint32_t callback) override;
void HandleSetOpaqueRegion(struct wl_resource *region_resource) override;
void HandleSetInputRegion(struct wl_resource *region_resource) override;
void HandleCommit() override;
void HandleSetBufferTransform(int32_t transform) override;
void HandleSetBufferScale(int32_t scale) override;
void HandleDamageBuffer(int32_t x, int32_t y, int32_t width, int32_t height) override;
void HandleOffset(int32_t x, int32_t y) override;
};