#define TAG CLIENT_TAG("windows")
-int wf_create_console(void)
+static int wf_create_console(void)
{
if (!AllocConsole())
return 1;
return 0;
}
-BOOL wf_sw_begin_paint(wfContext* wfc)
+static BOOL wf_sw_begin_paint(rdpContext* context)
{
- rdpGdi* gdi = ((rdpContext*) wfc)->gdi;
+ rdpGdi* gdi = context->gdi;
gdi->primary->hdc->hwnd->invalid->null = 1;
gdi->primary->hdc->hwnd->ninvalid = 0;
return TRUE;
}
-BOOL wf_sw_end_paint(wfContext* wfc)
+static BOOL wf_sw_end_paint(rdpContext* context)
{
int i;
rdpGdi* gdi;
HGDI_RGN cinvalid;
REGION16 invalidRegion;
RECTANGLE_16 invalidRect;
- const RECTANGLE_16* extents;
- rdpContext* context = (rdpContext*) wfc;
+ const RECTANGLE_16* extents;
+ wfContext* wfc = (wfContext*)context;
gdi = context->gdi;
return TRUE;
}
-BOOL wf_sw_desktop_resize(wfContext* wfc)
+static BOOL wf_sw_desktop_resize(rdpContext* context)
{
- rdpGdi* gdi;
- rdpContext* context;
+ rdpGdi* gdi;
rdpSettings* settings;
- freerdp* instance = wfc->instance;
+ wfContext* wfc = (wfContext*)context;
- context = (rdpContext*) wfc;
- settings = wfc->instance->settings;
- gdi = context->gdi;
+ if (!context || !context->instance)
+ return FALSE;
- wfc->width = settings->DesktopWidth;
- wfc->height = settings->DesktopHeight;
+ settings = context->instance->settings;
+ gdi = context->gdi;
+ if (!gdi || !settings)
+ return FALSE;
- gdi->primary->bitmap->data = NULL;
- gdi_free(instance);
+ if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
+ return FALSE;
if (wfc->primary)
{
+ UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
wf_image_free(wfc->primary);
- wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL);
+ wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL);
}
- if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, wfc->primary->pdata))
- return FALSE;
-
- gdi = instance->context->gdi;
- wfc->hdc = gdi->primary->hdc;
-
return TRUE;
}
-BOOL wf_hw_begin_paint(wfContext* wfc)
+static BOOL wf_hw_begin_paint(rdpContext* context)
{
- wfc->hdc->hwnd->invalid->null = 1;
- wfc->hdc->hwnd->ninvalid = 0;
+ HGDI_DC hdc;
+
+ if (!context || !context->gdi || !context->gdi->hdc)
+ return FALSE;
+ hdc = context->gdi->hdc;
+ if (!hdc || !hdc->hwnd || !hdc->hwnd->invalid)
+ return FALSE;
+
+ hdc->hwnd->invalid->null = 1;
+ hdc->hwnd->ninvalid = 0;
return TRUE;
}
-BOOL wf_hw_end_paint(wfContext* wfc)
+static BOOL wf_hw_end_paint(rdpContext* context)
{
return TRUE;
}
-BOOL wf_hw_desktop_resize(wfContext* wfc)
+static BOOL wf_hw_desktop_resize(rdpContext* context)
{
BOOL same;
RECT rect;
rdpSettings* settings;
+ wfContext* wfc = (wfContext*)context;
- settings = wfc->instance->settings;
+ if (!context || !context->settings)
+ return FALSE;
- wfc->width = settings->DesktopWidth;
- wfc->height = settings->DesktopHeight;
+ settings = context->settings;
if (wfc->primary)
{
+ UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
same = (wfc->primary == wfc->drawing) ? TRUE : FALSE;
wf_image_free(wfc->primary);
- wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL);
+ wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL);
if (same)
wfc->drawing = wfc->primary;
if (wfc->fullscreen != TRUE)
{
if (wfc->hwnd)
- SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, wfc->width + wfc->diff.x, wfc->height + wfc->diff.y, SWP_NOMOVE);
+ SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x, settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE);
}
else
{
return TRUE;
}
-BOOL wf_pre_connect(freerdp* instance)
+static BOOL wf_pre_connect(freerdp* instance)
{
wfContext* wfc;
int desktopWidth;
rdpContext* context;
rdpSettings* settings;
+ if (!instance || !instance->context || !instance->settings)
+ return FALSE;
+
context = instance->context;
wfc = (wfContext*) instance->context;
- wfc->instance = instance;
- wfc->codecs = instance->context->codecs;
+ wfc->instance = instance;
settings = instance->settings;
if (wfc->fullscreen)
wfc->fs_toggle = 1;
- wfc->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
- ZeroMemory(wfc->clrconv, sizeof(CLRCONV));
-
- wfc->clrconv->palette = NULL;
- wfc->clrconv->alpha = FALSE;
-
- if (!(instance->context->cache = cache_new(settings)))
- return FALSE;
-
desktopWidth = settings->DesktopWidth;
desktopHeight = settings->DesktopHeight;
return TRUE;
}
-void wf_add_system_menu(wfContext* wfc)
+static void wf_add_system_menu(wfContext* wfc)
{
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
}
}
-BOOL wf_post_connect(freerdp* instance)
+static BOOL wf_post_connect(freerdp* instance)
{
rdpGdi* gdi;
DWORD dwStyle;
wfc = (wfContext*) instance->context;
cache = instance->context->cache;
- wfc->dstBpp = 32;
- wfc->width = settings->DesktopWidth;
- wfc->height = settings->DesktopHeight;
+ UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
+ wfc->format = PIXEL_FORMAT_RGBX32;
+ wfc->primary = wf_image_new(wfc,settings->DesktopWidth, settings->DesktopHeight, format, NULL);
- if (settings->SoftwareGdi)
- {
- wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL);
+ if (!gdi_init_ex(instance, wfc->format, 0, wfc->primary->pdata, wf_image_free))
+ return FALSE;
- if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, wfc->primary->pdata))
- return FALSE;
-
- gdi = instance->context->gdi;
- wfc->hdc = gdi->primary->hdc;
- }
- else
+ gdi = instance->context->gdi;
+ if (!settings->SoftwareGdi)
{
- wf_gdi_register_update_callbacks(instance->update);
- wfc->srcBpp = instance->settings->ColorDepth;
- wfc->primary = wf_image_new(wfc, wfc->width, wfc->height, wfc->dstBpp, NULL);
-
- if (!(wfc->hdc = gdi_GetDC()))
- return FALSE;
-
- wfc->hdc->bitsPerPixel = wfc->dstBpp;
- wfc->hdc->bytesPerPixel = wfc->dstBpp / 8;
-
- wfc->hdc->alpha = wfc->clrconv->alpha;
- wfc->hdc->invert = wfc->clrconv->invert;
-
- wfc->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND));
- wfc->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0);
- wfc->hdc->hwnd->invalid->null = 1;
-
- wfc->hdc->hwnd->count = 32;
- wfc->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfc->hdc->hwnd->count);
- wfc->hdc->hwnd->ninvalid = 0;
-
- if (settings->RemoteFxCodec)
- {
- wfc->tile = wf_image_new(wfc, 64, 64, 32, NULL);
- }
+ UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
+ wf_gdi_register_update_callbacks(instance->update);
+ wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL);
}
if (settings->WindowTitle != NULL)
wf_add_system_menu(wfc);
- BitBlt(wfc->primary->hdc, 0, 0, wfc->width, wfc->height, NULL, 0, 0, BLACKNESS);
+ BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight, NULL, 0, 0, BLACKNESS);
wfc->drawing = wfc->primary;
EventArgsInit(&e, "wfreerdp");
brush_cache_register_callbacks(instance->update);
bitmap_cache_register_callbacks(instance->update);
offscreen_cache_register_callbacks(instance->update);
- wf_register_graphics(context->graphics);
- instance->update->BitmapUpdate = wf_gdi_bitmap_update;
+ wf_register_graphics(context->graphics);
}
if (freerdp_channels_post_connect(context->channels, instance) != CHANNEL_RC_OK)
return wf_authenticate_raw(instance, tmp, username, password, domain);
}
-DWORD wf_verify_certificate(freerdp* instance,
+static DWORD wf_verify_certificate(freerdp* instance,
const char* common_name,
const char* subject,
const char* issuer,
return FALSE;
}
-void* wf_input_thread(void* arg)
+static void* wf_input_thread(void* arg)
{
int status;
wMessage message;
return NULL;
}
-DWORD WINAPI wf_client_thread(LPVOID lpParam)
+static DWORD WINAPI wf_client_thread(LPVOID lpParam)
{
MSG msg;
int width;
return 0;
}
-DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
+static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
{
MSG msg;
BOOL status;
return (DWORD) NULL;
}
-rdpSettings* freerdp_client_get_settings(wfContext* wfc)
+static rdpSettings* freerdp_client_get_settings(wfContext* wfc)
{
return wfc->instance->settings;
}
-int freerdp_client_focus_in(wfContext* wfc)
+static int freerdp_client_focus_in(wfContext* wfc)
{
PostThreadMessage(wfc->mainThreadId, WM_SETFOCUS, 0, 1);
return 0;
}
-int freerdp_client_focus_out(wfContext* wfc)
+static int freerdp_client_focus_out(wfContext* wfc)
{
PostThreadMessage(wfc->mainThreadId, WM_KILLFOCUS, 0, 1);
return 0;
}
-int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
+static int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
{
WLog_DBG(TAG, "freerdp_client_set_window_size %d, %d", width, height);
wf_update_canvas_diff(wfc);
}
-BOOL wfreerdp_client_global_init(void)
+static BOOL wfreerdp_client_global_init(void)
{
WSADATA wsaData;
return TRUE;
}
-void wfreerdp_client_global_uninit(void)
+static void wfreerdp_client_global_uninit(void)
{
WSACleanup();
}
-BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context)
+static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context)
{
wfContext* wfc = (wfContext*) context;
return TRUE;
}
-void wfreerdp_client_free(freerdp* instance, rdpContext* context)
+static void wfreerdp_client_free(freerdp* instance, rdpContext* context)
{
if (!context)
return;
freerdp_channels_free(context->channels);
context->channels = NULL;
}
-
- if (context->cache)
- {
- cache_free(context->cache);
- context->cache = NULL;
- }
}
-int wfreerdp_client_start(rdpContext* context)
+static int wfreerdp_client_start(rdpContext* context)
{
HWND hWndParent;
HINSTANCE hInstance;
return 0;
}
-int wfreerdp_client_stop(rdpContext* context)
+static int wfreerdp_client_stop(rdpContext* context)
{
wfContext* wfc = (wfContext*) context;
rdpContext context;
DEFINE_RDP_CLIENT_COMMON();
+ freerdp* instance;
rdpSettings* settings;
- int width;
- int height;
+ UINT32 format; /* Local framebuffer color format */
+
int offset_x;
int offset_y;
int fs_toggle;
int client_x;
int client_y;
int client_width;
- int client_height;
- UINT32 bitmap_size;
- BYTE* bitmap_buffer;
+ int client_height;
HANDLE keyboardThread;
HCURSOR hDefaultCursor;
HWND hwnd;
- POINT diff;
- HGDI_DC hdc;
- UINT16 srcBpp;
- UINT16 dstBpp;
- rdpCodecs* codecs;
- freerdp* instance;
+ POINT diff;
+
wfBitmap* primary;
- wfBitmap* drawing;
- HCLRCONV clrconv;
+ wfBitmap* drawing;
HCURSOR cursor;
HBRUSH brush;
HBRUSH org_brush;
RECT update_rect;
RECT scale_update_rect;
- wfBitmap* tile;
DWORD mainThreadId;
DWORD keyboardThreadId;
#define X_POS(lParam) ((UINT16) (lParam & 0xFFFF))
#define Y_POS(lParam) ((UINT16) ((lParam >> 16) & 0xFFFF))
-BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop);
-void wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
+static BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop);
+static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
static BOOL g_flipping_in;
static BOOL g_flipping_out;
return 0;
}
-void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
+static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
{
+ rdpSettings* settings = wfc->instance->settings;
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
LPRECT rect;
- if (wfc->instance->settings->SmartSizing && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
+ if (settings->SmartSizing && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
{
rect = (LPRECT) wParam;
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
// Adjust height
- rect->bottom = rect->top + wfc->height * (rect->right - rect->left) / wfc->instance->settings->DesktopWidth;
+ rect->bottom = rect->top + settings->DesktopHeight * (rect->right - rect->left) / settings->DesktopWidth;
break;
case WMSZ_TOP:
case WMSZ_BOTTOM:
case WMSZ_TOPRIGHT:
// Adjust width
- rect->right = rect->left + wfc->width * (rect->bottom - rect->top) / wfc->instance->settings->DesktopHeight;
+ rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) / settings->DesktopHeight;
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
// adjust width
- rect->left = rect->right - (wfc->width * (rect->bottom - rect->top) / wfc->instance->settings->DesktopHeight);
+ rect->left = rect->right - (settings->DesktopWidth * (rect->bottom - rect->top) / settings->DesktopHeight);
break;
}
LONG_PTR ptr;
wfContext* wfc;
int x, y, w, h;
- PAINTSTRUCT ps;
- rdpInput* input;
+ PAINTSTRUCT ps;
BOOL processed;
RECT windowRect;
MINMAXINFO* minmax;
if (wfc != NULL)
{
- input = wfc->instance->input;
+ rdpInput* input = wfc->instance->input;
+ rdpSettings* settings = wfc->instance->settings;
switch (Msg)
{
if (!wfc->fullscreen)
{
// add window decoration
- minmax->ptMaxTrackSize.x = wfc->width + wfc->diff.x;
- minmax->ptMaxTrackSize.y = wfc->height + wfc->diff.y;
+ minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x;
+ minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y;
}
}
break;
BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop)
{
- int ww, wh, dw, dh;
+ rdpSettings* settings;
+ UINT32 ww, wh, dw, dh;
+ settings = wfc->instance->settings;
if (!wfc->client_width)
- wfc->client_width = wfc->width;
+ wfc->client_width = settings->DesktopWidth;
if (!wfc->client_height)
- wfc->client_height = wfc->height;
+ wfc->client_height = settings->DesktopHeight;
ww = wfc->client_width;
wh = wfc->client_height;
- dw = wfc->instance->settings->DesktopWidth;
- dh = wfc->instance->settings->DesktopHeight;
+ dw = settings->DesktopWidth;
+ dh = settings->DesktopHeight;
if (!ww)
ww = dw;
return TRUE;
}
-void wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
+static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
int ww, wh, dw, dh;
rdpContext* context;
+ rdpSettings* settings = wfc->context.settings;
MouseEventEventArgs eventArgs;
if (!wfc->client_width)
- wfc->client_width = wfc->width;
+ wfc->client_width = settings->DesktopWidth;
if (!wfc->client_height)
- wfc->client_height = wfc->height;
+ wfc->client_height = settings->DesktopHeight;
ww = wfc->client_width;
wh = wfc->client_height;
- dw = wfc->instance->settings->DesktopWidth;
- dh = wfc->instance->settings->DesktopHeight;
+ dw = settings->DesktopWidth;
+ dh = settings->DesktopHeight;
- if (!wfc->instance->settings->SmartSizing || ((ww == dw) && (wh == dh)))
+ if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
input->MouseEvent(input, flags, x + wfc->xCurrentScroll, y + wfc->yCurrentScroll);
else
input->MouseEvent(input, flags, x * dw / ww + wfc->xCurrentScroll, y * dh / wh + wfc->yCurrentScroll);
eventArgs.y = y;
context = (rdpContext*) wfc;
PubSub_OnMouseEvent(context->pubSub, context, &eventArgs);
+
+ return TRUE;
}
#include <freerdp/codec/bitmap.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/codec/nsc.h>
+#include <freerdp/gdi/gdi.h>
#include "wf_client.h"
#include "wf_graphics.h"
wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
{
wfBitmap* glyph_bmp;
- glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, 1, glyph->aj);
+ glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO, glyph->aj);
return glyph_bmp;
}
return cdata;
}
-HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, int bpp)
+static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UINT32 bpp)
{
- int i;
+ UINT32 i;
HBRUSH br;
LOGBRUSH lbr;
BYTE* cdata;
{
if (brush->bpp > 1)
{
- pattern = wf_create_dib(wfc, 8, 8, bpp, brush->data, NULL);
+ UINT32 format = gdi_get_pixel_format(bpp, FALSE);
+ pattern = wf_create_dib(wfc, 8, 8, format, brush->data, NULL);
lbr.lbHatch = (ULONG_PTR) pattern;
}
else
return br;
}
-void wf_scale_rect(wfContext* wfc, RECT* source)
+static BOOL wf_scale_rect(wfContext* wfc, RECT* source)
{
- int ww, wh, dw, dh;
+ UINT32 ww, wh, dw, dh;
+ rdpSettings* settings;
+
+ if (!wfc || !source || !wfc->instance)
+ return FALSE;
+
+ settings = wfc->instance->settings;
+ if (!settings)
+ return FALSE;
+ dw = settings->DesktopWidth;
+ dh = settings->DesktopHeight;
if (!wfc->client_width)
- wfc->client_width = wfc->width;
+ wfc->client_width = dw;
if (!wfc->client_height)
- wfc->client_height = wfc->height;
+ wfc->client_height = dh;
ww = wfc->client_width;
wh = wfc->client_height;
- dw = wfc->instance->settings->DesktopWidth;
- dh = wfc->instance->settings->DesktopHeight;
if (!ww)
ww = dw;
source->top -= wfc->yCurrentScroll;
source->left -= wfc->xCurrentScroll;
source->right -= wfc->xCurrentScroll;
+
+ return TRUE;
}
-void wf_invalidate_region(wfContext* wfc, int x, int y, int width, int height)
+void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height)
{
RECT rect;
+ rdpGdi* gdi = wfc->context.gdi;
wfc->update_rect.left = x + wfc->offset_x;
wfc->update_rect.top = y + wfc->offset_y;
rect.top = y;
rect.bottom = height;
wf_scale_rect(wfc, &rect);
- gdi_InvalidateRegion(wfc->hdc, rect.left, rect.top, rect.right, rect.bottom);
+ gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right, rect.bottom);
}
void wf_update_offset(wfContext* wfc)
{
+ rdpSettings* settings;
+
+ settings = wfc->instance->settings;
if (wfc->fullscreen)
{
if (wfc->instance->settings->UseMultimon)
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- wfc->offset_x = (w - wfc->width) / 2;
+ wfc->offset_x = (w - settings->DesktopWidth) / 2;
if (wfc->offset_x < x)
wfc->offset_x = x;
- wfc->offset_y = (h - wfc->height) / 2;
+ wfc->offset_y = (h - settings->DesktopHeight) / 2;
if (wfc->offset_y < y)
wfc->offset_y = y;
}
else
{
- wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - wfc->width) / 2;
+ wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - settings->DesktopWidth) / 2;
if (wfc->offset_x < 0)
wfc->offset_x = 0;
- wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - wfc->height) / 2;
+ wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - settings->DesktopHeight) / 2;
if (wfc->offset_y < 0)
wfc->offset_y = 0;
}
void wf_resize_window(wfContext* wfc)
{
+ rdpSettings* settings;
+
+ settings = wfc->instance->settings;
if (wfc->fullscreen)
{
if(wfc->instance->settings->UseMultimon)
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD);
/* Now resize to get full canvas size and room for caption and borders */
- SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, wfc->width, wfc->height, SWP_FRAMECHANGED);
+ SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth, settings->DesktopHeight, SWP_FRAMECHANGED);
wf_update_canvas_diff(wfc);
- SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, wfc->width + wfc->diff.x, wfc->height + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
+ SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x, settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
}
else
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX);
if (!wfc->client_height)
- wfc->client_height = wfc->height;
+ wfc->client_height = settings->DesktopHeight;
if (!wfc->client_width)
- wfc->client_width = wfc->width;
+ wfc->client_width = settings->DesktopWidth;
if (!wfc->client_x)
wfc->client_x = 10;
}
}
-BOOL wf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
+static BOOL wf_gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palette)
{
- HDC hdc;
- int status;
- int nXDst;
- int nYDst;
- int nXSrc;
- int nYSrc;
- int nWidth;
- int nHeight;
- HBITMAP dib;
- UINT32 index;
- BYTE* pSrcData;
- BYTE* pDstData;
- UINT32 SrcSize;
- BOOL compressed;
- UINT32 SrcFormat;
- UINT32 bitsPerPixel;
- UINT32 bytesPerPixel;
- BITMAP_DATA* bitmap;
- rdpCodecs* codecs = context->codecs;
- wfContext* wfc = (wfContext*) context;
-
- hdc = CreateCompatibleDC(GetDC(NULL));
- if (!hdc)
- return FALSE;
-
- for (index = 0; index < bitmapUpdate->number; index++)
- {
- bitmap = &(bitmapUpdate->rectangles[index]);
-
- nXSrc = 0;
- nYSrc = 0;
-
- nXDst = bitmap->destLeft;
- nYDst = bitmap->destTop;
-
- nWidth = bitmap->width;
- nHeight = bitmap->height;
-
- pSrcData = bitmap->bitmapDataStream;
- SrcSize = bitmap->bitmapLength;
-
- compressed = bitmap->compressed;
- bitsPerPixel = bitmap->bitsPerPixel;
- bytesPerPixel = (bitsPerPixel + 7) / 8;
-
- SrcFormat = gdi_get_pixel_format(bitsPerPixel, TRUE);
-
- if (wfc->bitmap_size < (UINT32) (nWidth * nHeight * 4))
- {
- wfc->bitmap_size = nWidth * nHeight * 4;
- wfc->bitmap_buffer = (BYTE*) _aligned_realloc(wfc->bitmap_buffer, wfc->bitmap_size, 16);
-
- if (!wfc->bitmap_buffer)
- return FALSE;
- }
-
- if (compressed)
- {
- pDstData = wfc->bitmap_buffer;
-
- if (bitsPerPixel < 32)
- {
- if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return FALSE;
-
- status = interleaved_decompress(codecs->interleaved, pSrcData, SrcSize, bitsPerPixel,
- &pDstData, PIXEL_FORMAT_XRGB32, nWidth * 4, 0, 0, nWidth, nHeight, NULL);
- }
- else
- {
- if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_PLANAR,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return FALSE;
-
- status = planar_decompress(codecs->planar, pSrcData, SrcSize, &pDstData,
- PIXEL_FORMAT_XRGB32, nWidth * 4, 0, 0, nWidth, nHeight, TRUE);
- }
-
- if (status < 0)
- {
- WLog_ERR(TAG, "bitmap decompression failure");
- return FALSE;
- }
-
- pSrcData = wfc->bitmap_buffer;
- }
-
- dib = wf_create_dib(wfc, nWidth, nHeight, 32, pSrcData, NULL);
- SelectObject(hdc, dib);
-
- nWidth = bitmap->destRight - bitmap->destLeft + 1; /* clip width */
- nHeight = bitmap->destBottom - bitmap->destTop + 1; /* clip height */
-
- BitBlt(wfc->primary->hdc, nXDst, nYDst, nWidth, nHeight, hdc, 0, 0, SRCCOPY);
-
- gdi_InvalidateRegion(wfc->hdc, nXDst, nYDst, nWidth, nHeight);
-
- DeleteObject(dib);
- }
-
- ReleaseDC(NULL, hdc);
- return TRUE;
-}
-
-void wf_gdi_palette_update(wfContext* wfc, PALETTE_UPDATE* palette)
-{
-
+ return TRUE;
}
void wf_set_null_clip_rgn(wfContext* wfc)
DeleteObject(clip);
}
-void wf_gdi_set_bounds(wfContext* wfc, rdpBounds* bounds)
+static BOOL wf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
{
HRGN hrgn;
+ wfContext* wfc = (wfContext*)context;
+
+ if (!context || !bounds)
+ return FALSE;
if (bounds != NULL)
{
DeleteObject(hrgn);
}
else
- {
SelectClipRgn(wfc->drawing->hdc, NULL);
- }
+
+ return TRUE;
}
-void wf_gdi_dstblt(wfContext* wfc, DSTBLT_ORDER* dstblt)
+static BOOL wf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{
- BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop));
+ wfContext* wfc = (wfContext*)context;
+
+ if (!context || !dstblt)
+ return FALSE;
+
+
+ if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
+ dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
+ return FALSE;
wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight);
+
+ return TRUE;
}
-void wf_gdi_patblt(wfContext* wfc, PATBLT_ORDER* patblt)
+static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
HBRUSH brush;
HBRUSH org_brush;
UINT32 bgcolor;
COLORREF org_bkcolor;
COLORREF org_textcolor;
+ BOOL rc;
+ wfContext* wfc = (wfContext*)context;
- fgcolor = freerdp_color_convert_bgr(patblt->foreColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
- bgcolor = freerdp_color_convert_bgr(patblt->backColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
+ if (!context || !patblt)
+ return FALSE;
- brush = wf_create_brush(wfc, &patblt->brush, fgcolor, wfc->srcBpp);
+ if (!gdi_decode_color(context->gdi, patblt->foreColor, &fgcolor, NULL))
+ return FALSE;
+ if (!gdi_decode_color(context->gdi, patblt->backColor, &bgcolor, NULL))
+ return FALSE;
+
+ brush = wf_create_brush(wfc, &patblt->brush, fgcolor, context->settings->ColorDepth);
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);
- PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
+ rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
SelectObject(wfc->drawing->hdc, org_brush);
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
+ return rc;
}
-void wf_gdi_scrblt(wfContext* wfc, SCRBLT_ORDER* scrblt)
+static BOOL wf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
{
- BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
+ wfContext *wfc = (wfContext*)context;
+
+ if (!context || !scrblt || !wfc->drawing)
+ return FALSE;
+
+ if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight, wfc->primary->hdc,
- scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop));
+ scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)))
+ return FALSE;
wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight);
+
+ return TRUE;
}
-void wf_gdi_opaque_rect(wfContext* wfc, OPAQUE_RECT_ORDER* opaque_rect)
+static BOOL wf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
{
RECT rect;
HBRUSH brush;
UINT32 brush_color;
+ wfContext *wfc = (wfContext*)context;
+
+ if (!context || !opaque_rect)
+ return FALSE;
- brush_color = freerdp_color_convert_var_bgr(opaque_rect->color, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
+ if (!gdi_decode_color(context->gdi, opaque_rect->color, &brush_color, NULL))
+ return FALSE;
rect.left = opaque_rect->nLeftRect;
rect.top = opaque_rect->nTopRect;
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1);
+
+ return TRUE;
}
-void wf_gdi_multi_opaque_rect(wfContext* wfc, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
+static BOOL wf_gdi_multi_opaque_rect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
- int i;
+ UINT32 i;
RECT rect;
HBRUSH brush;
- UINT32 brush_color;
- DELTA_RECT* rectangle;
+ UINT32 brush_color;
+ wfContext *wfc = (wfContext*)context;
+
+ if (!context || !multi_opaque_rect)
+ return FALSE;
- brush_color = freerdp_color_convert_var_rgb(multi_opaque_rect->color, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
+ if (!gdi_decode_color(context->gdi, multi_opaque_rect->color, &brush_color, NULL))
+ return FALSE;
- for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++)
+ for (i = 0; i < multi_opaque_rect->numRectangles; i++)
{
- rectangle = &multi_opaque_rect->rectangles[i];
+ const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
rect.left = rectangle->left;
rect.top = rectangle->top;
DeleteObject(brush);
}
+
+ return TRUE;
}
-void wf_gdi_line_to(wfContext* wfc, LINE_TO_ORDER* line_to)
+static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
{
HPEN pen;
HPEN org_pen;
int x, y, w, h;
UINT32 pen_color;
+ wfContext *wfc = (wfContext*)context;
- pen_color = freerdp_color_convert_var_bgr(line_to->penColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
+ if (!context || !line_to)
+ return FALSE;
+ if (!gdi_decode_color(context->gdi, line_to->penColor, &pen_color, NULL))
+ return FALSE;
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
SelectObject(wfc->drawing->hdc, org_pen);
DeleteObject(pen);
+
+ return TRUE;
}
-void wf_gdi_polyline(wfContext* wfc, POLYLINE_ORDER* polyline)
+static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
{
int org_rop2;
HPEN hpen;
HPEN org_hpen;
UINT32 pen_color;
+ wfContext *wfc = (wfContext*)context;
- pen_color = freerdp_color_convert_var_bgr(polyline->penColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
+ if (!context || !polyline)
+ return FALSE;
+ if (!gdi_decode_color(context->gdi, polyline->penColor, &pen_color, NULL))
+ return FALSE;
hpen = CreatePen(0, 1, pen_color);
org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2);
SelectObject(wfc->drawing->hdc, org_hpen);
wf_set_rop2(wfc->drawing->hdc, org_rop2);
DeleteObject(hpen);
+
+ return TRUE;
}
-void wf_gdi_memblt(wfContext* wfc, MEMBLT_ORDER* memblt)
+static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
wfBitmap* bitmap;
+ wfContext *wfc = (wfContext*)context;
+
+ if (!context || !memblt)
+ return FALSE;
bitmap = (wfBitmap*) memblt->bitmap;
+ if (!bitmap || !wfc->drawing || !wfc->drawing->hdc)
+ return FALSE;
BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
memblt->nWidth, memblt->nHeight, bitmap->hdc,
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
-}
-
-void wf_gdi_surface_bits(wfContext* wfc, SURFACE_BITS_COMMAND* surface_bits_command)
-{
- int i, j;
- int tx, ty;
- RFX_MESSAGE* message;
- BITMAPINFO bitmap_info;
-
- if (surface_bits_command->codecID == RDP_CODEC_ID_REMOTEFX)
- {
- if (!freerdp_client_codecs_prepare(wfc->codecs, FREERDP_CODEC_REMOTEFX,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return;
-
- if (!(message = rfx_process_message(wfc->codecs->rfx, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength)))
- {
- WLog_ERR(TAG, "Failed to process RemoteFX message");
- return;
- }
-
- /* blit each tile */
- for (i = 0; i < message->numTiles; i++)
- {
- tx = message->tiles[i]->x + surface_bits_command->destLeft;
- ty = message->tiles[i]->y + surface_bits_command->destTop;
-
- freerdp_image_convert(message->tiles[i]->data, wfc->tile->pdata, 64, 64, 32, 32, wfc->clrconv);
-
- for (j = 0; j < message->numRects; j++)
- {
- wf_set_clip_rgn(wfc,
- surface_bits_command->destLeft + message->rects[j].x,
- surface_bits_command->destTop + message->rects[j].y,
- message->rects[j].width, message->rects[j].height);
-
- BitBlt(wfc->primary->hdc, tx, ty, 64, 64, wfc->tile->hdc, 0, 0, SRCCOPY);
- }
- }
-
- wf_set_null_clip_rgn(wfc);
- /* invalidate regions */
- for (i = 0; i < message->numRects; i++)
- {
- tx = surface_bits_command->destLeft + message->rects[i].x;
- ty = surface_bits_command->destTop + message->rects[i].y;
- wf_invalidate_region(wfc, tx, ty, message->rects[i].width, message->rects[i].height);
- }
-
- rfx_message_free(wfc->codecs->rfx, message);
- }
- else if (surface_bits_command->codecID == RDP_CODEC_ID_NSCODEC)
- {
- if (!freerdp_client_codecs_prepare(wfc->codecs, FREERDP_CODEC_NSCODEC,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return;
-
- nsc_process_message(wfc->codecs->nsc, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height,
- surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
- ZeroMemory(&bitmap_info, sizeof(bitmap_info));
- bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
- bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
- bitmap_info.bmiHeader.biPlanes = 1;
- bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
- bitmap_info.bmiHeader.biCompression = BI_RGB;
- SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
- surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
- wfc->codecs->nsc->BitmapData, &bitmap_info, DIB_RGB_COLORS);
- wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
- surface_bits_command->width, surface_bits_command->height);
- }
- else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE)
- {
- ZeroMemory(&bitmap_info, sizeof(bitmap_info));
- bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
- bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
- bitmap_info.bmiHeader.biPlanes = 1;
- bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
- bitmap_info.bmiHeader.biCompression = BI_RGB;
- SetDIBitsToDevice(wfc->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
- surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
- surface_bits_command->bitmapData, &bitmap_info, DIB_RGB_COLORS);
- wf_invalidate_region(wfc, surface_bits_command->destLeft, surface_bits_command->destTop,
- surface_bits_command->width, surface_bits_command->height);
- }
- else
- {
- WLog_ERR(TAG, "Unsupported codecID %d", surface_bits_command->codecID);
- }
+ return TRUE;
}
-void wf_gdi_surface_frame_marker(wfContext* wfc, SURFACE_FRAME_MARKER* surface_frame_marker)
+static BOOL wf_gdi_surface_frame_marker(rdpContext* context, const SURFACE_FRAME_MARKER* surface_frame_marker)
{
- rdpContext* context;
- rdpSettings* settings;
+ rdpSettings* settings;
+
+ if (!context || !surface_frame_marker || !context->instance)
+ return FALSE;
- context = (rdpContext*) wfc;
- settings = wfc->instance->settings;
+ settings = context->instance->settings;
+ if (!settings)
+ return FALSE;
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END && settings->FrameAcknowledge > 0)
{
IFCALL(context->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
}
+
+ return TRUE;
}
void wf_gdi_register_update_callbacks(rdpUpdate* update)
{
rdpPrimaryUpdate* primary = update->primary;
- update->Palette = (pPalette) wf_gdi_palette_update;
- update->SetBounds = (pSetBounds) wf_gdi_set_bounds;
-
- primary->DstBlt = (pDstBlt) wf_gdi_dstblt;
- primary->PatBlt = (pPatBlt) wf_gdi_patblt;
- primary->ScrBlt = (pScrBlt) wf_gdi_scrblt;
- primary->OpaqueRect = (pOpaqueRect) wf_gdi_opaque_rect;
- primary->DrawNineGrid = NULL;
- primary->MultiDstBlt = NULL;
- primary->MultiPatBlt = NULL;
- primary->MultiScrBlt = NULL;
- primary->MultiOpaqueRect = (pMultiOpaqueRect) wf_gdi_multi_opaque_rect;
- primary->MultiDrawNineGrid = NULL;
- primary->LineTo = (pLineTo) wf_gdi_line_to;
- primary->Polyline = (pPolyline) wf_gdi_polyline;
- primary->MemBlt = (pMemBlt) wf_gdi_memblt;
- primary->Mem3Blt = NULL;
- primary->SaveBitmap = NULL;
- primary->GlyphIndex = NULL;
- primary->FastIndex = NULL;
- primary->FastGlyph = NULL;
- primary->PolygonSC = NULL;
- primary->PolygonCB = NULL;
- primary->EllipseSC = NULL;
- primary->EllipseCB = NULL;
-
- update->SurfaceBits = (pSurfaceBits) wf_gdi_surface_bits;
- update->SurfaceFrameMarker = (pSurfaceFrameMarker) wf_gdi_surface_frame_marker;
+ update->Palette = wf_gdi_palette_update;
+ update->SetBounds = wf_gdi_set_bounds;
+
+ primary->DstBlt = wf_gdi_dstblt;
+ primary->PatBlt = wf_gdi_patblt;
+ primary->ScrBlt = wf_gdi_scrblt;
+ primary->OpaqueRect = wf_gdi_opaque_rect;
+ primary->MultiOpaqueRect = wf_gdi_multi_opaque_rect;
+ primary->LineTo = wf_gdi_line_to;
+ primary->Polyline = wf_gdi_polyline;
+ primary->MemBlt = wf_gdi_memblt;
+
+ update->SurfaceFrameMarker = wf_gdi_surface_frame_marker;
}
void wf_update_canvas_diff(wfContext* wfc)
#include "wf_client.h"
-void wf_invalidate_region(wfContext* wfc, int x, int y, int width, int height);
-wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data);
+void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height);
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 bpp, const BYTE* data);
void wf_image_free(wfBitmap* image);
void wf_update_offset(wfContext* wfc);
void wf_resize_window(wfContext* wfc);
void wf_toggle_fullscreen(wfContext* wfc);
-BOOL wf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate);
void wf_gdi_register_update_callbacks(rdpUpdate* update);
void wf_update_canvas_diff(wfContext* wfc);
#define TAG CLIENT_TAG("windows")
-HBITMAP wf_create_dib(wfContext* wfc, int width, int height, int bpp, BYTE* data, BYTE** pdata)
+HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height, UINT32 srcFormat, const BYTE* data, BYTE** pdata)
{
HDC hdc;
int negHeight;
HBITMAP bitmap;
BITMAPINFO bmi;
BYTE* cdata = NULL;
+ UINT32 dstFormat = wfc->format;
/**
* See: http://msdn.microsoft.com/en-us/library/dd183376
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = negHeight;
bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = wfc->dstBpp;
+ bmi.bmiHeader.biBitCount = GetBitsPerPixel(dstFormat);
bmi.bmiHeader.biCompression = BI_RGB;
bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &cdata, NULL, 0);
- if (data)
- freerdp_image_convert(data, cdata, width, height, bpp, wfc->dstBpp, wfc->clrconv);
+ if (data)
+ freerdp_image_copy(cdata, dstFormat, 0, 0, 0, width, height, data, srcFormat, 0, 0, 0, &wfc->context.gdi->palette);
if (pdata)
*pdata = cdata;
return bitmap;
}
-wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data)
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format, const BYTE* data)
{
HDC hdc;
wfBitmap* image;
image = (wfBitmap*) malloc(sizeof(wfBitmap));
image->hdc = CreateCompatibleDC(hdc);
- image->bitmap = wf_create_dib(wfc, width, height, bpp, data, &(image->pdata));
+ image->bitmap = wf_create_dib(wfc, width, height, format, data, &(image->pdata));
image->org_bitmap = (HBITMAP) SelectObject(image->hdc, image->bitmap);
ReleaseDC(NULL, hdc);
/* Bitmap Class */
-void wf_Bitmap_New(wfContext* wfc, rdpBitmap* bitmap)
+static BOOL wf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
HDC hdc;
+ wfContext* wfc = (wfContext*)context;
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
+ if (!context || !bitmap)
+ return FALSE;
+
wf_bitmap = (wfBitmap*) bitmap;
hdc = GetDC(NULL);
if (!bitmap->data)
wf_bitmap->bitmap = CreateCompatibleBitmap(hdc, bitmap->width, bitmap->height);
else
- wf_bitmap->bitmap = wf_create_dib(wfc, bitmap->width, bitmap->height, bitmap->bpp, bitmap->data, NULL);
+ wf_bitmap->bitmap = wf_create_dib(wfc, bitmap->width, bitmap->height, bitmap->format, bitmap->data, NULL);
wf_bitmap->org_bitmap = (HBITMAP) SelectObject(wf_bitmap->hdc, wf_bitmap->bitmap);
ReleaseDC(NULL, hdc);
+
+ return TRUE;
}
-void wf_Bitmap_Free(wfContext* wfc, rdpBitmap* bitmap)
+static void wf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
{
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
}
}
-void wf_Bitmap_Paint(wfContext* wfc, rdpBitmap* bitmap)
+static BOOL wf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
- int width, height;
+ BOOL rc;
+ UINT32 width, height;
+ wfContext* wfc = (wfContext*)context;
wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
+ if (!context || !bitmap)
+ return FALSE;
+
width = bitmap->right - bitmap->left + 1;
height = bitmap->bottom - bitmap->top + 1;
- BitBlt(wfc->primary->hdc, bitmap->left, bitmap->top,
- width, height, wf_bitmap->hdc, 0, 0, SRCCOPY);
+ rc = BitBlt(wfc->primary->hdc, bitmap->left, bitmap->top,
+ width, height, wf_bitmap->hdc, 0, 0, SRCCOPY);
wf_invalidate_region(wfc, bitmap->left, bitmap->top, width, height);
-}
-
-void wf_Bitmap_Decompress(wfContext* wfc, rdpBitmap* bitmap,
- BYTE* data, int width, int height, int bpp, int length, BOOL compressed, int codecId)
-{
- int status;
- UINT16 size;
- BYTE* pSrcData;
- BYTE* pDstData;
- UINT32 SrcSize;
- UINT32 SrcFormat;
- UINT32 bytesPerPixel;
-
- bytesPerPixel = (bpp + 7) / 8;
- size = width * height * 4;
-
- if (!bitmap->data)
- bitmap->data = (BYTE*) _aligned_malloc(size, 16);
- else
- bitmap->data = (BYTE*) _aligned_realloc(bitmap->data, size, 16);
-
- pSrcData = data;
- SrcSize = (UINT32) length;
- pDstData = bitmap->data;
-
- if (compressed)
- {
- if (bpp < 32)
- {
- if (!freerdp_client_codecs_prepare(wfc->codecs, FREERDP_CODEC_INTERLEAVED,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return;
-
- status = interleaved_decompress(wfc->codecs->interleaved, pSrcData, SrcSize, bpp,
- &pDstData, PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, NULL);
- }
- else
- {
- if (!freerdp_client_codecs_prepare(wfc->codecs, FREERDP_CODEC_PLANAR,
- wfc->instance->settings->DesktopWidth,
- wfc->instance->settings->DesktopHeight))
- return;
-
- status = planar_decompress(wfc->codecs->planar, pSrcData, SrcSize, &pDstData,
- PIXEL_FORMAT_XRGB32, width * 4, 0, 0, width, height, TRUE);
- }
-
- if (status < 0)
- {
- WLog_ERR(TAG, "Bitmap Decompression Failed");
- return;
- }
- }
- else
- {
- SrcFormat = gdi_get_pixel_format(bpp, TRUE);
-
- status = freerdp_image_copy(pDstData, PIXEL_FORMAT_XRGB32, width * 4, 0, 0,
- width, height, pSrcData, SrcFormat, width * bytesPerPixel, 0, 0, NULL);
- }
-
- bitmap->compressed = FALSE;
- bitmap->length = size;
- bitmap->bpp = 32;
-}
-void wf_Bitmap_SetSurface(wfContext* wfc, rdpBitmap* bitmap, BOOL primary)
-{
- if (primary)
- wfc->drawing = wfc->primary;
- else
- wfc->drawing = (wfBitmap*) bitmap;
+ return rc;
}
/* Pointer Class */
-void wf_Pointer_New(wfContext* wfc, rdpPointer* pointer)
+static BOOL wf_Pointer_New(rdpContext* context, rdpPointer* pointer)
{
HCURSOR hCur;
ICONINFO info;
- BYTE *data;
+ BYTE *data;
+ rdpGdi* gdi;
- info.fIcon = FALSE;
+ if (!context || !pointer)
+ return FALSE;
+
+ gdi = context->gdi;
+ if (!gdi)
+ return FALSE;
+
+ info.fIcon = FALSE;
info.xHotspot = pointer->xPos;
info.yHotspot = pointer->yPos;
- if (pointer->xorBpp == 1)
+
+ data = _aligned_malloc(GetBytesPerPixel(gdi->dstFormat) * pointer->width * pointer->height, 16);
+ if (!data)
+ return FALSE;
+
+ if (!freerdp_image_copy_from_pointer_data(data, gdi->dstFormat,
+ 0, 0, 0, pointer->width, pointer->height,
+ pointer->xorMaskData, pointer->lengthXorMask,
+ pointer->andMaskData, pointer->lengthAndMask,
+ pointer->xorBpp, &context->gdi->palette))
+ {
+ _aligned_free(data);
+ return FALSE;
+ }
+
+ if (pointer->xorBpp == 1)
{
data = (BYTE*) malloc(pointer->lengthAndMask + pointer->lengthXorMask);
CopyMemory(data, pointer->andMaskData, pointer->lengthAndMask);
else
{
data = (BYTE*) malloc(pointer->lengthAndMask);
- freerdp_bitmap_flip(pointer->andMaskData, data, (pointer->width + 7) / 8, pointer->height);
+// freerdp_bitmap_flip(pointer->andMaskData, data, (pointer->width + 7) / 8, pointer->height);
info.hbmMask = CreateBitmap(pointer->width, pointer->height, 1, 1, data);
free(data);
data = (BYTE*) malloc(pointer->lengthXorMask);
- freerdp_image_flip(pointer->xorMaskData, data, pointer->width, pointer->height, pointer->xorBpp);
+// freerdp_image_flip(pointer->xorMaskData, data, pointer->width, pointer->height, pointer->xorBpp);
info.hbmColor = CreateBitmap(pointer->width, pointer->height, 1, pointer->xorBpp, data);
free(data);
}
hCur = CreateIconIndirect(&info);
((wfPointer*) pointer)->cursor = hCur;
+
+ _aligned_free(data);
if (info.hbmMask)
DeleteObject(info.hbmMask);
if (info.hbmColor)
DeleteObject(info.hbmColor);
+
+ return TRUE;
}
-void wf_Pointer_Free(wfContext* wfc, rdpPointer* pointer)
+static BOOL wf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
{
HCURSOR hCur;
+ if (!context || !pointer)
+ return FALSE;
+
hCur = ((wfPointer*) pointer)->cursor;
if (hCur != 0)
DestroyIcon(hCur);
+
+ return TRUE;
}
-void wf_Pointer_Set(wfContext* wfc, rdpPointer* pointer)
+static BOOL wf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
HCURSOR hCur;
+ wfContext* wfc = (wfContext*)context;
+
+ if (!context || !pointer)
+ return FALSE;
hCur = ((wfPointer*) pointer)->cursor;
SetCursor(hCur);
wfc->cursor = hCur;
}
+
+ return TRUE;
}
-void wf_Pointer_SetNull(wfContext* wfc)
+static BOOL wf_Pointer_SetNull(rdpContext* context)
{
-
+ if (!context)
+ return FALSE;
+ return TRUE;
}
-void wf_Pointer_SetDefault(wfContext* wfc)
+static BOOL wf_Pointer_SetDefault(rdpContext* context)
{
-
+ if (!context)
+ return FALSE;
+ return TRUE;
}
-void wf_register_pointer(rdpGraphics* graphics)
+BOOL wf_register_pointer(rdpGraphics* graphics)
{
wfContext* wfc;
rdpPointer pointer;
+ if (!graphics)
+ return FALSE;
wfc = (wfContext*) graphics->context;
ZeroMemory(&pointer, sizeof(rdpPointer));
pointer.size = sizeof(wfPointer);
- pointer.New = (pPointer_New) wf_Pointer_New;
- pointer.Free = (pPointer_Free) wf_Pointer_Free;
- pointer.Set = (pPointer_Set) wf_Pointer_Set;
- pointer.SetNull = (pPointer_SetNull) wf_Pointer_SetNull;
- pointer.SetDefault = (pPointer_SetDefault) wf_Pointer_SetDefault;
+ pointer.New = wf_Pointer_New;
+ pointer.Free = wf_Pointer_Free;
+ pointer.Set = wf_Pointer_Set;
+ pointer.SetNull = wf_Pointer_SetNull;
+ pointer.SetDefault = wf_Pointer_SetDefault;
graphics_register_pointer(graphics, &pointer);
+ return TRUE;
}
/* Graphics Module */
-void wf_register_graphics(rdpGraphics* graphics)
+BOOL wf_register_graphics(rdpGraphics* graphics)
{
wfContext* wfc;
rdpBitmap bitmap;
+ if (!graphics)
+ return FALSE;
+
wfc = (wfContext*) graphics->context;
ZeroMemory(&bitmap, sizeof(rdpBitmap));
bitmap.size = sizeof(wfBitmap);
- bitmap.New = (pBitmap_New) wf_Bitmap_New;
- bitmap.Free = (pBitmap_Free) wf_Bitmap_Free;
- bitmap.Paint = (pBitmap_Paint) wf_Bitmap_Paint;
- bitmap.Decompress = (pBitmap_Decompress) wf_Bitmap_Decompress;
- bitmap.SetSurface = (pBitmap_SetSurface) wf_Bitmap_SetSurface;
+ bitmap.New = wf_Bitmap_New;
+ bitmap.Free = wf_Bitmap_Free;
+ bitmap.Paint = wf_Bitmap_Paint;
graphics_register_bitmap(graphics, &bitmap);
+ return TRUE;
}
#include "wf_client.h"
-HBITMAP wf_create_dib(wfContext* wfc, int width, int height, int bpp, BYTE* data, BYTE** pdata);
-wfBitmap* wf_image_new(wfContext* wfc, int width, int height, int bpp, BYTE* data);
+HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format, const BYTE* data, BYTE** pdata);
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format, const BYTE* data);
void wf_image_free(wfBitmap* image);
-void wf_register_pointer(rdpGraphics* graphics);
-void wf_register_graphics(rdpGraphics* graphics);
+BOOL wf_register_pointer(rdpGraphics* graphics);
+BOOL wf_register_graphics(rdpGraphics* graphics);
#endif /* WF_GRAPHICS */