1 #ifndef WL_MIRROR_MIRROR_H_
2 #define WL_MIRROR_MIRROR_H_
3 
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <wayland-client-protocol.h>
7 #include <wayland-egl.h>
8 #include <EGL/egl.h>
9 #include "wlr-export-dmabuf-unstable-v1.h"
10 #include "transform.h"
11 
12 struct ctx;
13 struct output_list_node;
14 
15 typedef struct {
16     int32_t fd;
17     uint32_t size;
18     uint32_t offset;
19     uint32_t stride;
20     uint32_t plane_index;
21 } dmabuf_object_t;
22 
23 typedef enum {
24     STATE_WAIT_FRAME,
25     STATE_WAIT_OBJECTS,
26     STATE_WAIT_READY,
27     STATE_READY,
28     STATE_CANCELED
29 } dmabuf_state_t;
30 
31 typedef struct ctx_mirror {
32     struct output_list_node * current_target;
33     struct wl_callback * frame_callback;
34     struct zwlr_export_dmabuf_frame_v1 * frame;
35     region_t current_region;
36     bool invert_y;
37 
38     // gl data
39     EGLImage frame_image;
40 
41     // frame data
42     uint32_t width;
43     uint32_t height;
44     uint32_t x;
45     uint32_t y;
46     uint32_t buffer_flags;
47     uint32_t frame_flags;
48     uint32_t format;
49     uint32_t modifier_low;
50     uint32_t modifier_high;
51     uint32_t num_objects;
52 
53     // object data
54     dmabuf_object_t objects[4];
55 
56     // state flags
57     dmabuf_state_t state;
58     uint32_t processed_objects;
59     bool initialized;
60 } ctx_mirror_t;
61 
62 void init_mirror(struct ctx * ctx);
63 
64 void output_removed_mirror(struct ctx * ctx, struct output_list_node * node);
65 void update_options_mirror(struct ctx * ctx);
66 
67 void cleanup_mirror(struct ctx * ctx);
68 
69 #endif
70