server/test: final updates to support mstsc.

This commit is contained in:
Vic Lee 2011-08-25 17:38:51 +08:00
parent 78b9e4d52c
commit 64cd43ab3b

View File

@ -39,8 +39,9 @@ static const unsigned int test_quantization_values[] =
struct test_peer_info struct test_peer_info
{ {
RFX_CONTEXT* context; RFX_CONTEXT* context;
STREAM* bg_s; STREAM* s;
STREAM* icon_s; uint8* icon_data;
uint8* bg_data;
int icon_width; int icon_width;
int icon_height; int icon_height;
int icon_x; int icon_x;
@ -60,8 +61,7 @@ static void test_peer_init(freerdp_peer* client)
info->context->height = client->settings->height; info->context->height = client->settings->height;
rfx_context_set_pixel_format(info->context, RFX_PIXEL_FORMAT_RGB); rfx_context_set_pixel_format(info->context, RFX_PIXEL_FORMAT_RGB);
info->bg_s = stream_new(65536); info->s = stream_new(65536);
info->icon_s = stream_new(65536);
info->icon_x = -1; info->icon_x = -1;
info->icon_y = -1; info->icon_y = -1;
@ -75,27 +75,19 @@ static void test_peer_uninit(freerdp_peer* client)
if (info) if (info)
{ {
stream_free(info->bg_s); stream_free(info->s);
stream_free(info->icon_s); xfree(info->icon_data);
xfree(info->bg_data);
rfx_context_free(info->context); rfx_context_free(info->context);
xfree(info); xfree(info);
} }
} }
static STREAM* test_peer_stream_init(testPeerInfo* info, boolean icon) static STREAM* test_peer_stream_init(testPeerInfo* info)
{ {
if (icon) stream_clear(info->s);
{ stream_set_pos(info->s, 0);
stream_clear(info->icon_s); return info->s;
stream_set_pos(info->icon_s, 0);
return info->icon_s;
}
else
{
stream_clear(info->bg_s);
stream_set_pos(info->bg_s, 0);
return info->bg_s;
}
} }
static void test_peer_draw_background(freerdp_peer* client) static void test_peer_draw_background(freerdp_peer* client)
@ -111,7 +103,7 @@ static void test_peer_draw_background(freerdp_peer* client)
if (!client->settings->rfx_codec) if (!client->settings->rfx_codec)
return; return;
s = test_peer_stream_init(info, False); s = test_peer_stream_init(info);
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
@ -122,10 +114,7 @@ static void test_peer_draw_background(freerdp_peer* client)
rgb_data = xmalloc(size); rgb_data = xmalloc(size);
memset(rgb_data, 0xA0, size); memset(rgb_data, 0xA0, size);
/* In Video mode, the RemoteFX header should only be sent once */ rfx_compose_message(info->context, s,
rfx_compose_message_header(info->context, s);
rfx_compose_message_data(info->context, s,
&rect, 1, rgb_data, rect.width, rect.height, rect.width * 3); &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3);
cmd->destLeft = 0; cmd->destLeft = 0;
@ -146,19 +135,15 @@ static void test_peer_draw_background(freerdp_peer* client)
static void test_peer_load_icon(freerdp_peer* client) static void test_peer_load_icon(freerdp_peer* client)
{ {
testPeerInfo* info = (testPeerInfo*)client->param1; testPeerInfo* info = (testPeerInfo*)client->param1;
STREAM* s;
FILE* fp; FILE* fp;
int i; int i;
char line[50]; char line[50];
uint8* rgb_data; uint8* rgb_data;
int c; int c;
RFX_RECT rect;
if (!client->settings->rfx_codec) if (!client->settings->rfx_codec)
return; return;
s = test_peer_stream_init(info, True);
if ((fp = fopen("test_icon.ppm", "r")) == NULL) if ((fp = fopen("test_icon.ppm", "r")) == NULL)
return; return;
@ -183,22 +168,11 @@ static void test_peer_load_icon(freerdp_peer* client)
} }
} }
rect.x = 0; info->icon_data = rgb_data;
rect.y = 0;
rect.width = info->icon_width;
rect.height = info->icon_height;
rfx_compose_message_data(info->context, s, /* background with same size, which will be used to erase the icon from old position */
&rect, 1, rgb_data, rect.width, rect.height, rect.width * 3); info->bg_data = xmalloc(info->icon_width * info->icon_height * 3);
memset(info->bg_data, 0xA0, info->icon_width * info->icon_height * 3);
/* background with same size */
s = test_peer_stream_init(info, False);
memset(rgb_data, 0xA0, info->icon_width * info->icon_height * 3);
rfx_compose_message_data(info->context, s,
&rect, 1, rgb_data, rect.width, rect.height, rect.width * 3);
xfree(rgb_data);
} }
static void test_peer_draw_icon(freerdp_peer* client, int x, int y) static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
@ -206,32 +180,52 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
testPeerInfo* info = (testPeerInfo*)client->param1; testPeerInfo* info = (testPeerInfo*)client->param1;
rdpUpdate* update = client->update; rdpUpdate* update = client->update;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
RFX_RECT rect;
STREAM* s;
if (!client->settings->rfx_codec) if (!client->settings->rfx_codec)
return; return;
if (stream_get_length(info->icon_s) < 1) if (info->icon_width < 1)
return; return;
cmd->destRight = info->icon_width; rect.x = 0;
cmd->destBottom = info->icon_height; rect.y = 0;
rect.width = info->icon_width;
rect.height = info->icon_height;
if (info->icon_x >= 0)
{
s = test_peer_stream_init(info);
rfx_compose_message(info->context, s,
&rect, 1, info->bg_data, rect.width, rect.height, rect.width * 3);
cmd->destLeft = info->icon_x;
cmd->destTop = info->icon_y;
cmd->destRight = info->icon_x + info->icon_width;
cmd->destBottom = info->icon_y + info->icon_height;
cmd->bpp = 32; cmd->bpp = 32;
cmd->codecID = client->settings->rfx_codec_id; cmd->codecID = client->settings->rfx_codec_id;
cmd->width = info->icon_width; cmd->width = info->icon_width;
cmd->height = info->icon_height; cmd->height = info->icon_height;
cmd->bitmapDataLength = stream_get_length(s);
if (info->icon_x >= 0) cmd->bitmapData = stream_get_head(s);
{
cmd->destLeft = info->icon_x;
cmd->destTop = info->icon_y;
cmd->bitmapDataLength = stream_get_length(info->bg_s);
cmd->bitmapData = stream_get_head(info->bg_s);
update->SurfaceBits(update, cmd); update->SurfaceBits(update, cmd);
} }
s = test_peer_stream_init(info);
rfx_compose_message(info->context, s,
&rect, 1, info->icon_data, rect.width, rect.height, rect.width * 3);
cmd->destLeft = x; cmd->destLeft = x;
cmd->destTop = y; cmd->destTop = y;
cmd->bitmapDataLength = stream_get_length(info->icon_s); cmd->destRight = x + info->icon_width;
cmd->bitmapData = stream_get_head(info->icon_s); cmd->destBottom = y + info->icon_height;
cmd->bpp = 32;
cmd->codecID = client->settings->rfx_codec_id;
cmd->width = info->icon_width;
cmd->height = info->icon_height;
cmd->bitmapDataLength = stream_get_length(s);
cmd->bitmapData = stream_get_head(s);
update->SurfaceBits(update, cmd); update->SurfaceBits(update, cmd);
info->icon_x = x; info->icon_x = x;
@ -288,7 +282,7 @@ void test_peer_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)
{ {
printf("Client sent a mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y); printf("Client sent a mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y);
test_peer_draw_icon(input->param1, x, y); test_peer_draw_icon(input->param1, x + 10, y);
} }
void test_peer_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y) void test_peer_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)