BOOL combineUpdates;
rdpBounds currentBounds;
rdpBounds previousBounds;
+ CRITICAL_SECTION mux;
};
#endif /* FREERDP_UPDATE_H */
int fastpath_recv_updates(rdpFastPath* fastpath, wStream* s)
{
+ int rc = -2;
rdpUpdate* update;
if (!fastpath || !fastpath->rdp || !fastpath->rdp->update || !s)
update = fastpath->rdp->update;
- if (!IFCALLRESULT(TRUE, update->BeginPaint, update->context))
- return -2;
+ if (!update_begin_paint(update))
+ goto fail;
while (Stream_GetRemainingLength(s) >= 3)
{
if (fastpath_recv_update_data(fastpath, s) < 0)
{
WLog_ERR(TAG, "fastpath_recv_update_data() fail");
- return -3;
+ rc = -3;
+ goto fail;
}
}
- if (!IFCALLRESULT(FALSE, update->EndPaint, update->context))
+ rc = 0;
+fail:
+
+ if (!update_end_paint(update))
return -4;
- return 0;
+ return rc;
}
static BOOL fastpath_read_input_event_header(wStream* s, BYTE* eventFlags, BYTE* eventCode)
Stream_SetLength(s, record.length);
Stream_SetPosition(s, 0);
- if (!update->BeginPaint(update->context))
- status = FALSE;
- else if (update_recv_surfcmds(update, s) < 0)
- status = FALSE;
- else if (!update->EndPaint(update->context))
+ if (!update_begin_paint(update))
status = FALSE;
+ else
+ {
+ if (update_recv_surfcmds(update, s) < 0)
+ status = FALSE;
+
+ if (!update_end_paint(update))
+ status = FALSE;
+ }
Stream_Release(s);
}
Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */
WLog_Print(update->log, WLOG_TRACE, "%s Update Data PDU", UPDATE_TYPE_STRINGS[updateType]);
- if (!IFCALLRESULT(TRUE, update->BeginPaint, context))
- return FALSE;
+ if (!update_begin_paint(update))
+ goto fail;
switch (updateType)
{
if (!bitmap_update)
{
WLog_ERR(TAG, "UPDATE_TYPE_BITMAP - update_read_bitmap_update() failed");
- return FALSE;
+ goto fail;
}
rc = IFCALLRESULT(FALSE, update->BitmapUpdate, context, bitmap_update);
if (!palette_update)
{
WLog_ERR(TAG, "UPDATE_TYPE_PALETTE - update_read_palette() failed");
- return FALSE;
+ goto fail;
}
rc = IFCALLRESULT(FALSE, update->Palette, context, palette_update);
break;
}
+fail:
+
+ if (!update_end_paint(update))
+ rc = FALSE;
+
if (!rc)
{
WLog_ERR(TAG, "UPDATE_TYPE %s [%"PRIu16"] failed", update_type_to_string(updateType), updateType);
return FALSE;
}
- if (!IFCALLRESULT(FALSE, update->EndPaint, context))
- return FALSE;
-
return TRUE;
}
update->initialState = TRUE;
}
-static BOOL update_begin_paint(rdpContext* context)
+static BOOL _update_begin_paint(rdpContext* context)
{
wStream* s;
rdpUpdate* update = context->update;
if (update->us)
- update->EndPaint(context);
+ {
+ if (!update_end_paint(update))
+ return FALSE;
+ }
s = fastpath_update_pdu_init_new(context->rdp->fastpath);
return TRUE;
}
-static BOOL update_end_paint(rdpContext* context)
+static BOOL _update_end_paint(rdpContext* context)
{
wStream* s;
int headerLength;
if (update->numberOrders > 0)
{
- update->EndPaint(context);
- update->BeginPaint(context);
+ update_end_paint(update);
+ update_begin_paint(update);
}
}
static void update_force_flush(rdpContext* context)
{
- rdpUpdate* update = context->update;
-
- if (update->numberOrders > 0)
- {
- update->EndPaint(context);
- update->BeginPaint(context);
- }
+ update_flush(context);
}
static BOOL update_check_flush(rdpContext* context, int size)
if (!update->us)
{
- update->BeginPaint(context);
+ update_begin_paint(update);
return FALSE;
}
void update_register_server_callbacks(rdpUpdate* update)
{
- update->BeginPaint = update_begin_paint;
- update->EndPaint = update_end_paint;
+ update->BeginPaint = _update_begin_paint;
+ update->EndPaint = _update_end_paint;
update->SetBounds = update_set_bounds;
update->Synchronize = update_send_synchronize;
update->DesktopResize = update_send_desktop_resize;
update->SetKeyboardImeStatus = update_send_set_keyboard_ime_status;
update->SaveSessionInfo = rdp_send_save_session_info;
update->ServerStatusInfo = rdp_send_server_status_info;
-
update->primary->DstBlt = update_send_dstblt;
update->primary->PatBlt = update_send_patblt;
update->primary->ScrBlt = update_send_scrblt;
update->primary->LineTo = update_send_line_to;
update->primary->MemBlt = update_send_memblt;
update->primary->GlyphIndex = update_send_glyph_index;
-
update->secondary->CacheBitmap = update_send_cache_bitmap;
update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2;
update->secondary->CacheBitmapV3 = update_send_cache_bitmap_v3;
update->secondary->CacheGlyph = update_send_cache_glyph;
update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2;
update->secondary->CacheBrush = update_send_cache_brush;
-
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->PointerPosition = update_send_pointer_position;
update->pointer->PointerColor = update_send_pointer_color;
return NULL;
update->log = WLog_Get("com.freerdp.core.update");
+ InitializeCriticalSection(&(update->mux));
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
if (!update->pointer)
}
MessageQueue_Free(update->queue);
+ DeleteCriticalSection(&update->mux);
free(update);
}
}
+
+
+BOOL update_begin_paint(rdpUpdate* update)
+{
+ if (!update)
+ return FALSE;
+
+ EnterCriticalSection(&update->mux);
+
+ if (!update->BeginPaint)
+ return TRUE;
+
+ return update->BeginPaint(update->context);
+}
+
+BOOL update_end_paint(rdpUpdate* update)
+{
+ BOOL rc = FALSE;
+
+ if (!update)
+ return FALSE;
+
+ if (update->EndPaint)
+ rc = update->EndPaint(update->context);
+
+ LeaveCriticalSection(&update->mux);
+ return rc;
+}
FREERDP_LOCAL void update_register_client_callbacks(rdpUpdate* update);
FREERDP_LOCAL int update_process_messages(rdpUpdate* update);
+FREERDP_LOCAL BOOL update_begin_paint(rdpUpdate* update);
+FREERDP_LOCAL BOOL update_end_paint(rdpUpdate* update);
+
#endif /* FREERDP_LIB_CORE_UPDATE_H */
#include "config.h"
#endif
+#include "../core/update.h"
+
#include <freerdp/log.h>
#include <freerdp/gdi/gfx.h>
#include <freerdp/gdi/region.h>
if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects)
return CHANNEL_RC_OK;
- if (!IFCALLRESULT(TRUE, update->BeginPaint, gdi->context))
+ if (!update_begin_paint(update))
goto fail;
for (i = 0; i < nbRects; i++)
gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, width, height);
}
- if (!IFCALLRESULT(FALSE, update->EndPaint, gdi->context))
- goto fail;
-
rc = CHANNEL_RC_OK;
fail:
+
+ if (!update_end_paint(update))
+ rc = ERROR_INTERNAL_ERROR;
+
region16_clear(&(surface->invalidRegion));
return rc;
}
* limitations under the License.
*/
+#include "../core/update.h"
#include <freerdp/client/geometry.h>
#include <freerdp/client/video.h>
static BOOL gdiVideoShowSurface(VideoClientContext* video, VideoSurface* surface)
{
+ BOOL rc = FALSE;
rdpGdi* gdi = (rdpGdi*)video->custom;
gdiVideoSurface* gdiSurface = (gdiVideoSurface*)surface;
RECTANGLE_16 surfaceRect;
surfaceRect.top = surface->y;
surfaceRect.right = surface->x + surface->w;
surfaceRect.bottom = surface->y + surface->h;
- update->BeginPaint(gdi->context);
+
+ if (!update_begin_paint(update))
+ goto fail;
if ((gdi->width < 0) || (gdi->height < 0))
- return FALSE;
+ goto fail;
else
{
const UINT32 nXSrc = surface->x;
const UINT32 nYSrc = surface->y;
const UINT32 nXDst = nXSrc;
const UINT32 nYDst = nYSrc;
- const UINT32 width = (surface->w + surface->x < (UINT32)gdi->width) ? surface->w : (UINT32)gdi->width - surface->x;
- const UINT32 height = (surface->h + surface->y < (UINT32)gdi->height) ? surface->h : (UINT32)gdi->height -
+ const UINT32 width = (surface->w + surface->x < (UINT32)gdi->width) ? surface->w :
+ (UINT32)gdi->width - surface->x;
+ const UINT32 height = (surface->h + surface->y < (UINT32)gdi->height) ? surface->h :
+ (UINT32)gdi->height -
surface->y;
if (!freerdp_image_copy(gdi->primary_buffer, gdi->primary->hdc->format,
nXDst, nYDst, width, height,
surface->data, gdi->primary->hdc->format,
gdiSurface->scanline, 0, 0, NULL, FREERDP_FLIP_NONE))
- return FALSE;
+ goto fail;
if ((nXDst > INT32_MAX) || (nYDst > INT32_MAX) || (width > INT32_MAX) || (height > INT32_MAX))
- return FALSE;
+ goto fail;
+
gdi_InvalidateRegion(gdi->primary->hdc, (INT32)nXDst, (INT32)nYDst, (INT32)width, (INT32)height);
}
- update->EndPaint(gdi->context);
- return TRUE;
+
+ rc = TRUE;
+fail:
+
+ if (!update_end_paint(update))
+ return FALSE;
+
+ return rc;
}
static BOOL gdiVideoDeleteSurface(VideoClientContext* video, VideoSurface* surface)