]> git.proxmox.com Git - spiceterm.git/blob - test_display_base.h
Initial import
[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 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
93 int primary_height;
94 int primary_width;
95
96 SpiceTimer *wakeup_timer;
97 int wakeup_ms;
98
99 int cursor_notify;
100
101 uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
102 int has_secondary;
103
104 // Current mode (set by create_primary)
105 int width;
106 int height;
107
108 // qxl scripted rendering commands and io
109 Command *commands;
110 int num_commands;
111 int cmd_index;
112
113 int target_surface;
114
115 // callbacks
116 void (*on_client_connected)(Test *test);
117 void (*on_client_disconnected)(Test *test);
118 };
119
120 void test_set_simple_command_list(Test *test, int *command, int num_commands);
121 void test_set_command_list(Test *test, Command *command, int num_commands);
122 void test_add_display_interface(Test *test);
123 void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
124 Test* test_new(SpiceCoreInterface* core);
125
126 uint32_t test_get_width(void);
127 uint32_t test_get_height(void);
128
129 void spice_test_config_parse_args(int argc, char **argv);
130
131 #endif /* __TEST_DISPLAY_BASE_H__ */