2012-01-04 03:09:33 +00:00
|
|
|
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is libguac-client-rdp.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Michael Jumper.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2012-03-05 20:15:35 +00:00
|
|
|
* Matt Hortman
|
2012-01-04 03:09:33 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include <freerdp/freerdp.h>
|
|
|
|
|
|
|
|
#include <guacamole/client.h>
|
|
|
|
|
|
|
|
#include "client.h"
|
2012-02-08 23:09:12 +00:00
|
|
|
#include "rdp_bitmap.h"
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2012-02-27 20:39:13 +00:00
|
|
|
guac_transfer_function guac_rdp_rop3_transfer_function(guac_client* client,
|
2012-02-27 18:53:45 +00:00
|
|
|
int rop3) {
|
|
|
|
|
|
|
|
/* Translate supported ROP3 opcodes into composite modes */
|
|
|
|
switch (rop3) {
|
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSon" !(src | dest) */
|
|
|
|
case 0x11: return GUAC_TRANSFER_BINARY_NOR;
|
|
|
|
|
|
|
|
/* "DSna" !src & dest */
|
|
|
|
case 0x22: return GUAC_TRANSFER_BINARY_NSRC_AND;
|
|
|
|
|
|
|
|
/* "Sn" !src */
|
|
|
|
case 0x33: return GUAC_TRANSFER_BINARY_NSRC;
|
|
|
|
|
|
|
|
/* "SDna" (src & !dest) */
|
|
|
|
case 0x44: return GUAC_TRANSFER_BINARY_NDEST_AND;
|
|
|
|
|
|
|
|
/* "Dn" !dest */
|
|
|
|
case 0x55: return GUAC_TRANSFER_BINARY_NDEST;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCINVERT" (src ^ dest) */
|
2012-03-01 20:31:06 +00:00
|
|
|
case 0x66: return GUAC_TRANSFER_BINARY_XOR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSan" !(src & dest) */
|
|
|
|
case 0x77: return GUAC_TRANSFER_BINARY_NAND;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCAND" (src & dest) */
|
2012-02-27 20:39:13 +00:00
|
|
|
case 0x88: return GUAC_TRANSFER_BINARY_AND;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "DSxn" !(src ^ dest) */
|
|
|
|
case 0x99: return GUAC_TRANSFER_BINARY_XNOR;
|
|
|
|
|
2012-03-01 20:31:06 +00:00
|
|
|
/* "MERGEPAINT" (!src | dest)*/
|
|
|
|
case 0xBB: return GUAC_TRANSFER_BINARY_NSRC_OR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* "SDno" (src | !dest) */
|
|
|
|
case 0xDD: return GUAC_TRANSFER_BINARY_NDEST_OR;
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
/* "SRCPAINT" (src | dest) */
|
2012-02-27 20:39:13 +00:00
|
|
|
case 0xEE: return GUAC_TRANSFER_BINARY_OR;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
2012-03-07 23:28:35 +00:00
|
|
|
/* 0x00 = "BLACKNESS" (0) */
|
|
|
|
/* 0xAA = "NOP" (dest) */
|
2012-03-07 23:35:38 +00:00
|
|
|
/* 0xCC = "SRCCOPY" (src) */
|
2012-03-07 23:28:35 +00:00
|
|
|
/* 0xFF = "WHITENESS" (1) */
|
|
|
|
|
2012-02-27 18:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Log warning if ROP3 opcode not supported */
|
2012-02-27 20:39:13 +00:00
|
|
|
guac_client_log_info (client, "guac_rdp_rop3_transfer_function: "
|
|
|
|
"UNSUPPORTED opcode = 0x%02X", rop3);
|
|
|
|
|
|
|
|
/* Default to BINARY_SRC */
|
|
|
|
return GUAC_TRANSFER_BINARY_SRC;
|
2012-02-27 18:53:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
void guac_rdp_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) {
|
2012-02-17 21:57:27 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2012-02-17 21:57:27 +00:00
|
|
|
const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;
|
|
|
|
|
|
|
|
switch (dstblt->bRop) {
|
|
|
|
|
|
|
|
/* Blackness */
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
/* Send black rectangle */
|
|
|
|
guac_protocol_send_rect(client->socket,
|
|
|
|
GUAC_COMP_OVER, current_layer,
|
|
|
|
dstblt->nLeftRect, dstblt->nTopRect,
|
|
|
|
dstblt->nWidth, dstblt->nHeight,
|
|
|
|
0, 0, 0, 255);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Unsupported ROP3 */
|
|
|
|
default:
|
|
|
|
guac_client_log_info(client,
|
|
|
|
"guac_rdp_gdi_dstblt(rop3=%i)", dstblt->bRop);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) {
|
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
|
|
|
guac_client_log_info(client, "guac_rdp_gdi_patblt()");
|
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) {
|
2012-02-09 18:30:38 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2012-02-09 18:30:38 +00:00
|
|
|
const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;
|
|
|
|
|
|
|
|
/* Copy screen rect to current surface */
|
|
|
|
guac_protocol_send_copy(client->socket,
|
|
|
|
GUAC_DEFAULT_LAYER,
|
|
|
|
scrblt->nXSrc, scrblt->nYSrc, scrblt->nWidth, scrblt->nHeight,
|
|
|
|
GUAC_COMP_OVER, current_layer,
|
|
|
|
scrblt->nLeftRect, scrblt->nTopRect);
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) {
|
2012-02-08 23:09:12 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2012-02-08 23:09:12 +00:00
|
|
|
const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;
|
|
|
|
guac_socket* socket = client->socket;
|
|
|
|
guac_rdp_bitmap* bitmap = (guac_rdp_bitmap*) memblt->bitmap;
|
|
|
|
|
2012-02-27 20:39:13 +00:00
|
|
|
if (bitmap->layer != NULL) {
|
|
|
|
|
2012-03-07 23:35:38 +00:00
|
|
|
switch (memblt->bRop) {
|
|
|
|
|
|
|
|
/* If blackness, send black rectangle */
|
|
|
|
case 0x00:
|
|
|
|
guac_protocol_send_rect(client->socket,
|
|
|
|
GUAC_COMP_OVER, current_layer,
|
|
|
|
memblt->nLeftRect, memblt->nTopRect,
|
|
|
|
memblt->nWidth, memblt->nHeight,
|
|
|
|
0x00, 0x00, 0x00, 0xFF);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* If NOP, do nothing */
|
|
|
|
case 0xAA:
|
|
|
|
break;
|
|
|
|
|
2012-02-27 20:39:13 +00:00
|
|
|
/* If operation is just SRC, simply copy */
|
2012-03-07 23:35:38 +00:00
|
|
|
case 0xCC:
|
2012-02-27 20:39:13 +00:00
|
|
|
guac_protocol_send_copy(socket,
|
|
|
|
bitmap->layer,
|
|
|
|
memblt->nXSrc, memblt->nYSrc,
|
|
|
|
memblt->nWidth, memblt->nHeight,
|
|
|
|
GUAC_COMP_OVER,
|
|
|
|
current_layer, memblt->nLeftRect, memblt->nTopRect);
|
2012-03-07 23:35:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* If whiteness, send white rectangle */
|
|
|
|
case 0xFF:
|
|
|
|
guac_protocol_send_rect(client->socket,
|
|
|
|
GUAC_COMP_OVER, current_layer,
|
|
|
|
memblt->nLeftRect, memblt->nTopRect,
|
|
|
|
memblt->nWidth, memblt->nHeight,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2012-02-27 20:39:13 +00:00
|
|
|
|
|
|
|
/* Otherwise, use transfer */
|
2012-03-07 23:35:38 +00:00
|
|
|
default:
|
2012-02-27 20:39:13 +00:00
|
|
|
guac_protocol_send_transfer(socket,
|
|
|
|
bitmap->layer,
|
|
|
|
memblt->nXSrc, memblt->nYSrc,
|
|
|
|
memblt->nWidth, memblt->nHeight,
|
|
|
|
guac_rdp_rop3_transfer_function(client, memblt->bRop),
|
|
|
|
current_layer, memblt->nLeftRect, memblt->nTopRect);
|
|
|
|
|
|
|
|
}
|
2012-02-08 23:09:12 +00:00
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) {
|
|
|
|
|
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
2012-02-23 18:01:41 +00:00
|
|
|
uint32 color = freerdp_color_convert_var(opaque_rect->color,
|
2012-02-08 20:32:27 +00:00
|
|
|
context->instance->settings->color_depth, 32,
|
|
|
|
((rdp_freerdp_context*) context)->clrconv);
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2012-01-11 07:31:24 +00:00
|
|
|
const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;
|
|
|
|
|
2012-01-04 03:09:33 +00:00
|
|
|
guac_protocol_send_rect(client->socket,
|
2012-01-11 07:31:24 +00:00
|
|
|
GUAC_COMP_OVER, current_layer,
|
2012-01-04 03:09:33 +00:00
|
|
|
opaque_rect->nLeftRect, opaque_rect->nTopRect,
|
|
|
|
opaque_rect->nWidth, opaque_rect->nHeight,
|
|
|
|
(color >> 16) & 0xFF,
|
|
|
|
(color >> 8 ) & 0xFF,
|
|
|
|
(color ) & 0xFF,
|
|
|
|
255);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-08 20:32:27 +00:00
|
|
|
void guac_rdp_gdi_palette_update(rdpContext* context, PALETTE_UPDATE* palette) {
|
2012-01-04 03:09:33 +00:00
|
|
|
|
2012-02-08 20:32:27 +00:00
|
|
|
CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv;
|
|
|
|
clrconv->palette->count = palette->number;
|
|
|
|
clrconv->palette->entries = palette->entries;
|
|
|
|
|
|
|
|
}
|
2012-02-08 22:16:05 +00:00
|
|
|
|
|
|
|
void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) {
|
|
|
|
|
|
|
|
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
|
|
|
const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;
|
|
|
|
|
|
|
|
/* Set clip if specified */
|
|
|
|
if (bounds != NULL)
|
|
|
|
guac_protocol_send_clip(
|
|
|
|
client->socket,
|
|
|
|
current_layer,
|
|
|
|
bounds->left,
|
|
|
|
bounds->top,
|
|
|
|
bounds->right - bounds->left + 1,
|
|
|
|
bounds->bottom - bounds->top + 1);
|
|
|
|
|
|
|
|
/* Otherwise, reset clip */
|
|
|
|
else
|
|
|
|
guac_protocol_send_clip(
|
|
|
|
client->socket,
|
|
|
|
current_layer,
|
|
|
|
0, 0,
|
|
|
|
context->instance->settings->width,
|
|
|
|
context->instance->settings->height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|