Fixed remaining global order buffers.

This commit is contained in:
Armin Novak 2018-04-03 17:17:45 +02:00
parent e5767f07ac
commit 4e66972616
8 changed files with 114 additions and 119 deletions

View File

@ -227,13 +227,6 @@ struct rdp_update
rdpPcap* pcap_rfx;
BOOL initialState;
BITMAP_UPDATE bitmap_update;
PALETTE_UPDATE palette_update;
PLAY_SOUND_UPDATE play_sound;
SURFACE_BITS_COMMAND surface_bits_command;
SURFACE_FRAME_MARKER surface_frame_marker;
BOOL asynchronous;
rdpUpdateProxy* proxy;
wMessageQueue* queue;

View File

@ -112,3 +112,33 @@ void free_cache_color_table_order(rdpContext* context, CACHE_COLOR_TABLE_ORDER*
{
free(order);
}
SURFACE_BITS_COMMAND* copy_surface_bits_command(rdpContext* context, const SURFACE_BITS_COMMAND* order)
{
SURFACE_BITS_COMMAND* dst = calloc(1, sizeof(SURFACE_BITS_COMMAND));
if (!dst || !order)
goto fail;
*dst = *order;
dst->bmp.bitmapData = (BYTE*) malloc(order->bmp.bitmapDataLength);
if (!dst->bmp.bitmapData)
goto fail;
CopyMemory(dst->bmp.bitmapData, order->bmp.bitmapData,
order->bmp.bitmapDataLength);
return dst;
fail:
free_surface_bits_command(context, dst);
return NULL;
}
void free_surface_bits_command(rdpContext* context, SURFACE_BITS_COMMAND* order)
{
if (order)
free(order->bmp.bitmapData);
free(order);
}

View File

@ -29,4 +29,8 @@ FREERDP_LOCAL CACHE_COLOR_TABLE_ORDER* copy_cache_color_table_order(rdpContext*
FREERDP_LOCAL void free_cache_color_table_order(rdpContext* context,
CACHE_COLOR_TABLE_ORDER* order);
FREERDP_LOCAL SURFACE_BITS_COMMAND* copy_surface_bits_command(rdpContext* context,
const SURFACE_BITS_COMMAND* order);
FREERDP_LOCAL void free_surface_bits_command(rdpContext* context, SURFACE_BITS_COMMAND* order);
#endif /* FREERDP_LIB_CACHE_CACHE_H */

View File

@ -322,7 +322,7 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s)
if (!bitmap_update)
return FALSE;
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, &update->bitmap_update);
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update);
free_bitmap_update(context, bitmap_update);
}
break;
@ -334,7 +334,7 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s)
if (!palette_update)
return FALSE;
rc = IFCALLRESULT(FALSE, update->Palette, context, &update->palette_update);
rc = IFCALLRESULT(FALSE, update->Palette, context, palette_update);
free_palette_update(context, palette_update);
}
break;

View File

@ -244,26 +244,11 @@ static BOOL update_message_SurfaceBits(rdpContext* context,
if (!context || !context->update || !surfaceBitsCommand)
return FALSE;
wParam = (SURFACE_BITS_COMMAND*) malloc(sizeof(SURFACE_BITS_COMMAND));
wParam = copy_surface_bits_command(context, surfaceBitsCommand);
if (!wParam)
return FALSE;
CopyMemory(wParam, surfaceBitsCommand, sizeof(SURFACE_BITS_COMMAND));
#ifdef WITH_STREAM_POOL
StreamPool_AddRef(context->rdp->transport->ReceivePool, surfaceBitsCommand->bmp.bitmapData);
#else
wParam->bmp.bitmapData = (BYTE*) malloc(wParam->bmp.bitmapDataLength);
if (!wParam->bmp.bitmapData)
{
free(wParam);
return FALSE;
}
CopyMemory(wParam->bmp.bitmapData, surfaceBitsCommand->bmp.bitmapData,
wParam->bmp.bitmapDataLength);
#endif
return MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(Update, SurfaceBits), (void*) wParam, NULL);
}

View File

