diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 018a8e9c5..568c66504 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -69,7 +69,7 @@ static int wf_create_console(void) return 0; } -static BOOL wf_sw_end_paint(rdpContext* context) +static BOOL wf_end_paint(rdpContext* context) { int i; rdpGdi* gdi; @@ -95,6 +95,7 @@ static BOOL wf_sw_end_paint(rdpContext* context) invalidRect.top = cinvalid[i].y; invalidRect.right = cinvalid[i].x + cinvalid[i].w; invalidRect.bottom = cinvalid[i].y + cinvalid[i].h; + region16_union_rect(&invalidRegion, &invalidRegion, &invalidRect); } @@ -115,11 +116,6 @@ static BOOL wf_sw_end_paint(rdpContext* context) return TRUE; } -static BOOL wf_hw_end_paint(rdpContext* context) -{ - return TRUE; -} - static BOOL wf_begin_paint(rdpContext* context) { HGDI_DC hdc; @@ -210,9 +206,9 @@ static BOOL wf_pre_connect(freerdp* instance) settings->OrderSupport[NEG_LINETO_INDEX] = TRUE; settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE; settings->OrderSupport[NEG_MEMBLT_INDEX] = settings->BitmapCacheEnabled; - settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE; + settings->OrderSupport[NEG_MEM3BLT_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled; - settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE; + settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = settings->BitmapCacheEnabled; settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE; settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE; settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE; @@ -273,6 +269,9 @@ static BOOL wf_pre_connect(freerdp* instance) return FALSE; } + if (!freerdp_client_load_addins(context->channels, instance->settings)) + return -1; + freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout, (int) GetKeyboardLayout(0) & 0x0000FFFF); PubSub_SubscribeChannelConnected(instance->context->pubSub, @@ -370,13 +369,10 @@ static BOOL wf_post_connect(freerdp* instance) PubSub_OnEmbedWindow(context->pubSub, context, &e); ShowWindow(wfc->hwnd, SW_SHOWNORMAL); UpdateWindow(wfc->hwnd); + instance->update->BeginPaint = wf_begin_paint; instance->update->DesktopResize = wf_desktop_resize; - - if (settings->SoftwareGdi) - instance->update->EndPaint = wf_sw_end_paint; - else - instance->update->EndPaint = wf_hw_end_paint; + instance->update->EndPaint = wf_end_paint; pointer_cache_register_callbacks(instance->update); wf_register_pointer(context->graphics); @@ -1028,9 +1024,6 @@ static int wfreerdp_client_start(rdpContext* context) if (!wfc->keyboardThread) return -1; - if (!freerdp_client_load_addins(context->channels, instance->settings)) - return -1; - wfc->thread = CreateThread(NULL, 0, wf_client_thread, (void*) instance, 0, &wfc->mainThreadId); diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c index 4f3f69535..d12001f84 100644 --- a/client/Windows/wf_gdi.c +++ b/client/Windows/wf_gdi.c @@ -64,7 +64,7 @@ static const BYTE wf_rop2_table[] = }; static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, - UINT32* color, UINT32* format) + COLORREF* color, UINT32* format) { rdpGdi* gdi; rdpSettings* settings; @@ -705,6 +705,68 @@ static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) return TRUE; } +static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) +{ + BOOL rc = FALSE; + HDC hdc; + wfBitmap* bitmap; + wfContext* wfc = (wfContext*)context; + COLORREF fgcolor, bgcolor, orgColor; + HBRUSH orgBrush = NULL, brush = NULL; + + if (!context || !mem3blt) + return FALSE; + + bitmap = (wfBitmap*) mem3blt->bitmap; + + if (!bitmap || !wfc->drawing || !wfc->drawing->hdc) + return FALSE; + + hdc = wfc->drawing->hdc; + + if (!wf_decode_color(wfc, mem3blt->foreColor, &fgcolor, NULL)) + return FALSE; + + if (!wf_decode_color(wfc, mem3blt->backColor, &bgcolor, NULL)) + return FALSE; + + orgColor = SetTextColor(hdc, fgcolor); + switch(mem3blt->brush.style) + { + case GDI_BS_SOLID: + brush = CreateSolidBrush(fgcolor); + break; + case GDI_BS_HATCHED: + + case GDI_BS_PATTERN: + { + HBITMAP bmp = CreateBitmap(8, 8, 1, mem3blt->brush.bpp, mem3blt->brush.data); + brush = CreatePatternBrush(bmp); + } + break; + default: + goto fail; + } + + orgBrush = SelectObject(hdc, brush); + if (!BitBlt(hdc, mem3blt->nLeftRect, mem3blt->nTopRect, + mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc, + mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop))) + goto fail; + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, + mem3blt->nHeight); + + rc = TRUE; + +fail: + if (brush) + SelectObject(hdc, orgBrush); + SetTextColor(hdc, orgColor); + return rc; +} + static BOOL wf_gdi_surface_frame_marker(rdpContext* context, const SURFACE_FRAME_MARKER* surface_frame_marker) { @@ -741,6 +803,7 @@ void wf_gdi_register_update_callbacks(rdpUpdate* update) primary->LineTo = wf_gdi_line_to; primary->Polyline = wf_gdi_polyline; primary->MemBlt = wf_gdi_memblt; + primary->Mem3Blt = wf_gdi_mem3blt; update->SurfaceFrameMarker = wf_gdi_surface_frame_marker; }