libfreerdp-gdi: fix compilation

This commit is contained in:
Marc-André Moreau 2011-06-30 21:23:36 -04:00
parent e038b068b8
commit 32cfd0f325
30 changed files with 2817 additions and 86 deletions

View File

@ -25,4 +25,5 @@ add_subdirectory(include)
add_subdirectory(libfreerdp-asn1)
add_subdirectory(libfreerdp-utils)
add_subdirectory(libfreerdp-kbd)
add_subdirectory(libfreerdp-gdi)

View File

@ -1509,7 +1509,7 @@ void test_gdi_LineTo(void)
HGDI_BITMAP hBmp_LineTo_R2_MERGEPENNOT;
HGDI_BITMAP hBmp_LineTo_R2_MERGEPEN;
HGDI_BITMAP hBmp_LineTo_R2_WHITE;
RD_PALETTE* hPalette;
FRDP_PALETTE* hPalette;
HCLRCONV clrconv;
int bitsPerPixel = 8;
int bytesPerPixel = 1;
@ -1525,7 +1525,7 @@ void test_gdi_LineTo(void)
hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);
hPalette = (RD_PALETTE*) gdi_GetSystemPalette();
hPalette = (FRDP_PALETTE*) gdi_GetSystemPalette();
clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
clrconv->alpha = 1;
@ -1827,7 +1827,7 @@ void test_gdi_Ellipse(void)
HGDI_BITMAP hBmp_Ellipse_1;
HGDI_BITMAP hBmp_Ellipse_2;
HGDI_BITMAP hBmp_Ellipse_3;
RD_PALETTE* hPalette;
FRDP_PALETTE* hPalette;
HCLRCONV clrconv;
int bitsPerPixel = 8;
int bytesPerPixel = 1;
@ -1843,7 +1843,7 @@ void test_gdi_Ellipse(void)
hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16);
gdi_SelectObject(hdc, (HGDIOBJECT) hBmp);
hPalette = (RD_PALETTE*) gdi_GetSystemPalette();
hPalette = (FRDP_PALETTE*) gdi_GetSystemPalette();
clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
clrconv->alpha = 1;
@ -1982,7 +1982,7 @@ void test_gdi_BitBlt_32bpp(void)
HGDI_BITMAP hBmp_PATPAINT;
HGDI_BITMAP hBmp_PATINVERT;
HGDI_BITMAP hBmpDstOriginal;
RD_PALETTE* hPalette;
FRDP_PALETTE* hPalette;
HCLRCONV clrconv;
int bytesPerPixel = 4;
@ -1996,7 +1996,7 @@ void test_gdi_BitBlt_32bpp(void)
hdcDst->bytesPerPixel = bytesPerPixel;
hdcDst->bitsPerPixel = bitsPerPixel;
hPalette = (RD_PALETTE*) gdi_GetSystemPalette();
hPalette = (FRDP_PALETTE*) gdi_GetSystemPalette();
clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
clrconv->alpha = 1;
@ -2236,7 +2236,7 @@ void test_gdi_BitBlt_16bpp(void)
HGDI_BITMAP hBmp_PATPAINT;
HGDI_BITMAP hBmp_PATINVERT;
HGDI_BITMAP hBmpDstOriginal;
RD_PALETTE* hPalette;
FRDP_PALETTE* hPalette;
HCLRCONV clrconv;
int bytesPerPixel = 2;
@ -2250,7 +2250,7 @@ void test_gdi_BitBlt_16bpp(void)
hdcDst->bytesPerPixel = bytesPerPixel;
hdcDst->bitsPerPixel = bitsPerPixel;
hPalette = (RD_PALETTE*) gdi_GetSystemPalette();
hPalette = (FRDP_PALETTE*) gdi_GetSystemPalette();
clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
clrconv->alpha = 1;
@ -2490,7 +2490,7 @@ void test_gdi_BitBlt_8bpp(void)
HGDI_BITMAP hBmp_PATPAINT;
HGDI_BITMAP hBmp_PATINVERT;
HGDI_BITMAP hBmpDstOriginal;
RD_PALETTE* hPalette;
FRDP_PALETTE* hPalette;
HCLRCONV clrconv;
int bytesPerPixel = 1;
@ -2504,7 +2504,7 @@ void test_gdi_BitBlt_8bpp(void)
hdcDst->bytesPerPixel = bytesPerPixel;
hdcDst->bitsPerPixel = bitsPerPixel;
hPalette = (RD_PALETTE*) gdi_GetSystemPalette();
hPalette = (FRDP_PALETTE*) gdi_GetSystemPalette();
clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
clrconv->alpha = 1;

157
include/freerdp/freerdp.h Normal file
View File