@ -85,39 +85,45 @@ static BOOL update_recv_surfcmd_bitmap_ex(wStream* s, TS_BITMAP_DATA_EX* bmp)
static BOOL update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s)
{
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
SURFACE_BITS_COMMAND* cmd = calloc(1, sizeof(SURFACE_BITS_COMMAND));
if (!cmd)
return FALSE;
if (Stream_GetRemainingLength(s) < 8)
return FALSE;
goto fail;
Stream_Read_UINT16(s, cmd->destLeft);
Stream_Read_UINT16(s, cmd->destTop);
Stream_Read_UINT16(s, cmd->destRight);
Stream_Read_UINT16(s, cmd->destBottom);
if (!update_recv_surfcmd_bitmap_ex(s, &cmd->bmp))
return FALSE;
goto fail;
if (!update->SurfaceBits)
{
WLog_ERR(TAG, "Missing callback update->SurfaceBits");
return FALSE;
goto fail;
}
return update->SurfaceBits(update->context, cmd);
fail:
free_surface_bits_command(update->context, cmd);
return FALSE;
}
static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s)
{
SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
SURFACE_FRAME_MARKER marker;
if (Stream_GetRemainingLength(s) < 6)
return FALSE;
Stream_Read_UINT16(s, marker->frameAction);
Stream_Read_UINT32(s, marker->frameId);
Stream_Read_UINT16(s, marker.frameAction);
Stream_Read_UINT32(s, marker.frameId);
WLog_Print(update->log, WLOG_DEBUG, "SurfaceFrameMarker: action: %s (%"PRIu32") id: %"PRIu32"",
(!marker->frameAction) ? "Begin" : "End",
marker->frameAction, marker->frameId);
(!marker.frameAction) ? "Begin" : "End",
marker.frameAction, marker.frameId);
if (!update->SurfaceFrameMarker)
{
@ -125,7 +131,7 @@ static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s)
return FALSE;
}
return update->SurfaceFrameMarker(update->context, marker);
return update->SurfaceFrameMarker(update->context, &marker);
}
int update_recv_surfcmds(rdpUpdate* update, wStream* s)

View File

@ -306,11 +306,11 @@ static BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound)
BOOL update_recv_play_sound(rdpUpdate* update, wStream* s)
{
if (!update_read_play_sound(s, &update->play_sound))
PLAY_SOUND_UPDATE play_sound;
if (!update_read_play_sound(s, &play_sound))
return FALSE;
IFCALL(update->PlaySound, update->context, &update->play_sound);
return TRUE;
return IFCALLRESULT(FALSE, update->PlaySound, update->context, &play_sound);
}
POINTER_POSITION_UPDATE* update_read_pointer_position(rdpUpdate* update, wStream* s)
@ -647,7 +647,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s)
return FALSE;
}
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, &update->bitmap_update);
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update);
free_bitmap_update(update->context, bitmap_update);
}
break;
@ -2173,44 +2173,38 @@ rdpUpdate* update_new(rdpRdp* rdp)
return NULL;
update->log = WLog_Get("com.freerdp.core.update");
update->bitmap_update.count = 64;
update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(
update->bitmap_update.count, sizeof(BITMAP_DATA));
if (!update->bitmap_update.rectangles)
goto error_rectangles;
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
if (!update->pointer)
goto error_pointer;
goto fail;
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
if (!update->primary)
goto error_primary;
goto fail;
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
if (!update->secondary)
goto error_secondary;
goto fail;
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
if (!update->altsec)
goto error_altsec;
goto fail;
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
if (!update->window)
goto error_window;
goto fail;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
deleteList->sIndices = 64;
deleteList->indices = calloc(deleteList->sIndices, 2);
if (!deleteList->indices)
goto error_indices;
goto fail;
deleteList->cIndices = 0;
update->SuppressOutput = update_send_suppress_output;
@ -2218,25 +2212,11 @@ rdpUpdate* update_new(rdpRdp* rdp)
update->queue = MessageQueue_New(&cb);
if (!update->queue)
goto error_queue;
goto fail;
return update;
error_queue:
free(deleteList->indices);
error_indices:
free(update->window);
error_window:
free(update->altsec);
error_altsec:
free(update->secondary);
error_secondary:
free(update->primary);
error_primary:
free(update->pointer);
error_pointer:
free(update->bitmap_update.rectangles);
error_rectangles:
free(update);
fail:
update_free(update);
return NULL;
}
@ -2247,7 +2227,6 @@ void update_free(rdpUpdate* update)
OFFSCREEN_DELETE_LIST* deleteList;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
free(deleteList->indices);
free(update->bitmap_update.rectangles);
free(update->pointer);
free(update->primary->polyline.points);
free(update->primary->polygon_sc.points);

View File

