]>
Commit | Line | Data |
---|---|---|
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 |
9 | typedef 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 | */ | |
28 | typedef 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 | ||
42 | typedef struct CommandCreatePrimary { | |
43 | uint32_t width; | |
44 | uint32_t height; | |
45 | } CommandCreatePrimary; | |
46 | ||
47 | typedef 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 | ||
55 | typedef 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 | ||
63 | typedef struct CommandDrawSolid { | |
64 | QXLRect bbox; | |
65 | uint32_t color; | |
66 | uint32_t surface_id; | |
67 | } CommandDrawSolid; | |
68 | ||
69 | typedef struct CommandSleep { | |
70 | uint32_t secs; | |
71 | } CommandSleep; | |
72 | ||
73 | typedef struct Command Command; | |
74 | typedef struct Test Test; | |
75 | ||
76 | struct 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 | ||
95 | struct 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 | ||
120 | // qxl scripted rendering commands and io | |
121 | Command *commands; | |
122 | int num_commands; | |
123 | int cmd_index; | |
124 | ||
125 | int target_surface; | |
126 | ||
127 | // callbacks | |
128 | void (*on_client_connected)(Test *test); | |
129 | void (*on_client_disconnected)(Test *test); | |
130 | }; | |
131 | ||
132 | void test_set_simple_command_list(Test *test, int *command, int num_commands); | |
133 | void test_set_command_list(Test *test, Command *command, int num_commands); | |
134 | void test_add_display_interface(Test *test); | |
135 | void test_add_agent_interface(SpiceServer *server); // TODO - Test *test | |
8a22eb4f | 136 | void test_add_keyboard_interface(Test *test); |
cc04455b DM |
137 | Test* test_new(SpiceCoreInterface* core); |
138 | ||
22e5ba02 DM |
139 | void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib); |
140 | ||
cc04455b DM |
141 | uint32_t test_get_width(void); |
142 | uint32_t test_get_height(void); | |
143 | ||
144 | void spice_test_config_parse_args(int argc, char **argv); | |
145 | ||
146 | #endif /* __TEST_DISPLAY_BASE_H__ */ |