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