@ -148,21 +148,21 @@ static wStream* test_peer_stream_init(testPeerContext* context)
static void test_peer_begin_frame(freerdp_peer* client)
{
rdpUpdate* update = client->update;
SURFACE_FRAME_MARKER* fm = &update->surface_frame_marker;
SURFACE_FRAME_MARKER fm;
testPeerContext* context = (testPeerContext*) client->context;
fm->frameAction = SURFACECMD_FRAMEACTION_BEGIN;
fm->frameId = context->frame_id;
update->SurfaceFrameMarker(update->context, fm);
fm.frameAction = SURFACECMD_FRAMEACTION_BEGIN;
fm.frameId = context->frame_id;
update->SurfaceFrameMarker(update->context, &fm);
}
static void test_peer_end_frame(freerdp_peer* client)
{
rdpUpdate* update = client->update;
SURFACE_FRAME_MARKER* fm = &update->surface_frame_marker;
SURFACE_FRAME_MARKER fm;
testPeerContext* context = (testPeerContext*) client->context;
fm->frameAction = SURFACECMD_FRAMEACTION_END;
fm->frameId = context->frame_id;
update->SurfaceFrameMarker(update->context, fm);
fm.frameAction = SURFACECMD_FRAMEACTION_END;
fm.frameId = context->frame_id;
update->SurfaceFrameMarker(update->context, &fm);
context->frame_id++;
}
@ -173,7 +173,7 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
RFX_RECT rect;
BYTE* rgb_data;
rdpUpdate* update = client->update;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
SURFACE_BITS_COMMAND cmd = { 0 };
testPeerContext* context = (testPeerContext*) client->context;
BOOL ret = FALSE;
@ -194,7 +194,6 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
}
memset(rgb_data, 0xA0, size);
memset(cmd, 0, sizeof(SURFACE_BITS_COMMAND));
if (client->settings->RemoteFxCodec)
{
@ -204,27 +203,27 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
goto out;
}
cmd->bmp.codecID = client->settings->RemoteFxCodecId;
cmd.bmp.codecID = client->settings->RemoteFxCodecId;
}
else
{
nsc_compose_message(context->nsc_context, s,
rgb_data, rect.width, rect.height, rect.width * 3);
cmd->bmp.codecID = client->settings->NSCodecId;
cmd.bmp.codecID = client->settings->NSCodecId;
}
cmd->destLeft = 0;
cmd->destTop = 0;
cmd->destRight = rect.width;
cmd->destBottom = rect.height;
cmd->bmp.bpp = 32;
cmd->bmp.flags = 0;
cmd->bmp.width = rect.width;
cmd->bmp.height = rect.height;
cmd->bmp.bitmapDataLength = Stream_GetPosition(s);
cmd->bmp.bitmapData = Stream_Buffer(s);
cmd.destLeft = 0;
cmd.destTop = 0;
cmd.destRight = rect.width;
cmd.destBottom = rect.height;
cmd.bmp.bpp = 32;
cmd.bmp.flags = 0;
cmd.bmp.width = rect.width;
cmd.bmp.height = rect.height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
test_peer_begin_frame(client);
update->SurfaceBits(update->context, cmd);
update->SurfaceBits(update->context, &cmd);
test_peer_end_frame(client);
ret = TRUE;
out:
@ -300,7 +299,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
wStream* s;
RFX_RECT rect;
rdpUpdate* update = client->update;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
SURFACE_BITS_COMMAND cmd = { 0 };
testPeerContext* context = (testPeerContext*) client->context;
if (client->update->dump_rfx)
@ -317,7 +316,6 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
rect.y = 0;
rect.width = context->icon_width;
rect.height = context->icon_height;
memset(cmd, 0, sizeof(SURFACE_BITS_COMMAND));
if (context->icon_x >= 0)
{
@ -327,26 +325,26 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
{
rfx_compose_message(context->rfx_context, s,
&rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->bmp.codecID = client->settings->RemoteFxCodecId;
cmd.bmp.codecID = client->settings->RemoteFxCodecId;
}
else
{
nsc_compose_message(context->nsc_context, s,
context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->bmp.codecID = client->settings->NSCodecId;
cmd.bmp.codecID = client->settings->NSCodecId;
}
cmd->destLeft = context->icon_x;
cmd->destTop = context->icon_y;
cmd->destRight = context->icon_x + context->icon_width;
cmd->destBottom = context->icon_y + context->icon_height;
cmd->bmp.bpp = 32;
cmd->bmp.flags = 0;
cmd->bmp.width = context->icon_width;
cmd->bmp.height = context->icon_height;
cmd->bmp.bitmapDataLength = Stream_GetPosition(s);
cmd->bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, cmd);
cmd.destLeft = context->icon_x;
cmd.destTop = context->icon_y;
cmd.destRight = context->icon_x + context->icon_width;
cmd.destBottom = context->icon_y + context->icon_height;
cmd.bmp.bpp = 32;
cmd.bmp.flags = 0;
cmd.bmp.width = context->icon_width;
cmd.bmp.height = context->icon_height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, &cmd);
}
s = test_peer_stream_init(context);
@ -355,25 +353,25 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
{
rfx_compose_message(context->rfx_context, s,
&rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->bmp.codecID = client->settings->RemoteFxCodecId;
cmd.bmp.codecID = client->settings->RemoteFxCodecId;
}
else
{
nsc_compose_message(context->nsc_context, s,
context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->bmp.codecID = client->settings->NSCodecId;
cmd.bmp.codecID = client->settings->NSCodecId;
}
cmd->destLeft = x;
cmd->destTop = y;
cmd->destRight = x + context->icon_width;
cmd->destBottom = y + context->icon_height;
cmd->bmp.bpp = 32;
cmd->bmp.width = context->icon_width;
cmd->bmp.height = context->icon_height;
cmd->bmp.bitmapDataLength = Stream_GetPosition(s);
cmd->bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, cmd);
cmd.destLeft = x;
cmd.destTop = y;
cmd.destRight = x + context->icon_width;
cmd.destBottom = y + context->icon_height;
cmd.bmp.bpp = 32;
cmd.bmp.width = context->icon_width;
cmd.bmp.height = context->icon_height;
cmd.bmp.bitmapDataLength = Stream_GetPosition(s);
cmd.bmp.bitmapData = Stream_Buffer(s);
update->SurfaceBits(update->context, &cmd);
context->icon_x = x;
context->icon_y = y;
test_peer_end_frame(client);