1
1
/* -*- c-basic-offset: 8 -*-
2
2
rdesktop: A Remote Desktop Protocol client.
4
Copyright (C) Matthew Chapman 1999-2007
4
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
6
This program is free software; you can redistribute it and/or modify
6
This program is free software: you can redistribute it and/or modify
7
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
8
the Free Software Foundation, either version 3 of the License, or
9
9
(at your option) any later version.
11
11
This program is distributed in the hope that it will be useful,
14
14
GNU General Public License for more details.
16
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
157
156
return s_check(s);
160
setup_brush(BRUSH * out_brush, BRUSH * in_brush)
162
BRUSHDATA *brush_data;
166
memcpy(out_brush, in_brush, sizeof(BRUSH));
167
if (out_brush->style & 0x80)
169
colour_code = out_brush->style & 0x0f;
170
cache_idx = out_brush->pattern[0];
171
brush_data = cache_get_brush_data(colour_code, cache_idx);
172
if ((brush_data == NULL) || (brush_data->data == NULL))
174
error("error getting brush data, style %x\n", out_brush->style);
175
out_brush->bd = NULL;
176
memset(out_brush->pattern, 0, 8);
180
out_brush->bd = brush_data;
182
out_brush->style = 3;
160
186
/* Parse a brush */
162
188
rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present)
234
262
DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x,
235
263
os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour));
265
setup_brush(&brush, &os->brush);
237
267
ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,
238
&os->brush, os->bgcolour, os->fgcolour);
268
&brush, os->bgcolour, os->fgcolour);
241
271
/* Process a screen blt order */
485
516
if (bitmap == NULL)
519
setup_brush(&brush, &os->brush);
488
521
ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy,
489
bitmap, os->srcx, os->srcy, &os->brush, os->bgcolour, os->fgcolour);
522
bitmap, os->srcx, os->srcy, &brush, os->bgcolour, os->fgcolour);
492
525
/* Process a polygon order */
647
683
if (next - 1 == os->npoints)
648
684
ui_polygon(os->opcode - 1, os->fillmode, points, os->npoints + 1,
649
&os->brush, os->bgcolour, os->fgcolour);
685
&brush, os->bgcolour, os->fgcolour);
651
687
error("polygon2 parse error\n");
797
835
os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->brush.style,
798
836
os->bgcolour, os->fgcolour));
838
setup_brush(&brush, &os->brush);
800
840
ui_ellipse(os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left,
801
os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour);
841
os->bottom - os->top, &brush, os->bgcolour, os->fgcolour);
804
844
/* Process a text order */
916
setup_brush(&brush, &os->brush);
875
918
ui_draw_text(os->font, os->flags, os->opcode - 1, os->mixmode, os->x, os->y,
876
919
os->clipleft, os->cliptop, os->clipright - os->clipleft,
877
920
os->clipbottom - os->cliptop, os->boxleft, os->boxtop,
878
921
os->boxright - os->boxleft, os->boxbottom - os->boxtop,
879
&os->brush, os->bgcolour, os->fgcolour, os->text, os->length);
922
&brush, os->bgcolour, os->fgcolour, os->text, os->length);
882
925
/* Process a raw bitmap cache order */
1160
process_compressed_8x8_brush_data(uint8 * in, uint8 * out, int Bpp)
1162
int x, y, pal_index, in_index, shift, do2, i;
1167
/* read it bottom up */
1168
for (y = 7; y >= 0; y--)
1170
/* 2 bytes per row */
1172
for (do2 = 0; do2 < 2; do2++)
1174
/* 4 pixels per byte */
1178
pal_index = (in[in_index] >> shift) & 3;
1179
/* size of palette entries depends on Bpp */
1180
for (i = 0; i < Bpp; i++)
1182
out[(y * 8 + x) * Bpp + i] = pal[pal_index * Bpp + i];
1192
/* Process a brush cache order */
1194
process_brushcache(STREAM s, uint16 flags)
1196
BRUSHDATA brush_data;
1197
uint8 cache_idx, colour_code, width, height, size, type;
1202
in_uint8(s, cache_idx);
1203
in_uint8(s, colour_code);
1205
in_uint8(s, height);
1206
in_uint8(s, type); /* type, 0x8x = cached */
1209
DEBUG(("BRUSHCACHE(idx=%d,wd=%d,ht=%d,sz=%d)\n", cache_idx, width, height, size));
1211
if ((width == 8) && (height == 8))
1213
if (colour_code == 1)
1215
brush_data.colour_code = 1;
1216
brush_data.data_size = 8;
1217
brush_data.data = xmalloc(8);
1220
/* read it bottom up */
1221
for (index = 7; index >= 0; index--)
1223
in_uint8(s, brush_data.data[index]);
1228
warning("incompatible brush, colour_code %d size %d\n", colour_code,
1231
cache_put_brush_data(1, cache_idx, &brush_data);
1233
else if ((colour_code >= 3) && (colour_code <= 6))
1235
Bpp = colour_code - 2;
1236
brush_data.colour_code = colour_code;
1237
brush_data.data_size = 8 * 8 * Bpp;
1238
brush_data.data = xmalloc(8 * 8 * Bpp);
1239
if (size == 16 + 4 * Bpp)
1241
in_uint8p(s, comp_brush, 16 + 4 * Bpp);
1242
process_compressed_8x8_brush_data(comp_brush, brush_data.data, Bpp);
1246
in_uint8a(s, brush_data.data, 8 * 8 * Bpp);
1248
cache_put_brush_data(colour_code, cache_idx, &brush_data);
1252
warning("incompatible brush, colour_code %d size %d\n", colour_code, size);
1257
warning("incompatible brush, width height %d %d\n", width, height);
1116
1261
/* Process a secondary order */
1118
1263
process_secondary_order(STREAM s)