]> git.proxmox.com Git - spiceterm.git/blame - test_display_base.h
always update watch mask
[spiceterm.git] / test_display_base.h
CommitLineData
cc04455b
DM
1#ifndef __TEST_DISPLAY_BASE_H__
2#define __TEST_DISPLAY_BASE_H__
3
4#include <glib.h>
5#include <spice.h>
6#include "basic_event_loop.h"
7
8
22e5ba02
DM
9typedef struct TextAttributes {
10 unsigned int fgcol:4;
11 unsigned int bgcol:4;
12 unsigned int bold:1;
13 unsigned int uline:1;
14 unsigned int blink:1;
15 unsigned int invers:1;
16 unsigned int unvisible:1;
17} TextAttributes;
18
cc04455b
DM
19#define COUNT(x) ((sizeof(x)/sizeof(x[0])))
20
21/*
22 * simple queue for commands.
23 * each command can have up to two parameters (grow as needed)
24 *
25 * TODO: switch to gtk main loop. Then add gobject-introspection. then
26 * write tests in python/guile/whatever.
27 */
28typedef enum {
29 PATH_PROGRESS,
30 SIMPLE_CREATE_SURFACE,
31 SIMPLE_DRAW,
32 SIMPLE_DRAW_BITMAP,
33 SIMPLE_DRAW_SOLID,
34 SIMPLE_COPY_BITS,
35 SIMPLE_DESTROY_SURFACE,
36 SIMPLE_UPDATE,
37 DESTROY_PRIMARY,
38 CREATE_PRIMARY,
39 SLEEP
40} CommandType;
41
42typedef struct CommandCreatePrimary {
43 uint32_t width;
44 uint32_t height;
45} CommandCreatePrimary;
46
47typedef struct CommandCreateSurface {
48 uint32_t surface_id;
49 uint32_t format;
50 uint32_t width;
51 uint32_t height;
52 uint8_t *data;
53} CommandCreateSurface;
54
55typedef struct CommandDrawBitmap {
56 QXLRect bbox;
57 uint8_t *bitmap;
58 uint32_t surface_id;
59 uint32_t num_clip_rects;
60 QXLRect *clip_rects;
61} CommandDrawBitmap;
62
63typedef struct CommandDrawSolid {
64 QXLRect bbox;
65 uint32_t color;
66 uint32_t surface_id;
67} CommandDrawSolid;
68
69typedef struct CommandSleep {
70 uint32_t secs;
71} CommandSleep;
72
73typedef struct Command Command;
74typedef struct Test Test;
75
76struct Command {
77 CommandType command;
78 void (*cb)(Test *test, Command *command);
79 void *cb_opaque;
80 union {
81 CommandCreatePrimary create_primary;
82 CommandDrawBitmap bitmap;
83 CommandDrawSolid solid;
84 CommandSleep sleep;
85 CommandCreateSurface create_surface;
86 };
87};
88
89#define MAX_HEIGHT 2048
90#define MAX_WIDTH 2048
91
92#define SURF_WIDTH 320
93#define SURF_HEIGHT 240
94
95struct Test {
96 SpiceCoreInterface *core;
97 SpiceServer *server;
98
99 QXLInstance qxl_instance;
100 QXLWorker *qxl_worker;
101
8a22eb4f
DM
102 SpiceKbdInstance keyboard_sin;
103
cc04455b
DM
104 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
105 int primary_height;
106 int primary_width;
107
f6cb554c 108 SpiceTimer *conn_timeout_timer;
22e5ba02 109 SpiceWatch *mwatch; /* watch master pty */
f6cb554c 110
cc04455b
DM
111 int cursor_notify;
112
113 uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
114 int has_secondary;
115
116 // Current mode (set by create_primary)
117 int width;
118 int height;
119
cc04455b
DM
120 int target_surface;
121
122 // callbacks
123 void (*on_client_connected)(Test *test);
124 void (*on_client_disconnected)(Test *test);
125};
126
cc04455b
DM
127void test_add_display_interface(Test *test);
128void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
8a22eb4f 129void test_add_keyboard_interface(Test *test);
cc04455b
DM
130Test* test_new(SpiceCoreInterface* core);
131
22e5ba02
DM
132void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib);
133
cc04455b
DM
134uint32_t test_get_width(void);
135uint32_t test_get_height(void);
136
137void spice_test_config_parse_args(int argc, char **argv);
138
139#endif /* __TEST_DISPLAY_BASE_H__ */