]> git.proxmox.com Git - spiceterm.git/blame - test_display_base.h
implement scroll
[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
63a34f43
DM
89#define COMMANDS_SIZE 1024
90
cc04455b
DM
91#define MAX_HEIGHT 2048
92#define MAX_WIDTH 2048
93
94#define SURF_WIDTH 320
95#define SURF_HEIGHT 240
96
97struct Test {
98 SpiceCoreInterface *core;
99 SpiceServer *server;
100
101 QXLInstance qxl_instance;
102 QXLWorker *qxl_worker;
103
8a22eb4f
DM
104 SpiceKbdInstance keyboard_sin;
105
cc04455b
DM
106 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
107 int primary_height;
108 int primary_width;
109
f6cb554c 110 SpiceTimer *conn_timeout_timer;
22e5ba02 111 SpiceWatch *mwatch; /* watch master pty */
f6cb554c 112
cc04455b
DM
113 int cursor_notify;
114
115 uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
116 int has_secondary;
117
118 // Current mode (set by create_primary)
119 int width;
120 int height;
121
cc04455b
DM
122 int target_surface;
123
63a34f43
DM
124 GCond* command_cond;
125 GMutex* command_mutex;
126
127 int commands_end;
128 int commands_start;
129 struct QXLCommandExt* commands[COMMANDS_SIZE];
130
cc04455b
DM
131 // callbacks
132 void (*on_client_connected)(Test *test);
133 void (*on_client_disconnected)(Test *test);
134};
135
cc04455b
DM
136void test_add_display_interface(Test *test);
137void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
8a22eb4f 138void test_add_keyboard_interface(Test *test);
cc04455b
DM
139Test* test_new(SpiceCoreInterface* core);
140
22e5ba02 141void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib);
7b4a7650
DM
142void test_spice_scroll(Test *test, int x1, int y1, int x2, int y2, int src_x, int src_y);
143void test_spice_clear(Test *test, int x1, int y1, int x2, int y2);
144
22e5ba02 145
cc04455b
DM
146uint32_t test_get_width(void);
147uint32_t test_get_height(void);
148
149void spice_test_config_parse_args(int argc, char **argv);
150
151#endif /* __TEST_DISPLAY_BASE_H__ */