From 268004d0c9d284472d41d5b9f4e1814a2264917b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 12 May 2013 13:42:53 -0400 Subject: [PATCH] libfreerdp-core: start implementing server-side alternate secondary drawing orders --- libfreerdp/core/orders.c | 54 ++++++++++++++++++++++++++++++++++++ libfreerdp/core/orders.h | 2 ++ libfreerdp/core/update.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 4f3996a87..945944e27 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2048,6 +2048,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM if (Stream_GetRemainingLength(s) < 6) return FALSE; + Stream_Read_UINT16(s, flags); /* flags (2 bytes) */ create_offscreen_bitmap->id = flags & 0x7FFF; deleteListPresent = (flags & 0x8000) ? TRUE : FALSE; @@ -2056,11 +2057,14 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM Stream_Read_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ deleteList = &(create_offscreen_bitmap->deleteList); + if (deleteListPresent) { int i; + if (Stream_GetRemainingLength(s) < 2) return FALSE; + Stream_Read_UINT16(s, deleteList->cIndices); if (deleteList->cIndices > deleteList->sIndices) @@ -2081,6 +2085,44 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM { deleteList->cIndices = 0; } + + return TRUE; +} + +BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) +{ + UINT16 flags; + BOOL deleteListPresent; + OFFSCREEN_DELETE_LIST* deleteList; + + deleteList = &(create_offscreen_bitmap->deleteList); + + Stream_EnsureRemainingCapacity(s, 8 + deleteList->cIndices * 2); + + flags = create_offscreen_bitmap->id & 0x7FFF; + + deleteListPresent = (deleteList->cIndices > 0) ? TRUE : FALSE; + + if (deleteListPresent) + flags |= 0x8000; + + Stream_Write_UINT16(s, flags); /* flags (2 bytes) */ + + Stream_Write_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */ + Stream_Write_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ + + if (deleteListPresent) + { + int i; + + Stream_Write_UINT16(s, deleteList->cIndices); + + for (i = 0; i < (int) deleteList->cIndices; i++) + { + Stream_Write_UINT16(s, deleteList->indices[i]); + } + } + return TRUE; } @@ -2088,7 +2130,18 @@ BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_s { if (Stream_GetRemainingLength(s) < 2) return FALSE; + Stream_Read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ + + return TRUE; +} + +BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface) +{ + Stream_EnsureRemainingCapacity(s, 2); + + Stream_Write_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ + return TRUE; } @@ -2098,6 +2151,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM if (Stream_GetRemainingLength(s) < 19) return FALSE; + Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 21db4d74d..29c2ae077 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -234,7 +234,9 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags); BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); +BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); +BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap); BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker); BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index b5e9a08ea..ec634a257 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -953,6 +953,64 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER update->numberOrders++; } +static void update_send_create_offscreen_bitmap_order(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) +{ + wStream* s; + int bm, em; + BYTE orderType; + BYTE controlFlags; + int headerLength; + rdpUpdate* update = context->update; + + headerLength = 1; + orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP; + controlFlags = ORDER_SECONDARY | (orderType << 2); + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_create_offscreen_bitmap_order(s, create_offscreen_bitmap); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + +static void update_send_switch_surface_order(rdpContext* context, SWITCH_SURFACE_ORDER* switch_surface) +{ + wStream* s; + int bm, em; + BYTE orderType; + BYTE controlFlags; + int headerLength; + rdpUpdate* update = context->update; + + headerLength = 1; + orderType = ORDER_TYPE_SWITCH_SURFACE; + controlFlags = ORDER_SECONDARY | (orderType << 2); + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_switch_surface_order(s, switch_surface); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) { wStream* s; @@ -1090,6 +1148,8 @@ void update_register_server_callbacks(rdpUpdate* update) update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; update->secondary->CacheGlyph = update_send_cache_glyph; update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; + update->altsec->CreateOffscreenBitmap = update_send_create_offscreen_bitmap_order; + update->altsec->SwitchSurface = update_send_switch_surface_order; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; update->pointer->PointerNew = update_send_pointer_new;