@ -0,0 +1,157 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* FreeRDP Interface
*
* Copyright 2009-2011 Jay Sorg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FREERDP_H
#define __FREERDP_H
#include "rdpset.h"
#include "types/ui.h"
#include "rdpext.h"
#define FREERDP_INTERFACE_VERSION 4
#if defined _WIN32 || defined __CYGWIN__
#ifdef FREERDP_EXPORTS
#ifdef __GNUC__
#define FREERDP_API __attribute__((dllexport))
#else
#define FREERDP_API __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define FREERDP_API __attribute__((dllimport))
#else
#define FREERDP_API __declspec(dllimport)
#endif
#endif
#else
#if __GNUC__ >= 4
#define FREERDP_API __attribute__ ((visibility("default")))
#else
#define FREERDP_API
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API FRDP_BOOL
freerdp_global_init(void);
FREERDP_API void
freerdp_global_finish(void);
struct rdp_inst
{
int version;
int size;
rdpSet * settings;
void * rdp;
void * param1;
void * param2;
void * param3;
void * param4;
uint32 disc_reason;
/* calls from ui to library */
int (* rdp_connect)(rdpInst * inst);
int (* rdp_get_fds)(rdpInst * inst, void ** read_fds, int * read_count,
void ** write_fds, int * write_count);
int (* rdp_check_fds)(rdpInst * inst);
int (* rdp_send_input_scancode)(rdpInst * inst, FRDP_BOOL up, FRDP_BOOL extended, uint8 keyCode);
int (* rdp_send_input_unicode)(rdpInst * inst, uint16 character);
int (* rdp_send_input_mouse)(rdpInst * inst, uint16 pointerFlags, uint16 xPos, uint16 yPos);
int (* rdp_sync_input)(rdpInst * inst, int toggle_flags);
int (* rdp_channel_data)(rdpInst * inst, int chan_id, char * data, int data_size);
void (*rdp_suppress_output)(rdpInst * inst, int allow_display_updates);
void (* rdp_disconnect)(rdpInst * inst);
int (* rdp_send_frame_ack)(rdpInst * inst, int frame_id);
/* calls from library to ui */
void (* ui_error)(rdpInst * inst, const char * text);
void (* ui_warning)(rdpInst * inst, const char * text);
void (* ui_unimpl)(rdpInst * inst, const char * text);
void (* ui_begin_update)(rdpInst * inst);
void (* ui_end_update)(rdpInst * inst);
void (* ui_desktop_save)(rdpInst * inst, int offset, int x, int y,
int cx, int cy);
void (* ui_desktop_restore)(rdpInst * inst, int offset, int x, int y,
int cx, int cy);
FRDP_HBITMAP (* ui_create_bitmap)(rdpInst * inst, int width, int height, uint8 * data);
void (* ui_paint_bitmap)(rdpInst * inst, int x, int y, int cx, int cy, int width,
int height, uint8 * data);
void (* ui_destroy_bitmap)(rdpInst * inst, FRDP_HBITMAP bmp);
void (* ui_line)(rdpInst * inst, uint8 opcode, int startx, int starty, int endx,
int endy, FRDP_PEN * pen);
void (* ui_rect)(rdpInst * inst, int x, int y, int cx, int cy, uint32 color);
void (* ui_polygon)(rdpInst * inst, uint8 opcode, uint8 fillmode, FRDP_POINT * point,
int npoints, FRDP_BRUSH * brush, uint32 bgcolor, uint32 fgcolor);
void (* ui_polyline)(rdpInst * inst, uint8 opcode, FRDP_POINT * points, int npoints,
FRDP_PEN * pen);
void (* ui_ellipse)(rdpInst * inst, uint8 opcode, uint8 fillmode, int x, int y,
int cx, int cy, FRDP_BRUSH * brush, uint32 bgcolor, uint32 fgcolor);
void (* ui_start_draw_glyphs)(rdpInst * inst, uint32 bgcolor, uint32 fgcolor);
void (* ui_draw_glyph)(rdpInst * inst, int x, int y, int cx, int cy,
FRDP_HGLYPH glyph);
void (* ui_end_draw_glyphs)(rdpInst * inst, int x, int y, int cx, int cy);
uint32 (* ui_get_toggle_keys_state)(rdpInst * inst);
void (* ui_bell)(rdpInst * inst);
void (* ui_destblt)(rdpInst * inst, uint8 opcode, int x, int y, int cx, int cy);
void (* ui_patblt)(rdpInst * inst, uint8 opcode, int x, int y, int cx, int cy,
FRDP_BRUSH * brush, uint32 bgcolor, uint32 fgcolor);
void (* ui_screenblt)(rdpInst * inst, uint8 opcode, int x, int y, int cx, int cy,
int srcx, int srcy);
void (* ui_memblt)(rdpInst * inst, uint8 opcode, int x, int y, int cx, int cy,
FRDP_HBITMAP src, int srcx, int srcy);
void (* ui_triblt)(rdpInst * inst, uint8 opcode, int x, int y, int cx, int cy,
FRDP_HBITMAP src, int srcx, int srcy, FRDP_BRUSH * brush, uint32 bgcolor, uint32 fgcolor);
FRDP_HGLYPH (* ui_create_glyph)(rdpInst * inst, int width, int height, uint8 * data);
void (* ui_destroy_glyph)(rdpInst * inst, FRDP_HGLYPH glyph);
int (* ui_select)(rdpInst * inst, int rdp_socket);
void (* ui_set_clip)(rdpInst * inst, int x, int y, int cx, int cy);
void (* ui_reset_clip)(rdpInst * inst);
void (* ui_resize_window)(rdpInst * inst);
void (* ui_set_cursor)(rdpInst * inst, FRDP_HCURSOR cursor);
void (* ui_destroy_cursor)(rdpInst * inst, FRDP_HCURSOR cursor);
FRDP_HCURSOR (* ui_create_cursor)(rdpInst * inst, unsigned int x, unsigned int y,
int width, int height, uint8 * andmask, uint8 * xormask, int bpp);
void (* ui_set_null_cursor)(rdpInst * inst);
void (* ui_set_default_cursor)(rdpInst * inst);
FRDP_HPALETTE (* ui_create_palette)(rdpInst * inst, FRDP_PALETTE * palette);
void (* ui_set_palette)(rdpInst * inst, FRDP_HPALETTE palette);
void (* ui_move_pointer)(rdpInst * inst, int x, int y);
FRDP_HBITMAP (* ui_create_surface)(rdpInst * inst, int width, int height, FRDP_HBITMAP old);
void (* ui_set_surface)(rdpInst * inst, FRDP_HBITMAP surface);
void (* ui_destroy_surface)(rdpInst * inst, FRDP_HBITMAP surface);
void (* ui_channel_data)(rdpInst * inst, int chan_id, char * data, int data_size,
int flags, int total_size);
FRDP_BOOL (* ui_authenticate)(rdpInst * inst);
int (* ui_decode)(rdpInst * inst, uint8 * data, int data_size);
FRDP_BOOL (* ui_check_certificate)(rdpInst * inst, const char * fingerprint,
const char * subject, const char * issuer, FRDP_BOOL verified);
};
FREERDP_API rdpInst *
freerdp_new(rdpSet * settings);
FREERDP_API void
freerdp_free(rdpInst * inst);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -22,11 +22,11 @@
#include "types/base.h"
#define RDP_KEYBOARD_LAYOUT_TYPE_STANDARD 1
#define RDP_KEYBOARD_LAYOUT_TYPE_VARIANT 2
#define RDP_KEYBOARD_LAYOUT_TYPE_IME 4
#define RDP_KEYBOAFRDP_LAYOUT_TYPE_STANDARD 1
#define RDP_KEYBOAFRDP_LAYOUT_TYPE_VARIANT 2
#define RDP_KEYBOAFRDP_LAYOUT_TYPE_IME 4
typedef struct rdp_keyboard_layout
typedef struct rdp_keyboaFRDP_layout
{
uint32 code;
char name[50];
@ -35,10 +35,10 @@ typedef struct rdp_keyboard_layout
rdpKeyboardLayout *
freerdp_kbd_get_layouts(int types);
unsigned int
freerdp_kbd_init(void *dpy, unsigned int keyboard_layout_id);
freerdp_kbd_init(void *dpy, unsigned int keyboaFRDP_layout_id);
uint8
freerdp_kbd_get_scancode_by_keycode(uint8 keycode, fbool * extended);
freerdp_kbd_get_scancode_by_keycode(uint8 keycode, FRDP_BOOL * extended);
uint8
freerdp_kbd_get_scancode_by_virtualkey(int vkcode, fbool * extended);
freerdp_kbd_get_scancode_by_virtualkey(int vkcode, FRDP_BOOL * extended);
#endif /* __FREERDP_KBD_H */

64
include/freerdp/rdpext.h Normal file
View File

@ -0,0 +1,64 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* RDP Extensions
*
* Copyright 2010-2011 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RDPEXT_H
#define __RDPEXT_H
#include <freerdp/types/ui.h>
#ifdef _WIN32
#define RDPEXT_CC __stdcall
#else
#define RDPEXT_CC
#endif
/* Extensions ought to check for it to ensure compatibility */
#define RDPEXT_API 1
#define RDPEXT_EXPORT_FUNC_NAME "FreeRDPExtensionEntry"
typedef struct rdp_ext_plugin rdpExtPlugin;
struct rdp_ext_plugin
{
void * ext;
int (*init) (rdpExtPlugin * plugin, rdpInst * inst);
int (*uninit) (rdpExtPlugin * plugin, rdpInst * inst);
};
typedef uint32 (RDPEXT_CC * PFREERDP_EXTENSION_HOOK)(rdpExtPlugin * plugin, rdpInst * inst);
typedef uint32 (RDPEXT_CC * PREGISTEREXTENSION)(rdpExtPlugin * plugin);
typedef uint32 (RDPEXT_CC * PREGISTERPRECONNECTHOOK)(rdpExtPlugin * plugin, PFREERDP_EXTENSION_HOOK hook);
typedef uint32 (RDPEXT_CC * PREGISTERPOSTCONNECTHOOK)(rdpExtPlugin * plugin, PFREERDP_EXTENSION_HOOK hook);
struct _FREERDP_EXTENSION_ENTRY_POINTS
{
void * ext; /* Reference to internal instance */
PREGISTEREXTENSION pRegisterExtension;
PREGISTERPRECONNECTHOOK pRegisterPreConnectHook;
PREGISTERPOSTCONNECTHOOK pRegisterPostConnectHook;
void * data;
};
typedef struct _FREERDP_EXTENSION_ENTRY_POINTS FREERDP_EXTENSION_ENTRY_POINTS;
typedef FREERDP_EXTENSION_ENTRY_POINTS * PFREERDP_EXTENSION_ENTRY_POINTS;
typedef int (RDPEXT_CC * PFREERDP_EXTENSION_ENTRY)(PFREERDP_EXTENSION_ENTRY_POINTS pEntryPoints);
#endif

98
include/freerdp/rdpset.h Normal file
View File

@ -0,0 +1,98 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* RDP Settings
*
* Copyright 2009-2011 Jay Sorg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RDPSET_H
#define __RDPSET_H
struct rdp_chan
{
char name[8]; /* ui sets */
int flags; /* ui sets */
int chan_id; /* core sets */
void * handle; /* just for ui */
};
struct rdp_ext_set
{
char name[256]; /* plugin name or path */
void * data; /* plugin data */
};
struct rdp_monitor
{
int x;
int y;
int width;
int height;
int is_primary;
};
struct rdp_set
{
int width;
int height;
char hostname[16];
char server[64];
char domain[16];
char password[64];
char shell[256];
char directory[256];
char username[256];
int tcp_port_rdp;
int keyboard_layout;
int keyboard_type;
int keyboard_subtype;
int keyboard_functionkeys;
char xkb_layout[32];
char xkb_variant[32];
int tls_security;
int nla_security;
int rdp_security;
int encryption;
int rdp_version;
int remote_app;
char app_name[64];
int console_session;
int server_depth;
int bitmap_cache;
int bitmap_cache_persist_enable;
int bitmap_cache_precache;
int bitmap_compression;
int performanceflags;
int desktop_save;
int polygon_ellipse_orders;
int autologin;
int console_audio;
int off_screen_bitmaps;
int triblt;
int new_cursors;
int mouse_motion;
int bulk_compression;
int rfx_flags;
int ui_decode_flags;
int use_frame_ack;
int num_channels;
int software_gdi;
struct rdp_chan channels[16];
struct rdp_ext_set extensions[16];
int num_monitors;
struct rdp_monitor monitors[16];
};
#endif /* __RDPSET_H */

View File

@ -42,6 +42,6 @@ typedef signed long long sint64;
#define False (0)
#endif
typedef int fbool;
typedef int FRDP_BOOL;
#endif

140
include/freerdp/types/ui.h Normal file
View File

@ -0,0 +1,140 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* User Interface Types
*
* Copyright 2009-2011 Jay Sorg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TYPES_UI_H
#define __TYPES_UI_H
#include <freerdp/types/base.h>
typedef void *FRDP_HBITMAP;
typedef void *FRDP_HGLYPH;
typedef void *FRDP_HPALETTE;
typedef void *FRDP_HCURSOR;
typedef struct _FRDP_POINT
{
sint16 x, y;
}
FRDP_POINT;
typedef struct _FRDP_PALETTEENTRY
{
uint8 red;
uint8 green;
uint8 blue;
}
FRDP_PALETTEENTRY;
typedef struct _FRDP_PALETTE
{
uint16 count;
FRDP_PALETTEENTRY *entries;
}
FRDP_PALETTE;
typedef struct _FRDP_PEN
{
uint8 style;
uint8 width;
uint32 color;
}
FRDP_PEN;
/* this is whats in the brush cache */
typedef struct _FRDP_BRUSHDATA
{
uint32 color_code;
uint32 data_size;
uint8 *data;
}
FRDP_BRUSHDATA;
typedef struct _FRDP_BRUSH
{
uint8 xorigin;
uint8 yorigin;
uint8 style;
uint8 pattern[8];
FRDP_BRUSHDATA *bd;
}
FRDP_BRUSH;
typedef struct _FRDP_PLUGIN_DATA
{
uint16 size;
void * data[4];
}
FRDP_PLUGIN_DATA;
typedef struct _FRDP_RECT
{
sint16 x;
sint16 y;
sint16 width;
sint16 height;
}
FRDP_RECT;
typedef struct _FRDP_EVENT FRDP_EVENT;
typedef void (*FRDP_EVENT_CALLBACK) (FRDP_EVENT * event);
struct _FRDP_EVENT
{
uint16 event_type;
FRDP_EVENT_CALLBACK event_callback;
void * user_data;
};
struct _FRDP_VIDEO_FRAME_EVENT
{
FRDP_EVENT event;
uint8 * frame_data;
uint32 frame_size;
uint32 frame_pixfmt;
sint16 frame_width;
sint16 frame_height;
sint16 x;
sint16 y;
sint16 width;
sint16 height;
uint16 num_visible_rects;
FRDP_RECT * visible_rects;
};
typedef struct _FRDP_VIDEO_FRAME_EVENT FRDP_VIDEO_FRAME_EVENT;
struct _FRDP_REDRAW_EVENT
{
FRDP_EVENT event;
sint16 x;
sint16 y;
sint16 width;
sint16 height;
};
typedef struct _FRDP_REDRAW_EVENT FRDP_REDRAW_EVENT;
/* defined in include/freerdp/freerdp.h */
struct rdp_inst;
typedef struct rdp_inst rdpInst;
/* defined in include/freerdp/rdpset.h */
struct rdp_set;
typedef struct rdp_set rdpSet;
#endif

View File

@ -290,39 +290,39 @@ void credssp_encode_ts_credentials(rdpCredssp *credssp)
{
asn_enc_rval_t enc_rval;
TSCredentials_t *ts_credentials;
TSPasswordCreds_t *ts_password_creds;
DATABLOB ts_password_creds_buffer = { 0 };
TSPasswordCreds_t *ts_passwoFRDP_creds;
DATABLOB ts_passwoFRDP_creds_buffer = { 0 };
ts_credentials = calloc(1, sizeof(TSCredentials_t));
ts_credentials->credType = 1; /* TSPasswordCreds */
ts_password_creds = calloc(1, sizeof(TSPasswordCreds_t));
ts_passwoFRDP_creds = calloc(1, sizeof(TSPasswordCreds_t));
/* Domain */
ts_password_creds->domainName.buf = credssp->ntlmssp->domain.data;
ts_password_creds->domainName.size = credssp->ntlmssp->domain.length;
ts_passwoFRDP_creds->domainName.buf = credssp->ntlmssp->domain.data;
ts_passwoFRDP_creds->domainName.size = credssp->ntlmssp->domain.length;
/* Username */
ts_password_creds->userName.buf = credssp->ntlmssp->username.data;
ts_password_creds->userName.size = credssp->ntlmssp->username.length;
ts_passwoFRDP_creds->userName.buf = credssp->ntlmssp->username.data;
ts_passwoFRDP_creds->userName.size = credssp->ntlmssp->username.length;
/* Password */
ts_password_creds->password.buf = credssp->ntlmssp->password.data;
ts_password_creds->password.size = credssp->ntlmssp->password.length;
ts_passwoFRDP_creds->password.buf = credssp->ntlmssp->password.data;
ts_passwoFRDP_creds->password.size = credssp->ntlmssp->password.length;
/* get size ASN.1 encoded TSPasswordCreds */
enc_rval = der_encode(&asn_DEF_TSPasswordCreds, ts_password_creds, asn1_write, 0);
enc_rval = der_encode(&asn_DEF_TSPasswordCreds, ts_passwoFRDP_creds, asn1_write, 0);
if (enc_rval.encoded != -1)
{
datablob_alloc(&ts_password_creds_buffer, enc_rval.encoded);
datablob_alloc(&ts_passwoFRDP_creds_buffer, enc_rval.encoded);
enc_rval = der_encode_to_buffer(&asn_DEF_TSPasswordCreds, ts_password_creds,
ts_password_creds_buffer.data, ts_password_creds_buffer.length);
enc_rval = der_encode_to_buffer(&asn_DEF_TSPasswordCreds, ts_passwoFRDP_creds,
ts_passwoFRDP_creds_buffer.data, ts_passwoFRDP_creds_buffer.length);
}
ts_credentials->credentials.buf = ts_password_creds_buffer.data;
ts_credentials->credentials.size = ts_password_creds_buffer.length;
ts_credentials->credentials.buf = ts_passwoFRDP_creds_buffer.data;
ts_credentials->credentials.size = ts_passwoFRDP_creds_buffer.length;
/* get size ASN.1 encoded TSCredentials */
enc_rval = der_encode(&asn_DEF_TSCredentials, ts_credentials, asn1_write, 0);
@ -335,9 +335,9 @@ void credssp_encode_ts_credentials(rdpCredssp *credssp)
credssp->ts_credentials.data, credssp->ts_credentials.length);
}
datablob_free(&ts_password_creds_buffer);
datablob_free(&ts_passwoFRDP_creds_buffer);
free(ts_credentials);
free(ts_password_creds);
free(ts_passwoFRDP_creds);
}
/**

View File

@ -0,0 +1,45 @@
# libfreerdp-gdi
include_directories(.)
include_directories(../include)
set(FREERDP_GDI_SRCS
color.c
color.h
decode.c
decode.h
gdi_8bpp.c
gdi_8bpp.h
gdi_16bpp.c
gdi_16bpp.h
gdi_32bpp.c
gdi_32bpp.h
gdi_bitmap.c
gdi_bitmap.h
gdi_brush.c
gdi_brush.h
gdi_clipping.c
gdi_clipping.h
gdi_dc.c
gdi_dc.h
gdi_drawing.c
gdi_drawing.h
gdi_line.c
gdi_line.h
gdi_palette.c
gdi_palette.h
gdi_pen.c
gdi_pen.h
gdi_region.c
gdi_region.h
gdi_shape.c
gdi_shape.h
gdi.c
gdi.h)
add_library(freerdp-gdi SHARED ${FREERDP_GDI_SRCS})
set_target_properties(freerdp-gdi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION})
install(TARGETS freerdp-gdi DESTINATION lib)

723
libfreerdp-gdi/color.c Normal file
View File

@ -0,0 +1,723 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* GDI Color Conversion Routines
*
* Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include "color.h"
uint32 gdi_color_convert_rgb(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
uint8 red = 0;
uint8 green = 0;
uint8 blue = 0;
uint8 alpha = 0xFF;
int dstColor = 0;
switch (srcBpp)
{
case 32:
if (clrconv->alpha)
{
GetABGR32(alpha, red, green, blue, srcColor);
}
else
{
GetBGR32(red, green, blue, srcColor);
}
break;
case 24:
GetBGR24(red, green, blue, srcColor);
break;
case 16:
GetRGB16(red, green, blue, srcColor);
break;
case 15:
GetRGB15(red, green, blue, srcColor);
break;
case 8:
srcColor &= 0xFF;
red = clrconv->palette->entries[srcColor].red;
green = clrconv->palette->entries[srcColor].green;
blue = clrconv->palette->entries[srcColor].blue;
break;
case 1:
if (srcColor != 0)
{
red = 0xFF;
green = 0xFF;
blue = 0xFF;
}
break;
default:
break;
}
switch (dstBpp)
{
case 32:
dstColor = ARGB32(alpha, red, green, blue);
break;
case 24:
dstColor = BGR24(red, green, blue);
break;
case 16:
if(clrconv->rgb555)
{
dstColor = RGB15(red, green, blue);
}
else
{
dstColor = RGB16(red, green, blue);
}
break;
case 15:
dstColor = RGB15(red, green, blue);
break;
case 8:
srcColor &= 0xFF;
red = clrconv->palette->entries[srcColor].red;
green = clrconv->palette->entries[srcColor].green;
blue = clrconv->palette->entries[srcColor].blue;
break;
case 1:
if ((red != 0) || (green != 0) || (blue != 0))
dstColor = 1;
break;
default:
break;
}
return dstColor;
}
uint32 gdi_color_convert_bgr(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
uint8 red = 0;
uint8 green = 0;
uint8 blue = 0;
uint8 alpha = 0xFF;
int dstColor = 0;
switch (srcBpp)
{
case 32:
if (clrconv->alpha)
{
GetABGR32(alpha, red, green, blue, srcColor);
}
else
{
GetBGR32(red, green, blue, srcColor);
}
break;
case 24:
GetBGR24(red, green, blue, srcColor);
break;
case 16:
GetRGB16(red, green, blue, srcColor);
break;
case 15:
GetRGB15(red, green, blue, srcColor);
break;
case 8:
srcColor &= 0xFF;
red = clrconv->palette->entries[srcColor].red;
green = clrconv->palette->entries[srcColor].green;
blue = clrconv->palette->entries[srcColor].blue;
break;
case 1:
if (srcColor != 0)
{
red = 0xFF;
green = 0xFF;
blue = 0xFF;
}
break;
default:
break;
}
switch (dstBpp)
{
case 32:
dstColor = ABGR32(alpha, red, green, blue);
break;
case 24:
dstColor = BGR24(red, green, blue);
break;
case 16:
if(clrconv->rgb555)
{
dstColor = BGR15(red, green, blue);
}
else
{
dstColor = BGR16(red, green, blue);
}
break;
case 15:
dstColor = BGR15(red, green, blue);
break;
case 8:
srcColor &= 0xFF;
red = clrconv->palette->entries[srcColor].red;
green = clrconv->palette->entries[srcColor].green;
blue = clrconv->palette->entries[srcColor].blue;
break;
case 1:
if ((red != 0) || (green != 0) || (blue != 0))
dstColor = 1;
break;
default:
break;
}
return dstColor;
}
uint32 gdi_color_convert(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
if (clrconv->invert)
return gdi_color_convert_bgr(srcColor, srcBpp, dstBpp, clrconv);
else
return gdi_color_convert_rgb(srcColor, srcBpp, dstBpp, clrconv);
}
uint8* gdi_image_convert_8bpp(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
int i;
uint8 red;
uint8 green;
uint8 blue;
uint32 pixel;
uint8 *src8;
uint16 *dst16;
uint32 *dst32;
if (dstBpp == 8)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height);
memcpy(dstData, srcData, width * height);
return dstData;
}
else if (dstBpp == 15 || (dstBpp == 16 && clrconv->rgb555))
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
dst16 = (uint16 *) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *srcData;
srcData++;
red = clrconv->palette->entries[pixel].red;
green = clrconv->palette->entries[pixel].green;
blue = clrconv->palette->entries[pixel].blue;
pixel = RGB15(red, green, blue);
*dst16 = pixel;
dst16++;
}
return dstData;
}
else if (dstBpp == 16)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
dst16 = (uint16 *) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *srcData;
srcData++;
red = clrconv->palette->entries[pixel].red;
green = clrconv->palette->entries[pixel].green;
blue = clrconv->palette->entries[pixel].blue;
pixel = RGB16(red, green, blue);
*dst16 = pixel;
dst16++;
}
return dstData;
}
else if (dstBpp == 32)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
src8 = (uint8*) srcData;
dst32 = (uint32*) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *src8;
src8++;
red = clrconv->palette->entries[pixel].red;
green = clrconv->palette->entries[pixel].green;
blue = clrconv->palette->entries[pixel].blue;
pixel = BGR32(red, green, blue);
*dst32 = pixel;
dst32++;
}
return dstData;
}
return srcData;
}
uint8* gdi_image_convert_15bpp(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
int i;
uint8 red;
uint8 green;
uint8 blue;
uint32 pixel;
uint16 *src16;
uint16 *dst16;
uint32 *dst32;
if (dstBpp == 15 || (dstBpp == 16 && clrconv->rgb555))
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
memcpy(dstData, srcData, width * height * 2);
return dstData;
}
else if (dstBpp == 32)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
src16 = (uint16 *) srcData;
dst32 = (uint32 *) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *src16;
src16++;
GetBGR16(red, green, blue, pixel);
pixel = BGR32(red, green, blue);
*dst32 = pixel;
dst32++;
}
return dstData;
}
else if (dstBpp == 16)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
src16 = (uint16 *) srcData;
dst16 = (uint16 *) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *src16;
src16++;
GetRGB_555(red, green, blue, pixel);
RGB_555_565(red, green, blue);
pixel = RGB565(red, green, blue);
*dst16 = pixel;
dst16++;
}
return dstData;
}
return srcData;
}
uint8* gdi_image_convert_16bpp(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
if (srcBpp == 15)
return gdi_image_convert_15bpp(srcData, dstData, width, height, srcBpp, dstBpp, clrconv);
if (dstBpp == 16)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
if(clrconv->rgb555)
{
int i;
uint8 red, green, blue;
uint16* src16 = (uint16 *) srcData;
uint16* dst16 = (uint16 *) dstData;
for (i = width * height; i > 0; i--)
{
GetRGB_565(red, green, blue, (*src16));
RGB_565_555(red, green, blue);
(*dst16) = RGB555(red, green, blue);
src16++;
dst16++;
}
}
else
{
memcpy(dstData, srcData, width * height * 2);
}
return dstData;
}
else if (dstBpp == 24)
{
int i;
uint8 *dst8;
uint16 *src16;
uint8 red, green, blue;
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 3);
dst8 = (uint8 *) dstData;
src16 = (uint16 *) srcData;
for (i = width * height; i > 0; i--)
{
GetBGR16(red, green, blue, *src16);
src16++;
if (clrconv->invert)
{
*dst8++ = blue;
*dst8++ = green;
*dst8++ = red;
}
else
{
*dst8++ = red;
*dst8++ = green;
*dst8++ = blue;
}
}
return dstData;
}
else if (dstBpp == 32)
{
int i;
uint32 pixel;
uint16 *src16;
uint32 *dst32;
uint8 red, green, blue;
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
src16 = (uint16 *) srcData;
dst32 = (uint32 *) dstData;
for (i = width * height; i > 0; i--)
{
pixel = *src16;
src16++;
GetBGR16(red, green, blue, pixel);
pixel = BGR32(red, green, blue);
*dst32 = pixel;
dst32++;
}
return dstData;
}
return srcData;
}
uint8* gdi_image_convert_24bpp(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
int i;
uint8 red;
uint8 green;
uint8 blue;
uint32 pixel;
uint32 *dst32;
if (dstBpp == 32)
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
dst32 = (uint32 *) dstData;
for (i = width * height; i > 0; i--)
{
red = *(srcData++);
green = *(srcData++);
blue = *(srcData++);
pixel = BGR24(red, green, blue);
*dst32 = pixel;
dst32++;
}
return dstData;
}
return srcData;
}
uint8* gdi_image_convert_32bpp(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
if (dstBpp == 16)
{
int index;
uint16 *dst16;
uint32 *src32;
uint8 red, green, blue;
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 2);
dst16 = (uint16*) dstData;
src32 = (uint32*) srcData;
for (index = 0; index < width * height; index++)
{
GetBGR32(blue, green, red, *src32);
*dst16 = RGB16(red, green, blue);
src32++;
dst16++;
}
return dstData;
}
else if (dstBpp == 24)
{
int index;
uint8 red, green, blue;
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 3);
for (index = 0; index < width * height; index++)
{
red = *(srcData++);
green = *(srcData++);
blue = *(srcData++);
if (clrconv->invert)
{
*dstData++ = blue;
*dstData++ = green;
*dstData++ = red;
}
else
{
*dstData++ = red;
*dstData++ = green;
*dstData++ = blue;
}
srcData++;
}
return dstData;
}
else if (dstBpp == 32)
{
if (clrconv->alpha)
{
int x, y;
uint8 *dstp;
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
memcpy(dstData, srcData, width * height * 4);
dstp = dstData;
for (y = 0; y < height; y++)
{
for (x = 0; x < width * 4; x += 4)
{
dstp += 3;
*dstp = 0xFF;
dstp++;
}
}
}
else
{
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * 4);
memcpy(dstData, srcData, width * height * 4);
}
return dstData;
}
return srcData;
}
p_gdi_image_convert gdi_image_convert_[5] =
{
NULL,
gdi_image_convert_8bpp,
gdi_image_convert_16bpp,
gdi_image_convert_24bpp,
gdi_image_convert_32bpp
};
uint8* gdi_image_convert(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv)
{
p_gdi_image_convert _p_gdi_image_convert = gdi_image_convert_[IBPP(srcBpp)];
if (_p_gdi_image_convert != NULL)
return _p_gdi_image_convert(srcData, dstData, width, height, srcBpp, dstBpp, clrconv);
else
return 0;
}
uint8*
gdi_glyph_convert(int width, int height, uint8* data)
{
int x, y;
uint8 *srcp;
uint8 *dstp;
uint8 *dstData;
int scanline;
/*
* converts a 1-bit-per-pixel glyph to a one-byte-per-pixel glyph:
* this approach uses a little more memory, but provides faster
* means of accessing individual pixels in blitting operations
*/
scanline = (width + 7) / 8;
dstData = (uint8*) malloc(width * height);
memset(dstData, 0, width * height);
dstp = dstData;
for (y = 0; y < height; y++)
{
srcp = data + (y * scanline);
for (x = 0; x < width; x++)
{
if ((*srcp & (0x80 >> (x % 8))) != 0)
*dstp = 0xFF;
dstp++;
if (((x + 1) % 8 == 0) && x != 0)
srcp++;
}
}
return dstData;
}
uint8* gdi_mono_image_convert(uint8* srcData, int width, int height, int srcBpp, int dstBpp, uint32 bgcolor, uint32 fgcolor, HCLRCONV clrconv)
{
int index;
uint16* dst16;
uint32* dst32;
uint8* dstData;
uint8 bitMask;
int bitIndex;
uint8 redBg, greenBg, blueBg;
uint8 redFg, greenFg, blueFg;
switch (srcBpp)
{
case 8:
bgcolor &= 0xFF;
redBg = clrconv->palette->entries[bgcolor].red;
greenBg = clrconv->palette->entries[bgcolor].green;
blueBg = clrconv->palette->entries[bgcolor].blue;
fgcolor &= 0xFF;
redFg = clrconv->palette->entries[fgcolor].red;
greenFg = clrconv->palette->entries[fgcolor].green;
blueFg = clrconv->palette->entries[fgcolor].blue;
break;
case 16:
GetRGB16(redBg, greenBg, blueBg, bgcolor);
GetRGB16(redFg, greenFg, blueFg, fgcolor);
break;
case 15:
GetRGB15(redBg, greenBg, blueBg, bgcolor);
GetRGB15(redFg, greenFg, blueFg, fgcolor);
break;
default:
GetRGB32(redBg, greenBg, blueBg, bgcolor);
GetRGB32(redFg, greenFg, blueFg, fgcolor);
}
if(dstBpp == 16)
{
if(clrconv->rgb555)
{
if(srcBpp == 16)
{
/* convert 15-bit colors to 16-bit colors */
RGB16_RGB15(redBg, greenBg, blueBg, bgcolor);
RGB16_RGB15(redFg, greenFg, blueFg, fgcolor);
}
}
else
{
if(srcBpp == 15)
{
/* convert 15-bit colors to 16-bit colors */
RGB15_RGB16(redBg, greenBg, blueBg, bgcolor);
RGB15_RGB16(redFg, greenFg, blueFg, fgcolor);
}
}
dstData = (uint8*) malloc(width * height * 2);
dst16 = (uint16*) dstData;
for(index = height; index > 0; index--)
{
/* each bit encodes a pixel */
bitMask = *srcData;
for(bitIndex = 7; bitIndex >= 0; bitIndex--)
{
if((bitMask >> bitIndex) & 0x01)
{
*dst16 = bgcolor;
}
else
{
*dst16 = fgcolor;
}
dst16++;
}
srcData++;
}
return dstData;
}
else if(dstBpp == 32)
{
dstData = (uint8*) malloc(width * height * 4);
dst32 = (uint32*) dstData;
for(index = height; index > 0; index--)
{
/* each bit encodes a pixel */
bitMask = *srcData;
for(bitIndex = 7; bitIndex >= 0; bitIndex--)
{
if((bitMask >> bitIndex) & 0x01)
{
*dst32 = RGB32(redBg, greenBg, blueBg);
}
else
{
*dst32 = RGB32(redFg, greenFg, blueFg);
}
dst32++;
}
srcData++;
}
return dstData;
}
return srcData;
}

247
libfreerdp-gdi/color.h Normal file
View File

@ -0,0 +1,247 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* GDI Color Conversion Routines
*
* Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __COLOR_H
#define __COLOR_H
#include <freerdp/freerdp.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Color Space Conversions: http://msdn.microsoft.com/en-us/library/ff566496/ */
/* Color Space Conversion */
#define RGB_555_565(_r, _g, _b) \
_r = _r; \
_g = (_g << 1 & ~0x1) | (_g >> 4); \
_b = _b;
#define RGB_565_555(_r, _g, _b) \
_r = _r; \
_g = (_g >> 1); \
_b = _b;
#define RGB_555_888(_r, _g, _b) \
_r = (_r << 3 & ~0x7) | (_r >> 2); \
_g = (_g << 3 & ~0x7) | (_g >> 2); \
_b = (_b << 3 & ~0x7) | (_b >> 2);
#define RGB_565_888(_r, _g, _b) \
_r = (_r << 3 & ~0x7) | (_r >> 2); \
_g = (_g << 2 & ~0x3) | (_g >> 4); \
_b = (_b << 3 & ~0x7) | (_b >> 2);
#define RGB_888_565(_r, _g, _b) \
_r = (_r >> 3); \
_g = (_g >> 2); \
_b = (_b >> 3);
#define RGB_888_555(_r, _g, _b) \
_r = (_r >> 3); \
_g = (_g >> 3); \
_b = (_b >> 3);
/* RGB 15 (RGB_555) */
#define RGB555(_r, _g, _b) \
((_r & 0x1F) << 10) | ((_g & 0x1F) << 5) | (_b & 0x1F);
#define RGB15(_r, _g, _b) \
(((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_b >> 3) & 0x1F);
#define GetRGB_555(_r, _g, _b, _p) \
_r = (_p & 0x7C00) >> 10; \
_g = (_p & 0x3E0) >> 5; \
_b = (_p & 0x1F);
#define GetRGB15(_r, _g, _b, _p) \
GetRGB_555(_r, _g, _b, _p); \
RGB_555_888(_r, _g, _b);
/* BGR 15 (BGR_555) */
#define BGR555(_r, _g, _b) \
((_b & 0x1F) << 10) | ((_g & 0x1F) << 5) | (_r & 0x1F);
#define BGR15(_r, _g, _b) \
(((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((_r >> 3) & 0x1F);
#define GetBGR_555(_r, _g, _b, _p) \
_b = (_p & 0x7C00) >> 10; \
_g = (_p & 0x3E0) >> 5; \
_r = (_p & 0x1F);
#define GetBGR15(_r, _g, _b, _p) \
GetBGR_555(_r, _g, _b, _p); \
RGB_555_888(_r, _g, _b);
/* RGB 16 (RGB_565) */
#define RGB565(_r, _g, _b) \
((_r & 0x1F) << 11) | ((_g & 0x3F) << 5) | (_b & 0x1F);
#define RGB16(_r, _g, _b) \
(((_r >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_b >> 3) & 0x1F);
#define GetRGB_565(_r, _g, _b, _p) \
_r = (_p & 0xF800) >> 11; \
_g = (_p & 0x7E0) >> 5; \
_b = (_p & 0x1F);
#define GetRGB16(_r, _g, _b, _p) \
GetRGB_565(_r, _g, _b, _p); \
RGB_565_888(_r, _g, _b);
/* BGR 16 (BGR_565) */
#define BGR565(_r, _g, _b) \
((_b & 0x1F) << 11) | ((_g & 0x3F) << 5) | (_r & 0x1F);
#define BGR16(_r, _g, _b) \
(((_b >> 3) & 0x1F) << 11) | (((_g >> 2) & 0x3F) << 5) | ((_r >> 3) & 0x1F);
#define GetBGR_565(_r, _g, _b, _p) \
_b = (_p & 0xF800) >> 11; \
_g = (_p & 0x7E0) >> 5; \
_r = (_p & 0x1F);
#define GetBGR16(_r, _g, _b, _p) \
GetBGR_565(_r, _g, _b, _p); \
RGB_565_888(_r, _g, _b);
/* RGB 24 (RGB_888) */
#define RGB24(_r, _g, _b) \
(_r << 16) | (_g << 8) | _b;
#define GetRGB24(_r, _g, _b, _p) \
_r = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_b = (_p & 0xFF);
/* BGR 24 (BGR_888) */
#define BGR24(_r, _g, _b) \
(_b << 16) | (_g << 8) | _r;
#define GetBGR24(_r, _g, _b, _p) \
_b = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_r = (_p & 0xFF);
/* RGB 32 (ARGB_8888), alpha ignored */
#define RGB32(_r, _g, _b) \
(_r << 16) | (_g << 8) | _b;
#define GetRGB32(_r, _g, _b, _p) \
_r = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_b = (_p & 0xFF);
/* ARGB 32 (ARGB_8888) */
#define ARGB32(_a,_r, _g, _b) \
(_a << 24) | (_r << 16) | (_g << 8) | _b;
#define GetARGB32(_a, _r, _g, _b, _p) \
_a = (_p & 0xFF000000) >> 24; \
_r = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_b = (_p & 0xFF);
/* BGR 32 (ABGR_8888), alpha ignored */
#define BGR32(_r, _g, _b) \
(_b << 16) | (_g << 8) | _r;
#define GetBGR32(_r, _g, _b, _p) \
_b = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_r = (_p & 0xFF);
/* BGR 32 (ABGR_8888) */
#define ABGR32(_a, _r, _g, _b) \
(_a << 24) | (_b << 16) | (_g << 8) | _r;
#define GetABGR32(_a, _r, _g, _b, _p) \
_a = (_p & 0xFF000000) >> 24; \
_b = (_p & 0xFF0000) >> 16; \
_g = (_p & 0xFF00) >> 8; \
_r = (_p & 0xFF);
/* Color Conversion */
#define BGR16_RGB32(_r, _g, _b, _p) \
GetBGR16(_r, _g, _b, _p); \
RGB_565_888(_r, _g, _b); \
_p = RGB32(_r, _g, _b);
#define RGB32_RGB16(_r, _g, _b, _p) \
GetRGB32(_r, _g, _b, _p); \
RGB_888_565(_r, _g, _b); \
_p = RGB565(_r, _g, _b);
#define RGB15_RGB16(_r, _g, _b, _p) \
GetRGB_555(_r, _g, _b, _p); \
_g = (_g << 1 & ~0x1) | (_g >> 4); \
_p = RGB565(_r, _g, _b);
#define RGB16_RGB15(_r, _g, _b, _p) \
GetRGB_565(_r, _g, _b, _p); \
_g = (_g >> 1); \
_p = RGB555(_r, _g, _b);
#define CLRCONV_ALPHA 1
#define CLRCONV_INVERT 2
/* if defined RGB555 format is used when rendering with a 16-bit frame buffer */
#define CLRCONV_RGB555 4
/* Supported Internal Buffer Formats */
#define CLRBUF_16BPP 8
#define CLRBUF_32BPP 16
struct _CLRCONV
{
int alpha;
int invert;
int rgb555;
FRDP_PALETTE* palette;
};
typedef struct _CLRCONV CLRCONV;
typedef CLRCONV* HCLRCONV;
#define IBPP(_bpp) (((_bpp + 1)/ 8) % 5)
typedef uint8* (*p_gdi_image_convert)(uint8* srcData, uint8* dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv);
uint32 gdi_color_convert(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv);
uint8* gdi_image_convert(uint8* srcData, uint8 *dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv);
uint8* gdi_glyph_convert(int width, int height, uint8* data);
uint8* gdi_mono_image_convert(uint8* srcData, int width, int height, int srcBpp, int dstBpp, uint32 bgcolor, uint32 fgcolor, HCLRCONV clrconv);
#ifdef __cplusplus
}
#endif
#endif /* __COLOR_H */

40
libfreerdp-gdi/decode.c Normal file
View File

@ -0,0 +1,40 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* GDI RemoteFX Decoder
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>
#include "gdi.h"
#include "gdi_bitmap.h"
#include "gdi_region.h"
#include "gdi_clipping.h"
#include "decode.h"
void gdi_decode_frame(GDI *gdi, int x, int y, uint8 * data, uint32 length)
{
}
void gdi_decode_data(GDI *gdi, uint8 * data, int data_size)
{
}

30
libfreerdp-gdi/decode.h Normal file
View File

@ -0,0 +1,30 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* GDI RemoteFX Decoder
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DECODE_H
#define __DECODE_H
#include <freerdp/freerdp.h>
#include "gdi.h"
void gdi_decode_frame(GDI *gdi, int x, int y, uint8 * data, uint32 length);
void gdi_decode_data(GDI *gdi, uint8 * data, int data_size);
#endif /* __DECODE_H */

1195
libfreerdp-gdi/gdi.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,15 +17,10 @@
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef __GDI_H
#define __GDI_H
#include "color.h"
#include <freerdp/rfx.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/debug.h>
@ -252,7 +247,7 @@ typedef struct _GDI GDI;
uint32 gdi_rop3_code(uint8 code);
void gdi_copy_mem(uint8 *d, uint8 *s, int n);
void gdi_copy_memb(uint8 *d, uint8 *s, int n);
void gdi_copy_mem_backwards(uint8 *d, uint8 *s, int n);
uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y);
uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y);
int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width);

View File

@ -192,7 +192,7 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
if (srcp != 0 && dstp != 0)
{
gdi_copy_memb(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
gdi_copy_mem_backwards(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
}
}
}

View File

@ -209,7 +209,7 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
if (srcp != 0 && dstp != 0)
{
gdi_copy_memb(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
gdi_copy_mem_backwards(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
}
}
}

View File

@ -131,7 +131,7 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
if (srcp != 0 && dstp != 0)
{
gdi_copy_memb(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
gdi_copy_mem_backwards(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
}
}
}

View File

@ -19,8 +19,8 @@
/* Microsoft Windows Virtual Key Codes: http://msdn.microsoft.com/en-us/library/ms645540.aspx */
#ifndef __KEYBOARD_H
#define __KEYBOARD_H
#ifndef __KEYBOAFRDP_H
#define __KEYBOAFRDP_H
#include <stddef.h>
@ -584,4 +584,4 @@ static const virtualKey virtualKeyboard[256 + 2] =
{ 0x1C, 1, "" , "KPEN" },
};
#endif /* __KEYBOARD_H */
#endif /* __KEYBOAFRDP_H */

View File

@ -230,7 +230,7 @@ keyboardIME keyboardIMEs[] =
rdpKeyboardLayout *
get_keyboard_layouts(int types)
get_keyboaFRDP_layouts(int types)
{
rdpKeyboardLayout * layouts;
int num;
@ -240,7 +240,7 @@ get_keyboard_layouts(int types)
num = 0;
layouts = (rdpKeyboardLayout *) malloc((num + 1) * sizeof(rdpKeyboardLayout));
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_STANDARD) != 0)
if ((types & RDP_KEYBOAFRDP_LAYOUT_TYPE_STANDARD) != 0)
{
len = sizeof(keyboardLayouts) / sizeof(keyboardLayout);
layouts = (rdpKeyboardLayout *) realloc(layouts, (num + len + 1) * sizeof(rdpKeyboardLayout));
@ -250,7 +250,7 @@ get_keyboard_layouts(int types)
strcpy(layouts[num].name, keyboardLayouts[i].name);
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0)
if ((types & RDP_KEYBOAFRDP_LAYOUT_TYPE_VARIANT) != 0)
{
len = sizeof(keyboardLayoutVariants) / sizeof(keyboardLayoutVariant);
layouts = (rdpKeyboardLayout *) realloc(layouts, (num + len + 1) * sizeof(rdpKeyboardLayout));
@ -260,7 +260,7 @@ get_keyboard_layouts(int types)
strcpy(layouts[num].name, keyboardLayoutVariants[i].name);
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0)
if ((types & RDP_KEYBOAFRDP_LAYOUT_TYPE_IME) != 0)
{
len = sizeof(keyboardIMEs) / sizeof(keyboardIME);
layouts = (rdpKeyboardLayout *) realloc(layouts, (num + len + 1) * sizeof(rdpKeyboardLayout));

View File

@ -178,7 +178,7 @@
#define KBD_CHINESE_TRADITIONAL_ALPHANUMERIC 0xE00F0404
rdpKeyboardLayout *
get_keyboard_layouts(int types);
get_keyboaFRDP_layouts(int types);
char *
get_layout_name(unsigned int keyboardLayoutID);

View File

@ -21,7 +21,6 @@
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "libkbd.h"
#include "keyboard.h"
#include "x_layout_id_table.h"
@ -58,10 +57,10 @@ comma_substring(char *s, int n)
}
unsigned int
detect_keyboard_layout_from_xkb(void *dpy)
detect_keyboaFRDP_layout_from_xkb(void *dpy)
{
char *layout, *variant;
unsigned int keyboard_layout = 0, group = 0;
unsigned int keyboaFRDP_layout = 0, group = 0;
XkbRF_VarDefsRec rules_names;
XKeyboardState coreKbdState;
XkbStateRec state;
@ -83,7 +82,7 @@ detect_keyboard_layout_from_xkb(void *dpy)
DEBUG_KBD("layout: %s", layout);
DEBUG_KBD("variant: %s", variant);
keyboard_layout = find_keyboard_layout_in_xorg_rules(layout, variant);
keyboaFRDP_layout = find_keyboaFRDP_layout_in_xorg_rules(layout, variant);
free(rules_names.model);
free(rules_names.layout);
@ -91,7 +90,7 @@ detect_keyboard_layout_from_xkb(void *dpy)
free(rules_names.options);
}
return keyboard_layout;
return keyboaFRDP_layout;
}
int
@ -359,7 +358,7 @@ load_xkb_keyboard(KeycodeToVkcode map, char* kbd)
}
void
load_keyboard_map(KeycodeToVkcode keycodeToVkcode, char *xkbfile)
load_keyboaFRDP_map(KeycodeToVkcode keycodeToVkcode, char *xkbfile)
{
char* kbd;
char* xkbfileEnd;

View File

@ -20,8 +20,6 @@
#ifndef __LAYOUTS_XKB_H
#define __LAYOUTS_XKB_H
#include "config.h"
typedef unsigned char KeycodeToVkcode[256];
typedef struct
@ -39,7 +37,7 @@ int
init_xkb(void *dpy);
unsigned int
detect_keyboard_layout_from_xkb(void *dpy);
detect_keyboaFRDP_layout_from_xkb(void *dpy);
int
init_keycodes_from_xkb(void *dpy, RdpKeycodes x_keycode_to_rdp_keycode);
@ -47,7 +45,7 @@ init_keycodes_from_xkb(void *dpy, RdpKeycodes x_keycode_to_rdp_keycode);
#else
void
load_keyboard_map(KeycodeToVkcode keycodeToVkcode, char *xkbfile);
load_keyboaFRDP_map(KeycodeToVkcode keycodeToVkcode, char *xkbfile);
#endif

View File

@ -21,9 +21,9 @@
#include <stdlib.h>
#include <string.h>
#include <freerdp/freerdp.h>
#include <freerdp/kbd.h>
#include "config.h"
#include <freerdp/types/base.h>
#include "locales.h"
#include "layout_ids.h"
#include "layouts_xkb.h"
@ -52,15 +52,15 @@ detect_keyboard(void *dpy, unsigned int keyboardLayoutID, char *xkbfile, size_t
#if defined(sun)
if(keyboardLayoutID == 0)
{
keyboardLayoutID = detect_keyboard_type_and_layout_sunos(xkbfile, xkbfilelength);
DEBUG_KBD("detect_keyboard_type_and_layout_sunos: %X %s", keyboardLayoutID, xkbfile);
keyboardLayoutID = detect_keyboaFRDP_type_and_layout_sunos(xkbfile, xkbfilelength);
DEBUG_KBD("detect_keyboaFRDP_type_and_layout_sunos: %X %s", keyboardLayoutID, xkbfile);
}
#endif
if(keyboardLayoutID == 0)
{
keyboardLayoutID = detect_keyboard_layout_from_locale();
DEBUG_KBD("detect_keyboard_layout_from_locale: %X", keyboardLayoutID);
keyboardLayoutID = detect_keyboaFRDP_layout_from_locale();
DEBUG_KBD("detect_keyboaFRDP_layout_from_locale: %X", keyboardLayoutID);
}
if (keyboardLayoutID == 0)
@ -86,7 +86,7 @@ detect_keyboard(void *dpy, unsigned int keyboardLayoutID, char *xkbfile, size_t
*/
unsigned int
freerdp_kbd_init(void *dpy, unsigned int keyboard_layout_id)
freerdp_kbd_init(void *dpy, unsigned int keyboaFRDP_layout_id)
{
#ifdef WITH_XKBFILE
if (!init_xkb(dpy))
@ -94,10 +94,10 @@ freerdp_kbd_init(void *dpy, unsigned int keyboard_layout_id)
DEBUG_KBD("Error initializing xkb");
return 0;
}
if (!keyboard_layout_id)
if (!keyboaFRDP_layout_id)
{
keyboard_layout_id = detect_keyboard_layout_from_xkb(dpy);
DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboard_layout_id);
keyboaFRDP_layout_id = detect_keyboaFRDP_layout_from_xkb(dpy);
DEBUG_KBD("detect_keyboaFRDP_layout_from_xkb: %X", keyboaFRDP_layout_id);
}
init_keycodes_from_xkb(dpy, x_keycode_to_rdp_keycode);
#else
@ -105,11 +105,11 @@ freerdp_kbd_init(void *dpy, unsigned int keyboard_layout_id)
KeycodeToVkcode keycodeToVkcode;
int keycode;
keyboard_layout_id = detect_keyboard(dpy, keyboard_layout_id, xkbfile, sizeof(xkbfile));
keyboaFRDP_layout_id = detect_keyboard(dpy, keyboaFRDP_layout_id, xkbfile, sizeof(xkbfile));
DEBUG_KBD("Using keyboard layout 0x%X with xkb name %s and xkbfile %s",
keyboard_layout_id, get_layout_name(keyboard_layout_id), xkbfile);
keyboaFRDP_layout_id, get_layout_name(keyboaFRDP_layout_id), xkbfile);
load_keyboard_map(keycodeToVkcode, xkbfile);
load_keyboaFRDP_map(keycodeToVkcode, xkbfile);
for (keycode=0; keycode<256; keycode++)
{
@ -126,17 +126,17 @@ freerdp_kbd_init(void *dpy, unsigned int keyboard_layout_id)
}
#endif
return keyboard_layout_id;
return keyboaFRDP_layout_id;
}
rdpKeyboardLayout *
freerdp_kbd_get_layouts(int types)
{
return get_keyboard_layouts(types);
return get_keyboaFRDP_layouts(types);
}
uint8
freerdp_kbd_get_scancode_by_keycode(uint8 keycode, RD_BOOL * extended)
freerdp_kbd_get_scancode_by_keycode(uint8 keycode, FRDP_BOOL * extended)
{
DEBUG_KBD("%2x %4s -> %d/%d", keycode, x_keycode_to_rdp_keycode[keycode].keyname,
x_keycode_to_rdp_keycode[keycode].extended, x_keycode_to_rdp_keycode[keycode].keycode);
@ -145,7 +145,7 @@ freerdp_kbd_get_scancode_by_keycode(uint8 keycode, RD_BOOL * extended)
}
uint8
freerdp_kbd_get_scancode_by_virtualkey(int vkcode, RD_BOOL * extended)
freerdp_kbd_get_scancode_by_virtualkey(int vkcode, FRDP_BOOL * extended)
{
*extended = virtualKeyboard[vkcode].extended;
return virtualKeyboard[vkcode].scancode;

View File

@ -422,7 +422,7 @@ static const localeAndKeyboardLayout defaultKeyboardLayouts[] =
};
unsigned int
detect_keyboard_layout_from_locale()
detect_keyboaFRDP_layout_from_locale()
{
int i;
int j;

View File

@ -321,6 +321,6 @@ Time zones, taken from Windows Server 2008
*/
unsigned int
detect_keyboard_layout_from_locale();
detect_keyboaFRDP_layout_from_locale();
#endif /* __LOCALES_H */

View File

@ -1076,7 +1076,7 @@ SunOSKeyboard SunOSKeyboards[] =
};
unsigned int
find_keyboard_layout_in_xorg_rules(char* layout, char* variant)
find_keyboaFRDP_layout_in_xorg_rules(char* layout, char* variant)
{
int i;
int j;
@ -1108,7 +1108,7 @@ find_keyboard_layout_in_xorg_rules(char* layout, char* variant)
#if defined(sun)
unsigned int
detect_keyboard_type_and_layout_sunos(char* xkbfile, int length)
detect_keyboaFRDP_type_and_layout_sunos(char* xkbfile, int length)
{
FILE* kbd;

View File

@ -23,11 +23,11 @@
#define __LAYOUTS_X_H
unsigned int
find_keyboard_layout_in_xorg_rules(char* layout, char* variant);
find_keyboaFRDP_layout_in_xorg_rules(char* layout, char* variant);
#if defined(sun)
unsigned int
detect_keyboard_type_and_layout_sunos(char* xkbfile, int length);
detect_keyboaFRDP_type_and_layout_sunos(char* xkbfile, int length);
#endif
#endif

View File

@ -17,7 +17,6 @@
* limitations under the License.
*/
#include "config.h"
#include <errno.h>
#include <freerdp/utils/memory.h>