181
194
function = GXset;
188
205
if (function < 0)
190
printf("Unsupported ROP3: 0x%08X\n", rop3);
191
XSetFunction(xfi->display, xfi->gc, GXclear);
207
fprintf(stderr, "Unsupported ROP3: 0x%08X\n", rop3);
208
XSetFunction(xfc->display, xfc->gc, GXclear);
195
XSetFunction(xfi->display, xfi->gc, function);
212
XSetFunction(xfc->display, xfc->gc, function);
200
Pixmap xf_brush_new(xfInfo* xfi, int width, int height, int bpp, uint8* data)
217
Pixmap xf_brush_new(xfContext* xfc, int width, int height, int bpp, BYTE* data)
206
bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, xfi->depth);
223
bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, xfc->depth);
210
GC gc; // FIXME, should cache
212
cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfi->bpp, xfi->clrconv);
213
image = XCreateImage(xfi->display, xfi->visual, xfi->depth,
214
ZPixmap, 0, (char*) cdata, width, height, xfi->scanline_pad, 0);
216
gc = XCreateGC(xfi->display, xfi->drawable, 0, NULL);
217
XPutImage(xfi->display, bitmap, gc, image, 0, 0, 0, 0, width, height);
229
cdata = freerdp_image_convert(data, NULL, width, height, bpp, xfc->bpp, xfc->clrconv);
231
image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
232
ZPixmap, 0, (char*) cdata, width, height, xfc->scanline_pad, 0);
234
gc = XCreateGC(xfc->display, xfc->drawable, 0, NULL);
235
XPutImage(xfc->display, bitmap, gc, image, 0, 0, 0, 0, width, height);
219
238
if (cdata != data)
222
XFreeGC(xfi->display, gc);
241
XFreeGC(xfc->display, gc);
228
Pixmap xf_mono_bitmap_new(xfInfo* xfi, int width, int height, uint8* data)
234
scanline = (width + 7) / 8;
236
bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, 1);
238
image = XCreateImage(xfi->display, xfi->visual, 1,
239
ZPixmap, 0, (char*) data, width, height, 8, scanline);
241
XPutImage(xfi->display, bitmap, xfi->gc_mono, image, 0, 0, 0, 0, width, height);
247
Pixmap xf_glyph_new(xfInfo* xfi, int width, int height, uint8* data)
253
scanline = (width + 7) / 8;
255
bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, 1);
257
image = XCreateImage(xfi->display, xfi->visual, 1,
258
ZPixmap, 0, (char*) data, width, height, 8, scanline);
260
image->byte_order = MSBFirst;
261
image->bitmap_bit_order = MSBFirst;
264
XPutImage(xfi->display, bitmap, xfi->gc_mono, image, 0, 0, 0, 0, width, height);
247
Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height, BYTE* data)
253
scanline = (width + 7) / 8;
255
bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, 1);
257
image = XCreateImage(xfc->display, xfc->visual, 1,
258
ZPixmap, 0, (char*) data, width, height, 8, scanline);
260
XPutImage(xfc->display, bitmap, xfc->gc_mono, image, 0, 0, 0, 0, width, height);
285
287
clip.y = bounds->top;
286
288
clip.width = bounds->right - bounds->left + 1;
287
289
clip.height = bounds->bottom - bounds->top + 1;
288
XSetClipRectangles(xfi->display, xfi->gc, 0, 0, &clip, 1, YXBanded);
290
XSetClipRectangles(xfc->display, xfc->gc, 0, 0, &clip, 1, YXBanded);
292
XSetClipMask(xfi->display, xfi->gc, None);
294
XSetClipMask(xfc->display, xfc->gc, None);
297
xf_unlock_x11(xfc, FALSE);
296
300
void xf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
298
xfInfo* xfi = ((xfContext*) context)->xfi;
300
xf_set_rop3(xfi, gdi_rop3_code(dstblt->bRop));
302
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
303
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
302
xfContext* xfc = (xfContext*) context;
304
xf_lock_x11(xfc, FALSE);
306
xf_set_rop3(xfc, gdi_rop3_code(dstblt->bRop));
308
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
309
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
304
310
dstblt->nLeftRect, dstblt->nTopRect,
305
311
dstblt->nWidth, dstblt->nHeight);
307
if (xfi->drawing == xfi->primary)
313
if (xfc->drawing == xfc->primary)
309
if (xfi->remote_app != true)
311
XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
312
dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
315
gdi_InvalidateRegion(xfi->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
315
gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
317
XSetFunction(xfi->display, xfi->gc, GXcopy);
318
XSetFunction(xfc->display, xfc->gc, GXcopy);
320
xf_unlock_x11(xfc, FALSE);
320
323
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
326
xfInfo* xfi = ((xfContext*) context)->xfi;
329
xfContext* xfc = (xfContext*) context;
331
xf_lock_x11(xfc, FALSE);
328
333
brush = &patblt->brush;
329
xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop));
334
xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop));
331
foreColor = freerdp_color_convert_rgb(patblt->foreColor, xfi->srcBpp, xfi->bpp, xfi->clrconv);
332
backColor = freerdp_color_convert_rgb(patblt->backColor, xfi->srcBpp, xfi->bpp, xfi->clrconv);
336
foreColor = freerdp_color_convert_var(patblt->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
337
backColor = freerdp_color_convert_var(patblt->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
334
339
if (brush->style == GDI_BS_SOLID)
336
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
337
XSetForeground(xfi->display, xfi->gc, foreColor);
341
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
342
XSetForeground(xfc->display, xfc->gc, foreColor);
339
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
344
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
340
345
patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
347
else if (brush->style == GDI_BS_HATCHED)
349
pattern = xf_mono_bitmap_new(xfc, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch);
351
XSetForeground(xfc->display, xfc->gc, backColor);
352
XSetBackground(xfc->display, xfc->gc, foreColor);
353
XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
354
XSetStipple(xfc->display, xfc->gc, pattern);
355
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
357
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
358
patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
360
XFreePixmap(xfc->display, pattern);
342
362
else if (brush->style == GDI_BS_PATTERN)
344
364
if (brush->bpp > 1)
346
pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data);
348
XSetFillStyle(xfi->display, xfi->gc, FillTiled);
349
XSetTile(xfi->display, xfi->gc, pattern);
350
XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);
352
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
366
pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
368
XSetFillStyle(xfc->display, xfc->gc, FillTiled);
369
XSetTile(xfc->display, xfc->gc, pattern);
370
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
372
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
353
373
patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
355
XSetTile(xfi->display, xfi->gc, xfi->primary);
375
XSetTile(xfc->display, xfc->gc, xfc->primary);
357
XFreePixmap(xfi->display, pattern);
377
XFreePixmap(xfc->display, pattern);
361
pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data);
363
XSetForeground(xfi->display, xfi->gc, backColor);
364
XSetBackground(xfi->display, xfi->gc, foreColor);
365
XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled);
366
XSetStipple(xfi->display, xfi->gc, pattern);
367
XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y);
369
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
381
pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
383
XSetForeground(xfc->display, xfc->gc, backColor);
384
XSetBackground(xfc->display, xfc->gc, foreColor);
385
XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
386
XSetStipple(xfc->display, xfc->gc, pattern);
387
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
389
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
370
390
patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
372
XFreePixmap(xfi->display, pattern);
392
XFreePixmap(xfc->display, pattern);
377
printf("unimplemented brush style:%d\n", brush->style);
397
fprintf(stderr, "unimplemented brush style:%d\n", brush->style);
380
if (xfi->drawing == xfi->primary)
400
if (xfc->drawing == xfc->primary)
382
XSetFunction(xfi->display, xfi->gc, GXcopy);
384
if (xfi->remote_app != true)
386
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect,
387
patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect);
390
gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
402
gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
393
XSetFunction(xfi->display, xfi->gc, GXcopy);
405
XSetFunction(xfc->display, xfc->gc, GXcopy);
407
xf_unlock_x11(xfc, FALSE);
396
410
void xf_gdi_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
398
xfInfo* xfi = ((xfContext*) context)->xfi;
400
xf_set_rop3(xfi, gdi_rop3_code(scrblt->bRop));
402
XCopyArea(xfi->display, xfi->primary, xfi->drawing, xfi->gc, scrblt->nXSrc, scrblt->nYSrc,
412
xfContext* xfc = (xfContext*) context;
414
xf_lock_x11(xfc, FALSE);
416
xf_set_rop3(xfc, gdi_rop3_code(scrblt->bRop));
418
XCopyArea(xfc->display, xfc->primary, xfc->drawing, xfc->gc, scrblt->nXSrc, scrblt->nYSrc,
403
419
scrblt->nWidth, scrblt->nHeight, scrblt->nLeftRect, scrblt->nTopRect);
405
if (xfi->drawing == xfi->primary)
421
if (xfc->drawing == xfc->primary)
407
if (xfi->remote_app != true)
411
XCopyArea(xfi->display, xfi->drawable, xfi->drawable, xfi->gc,
412
scrblt->nXSrc, scrblt->nYSrc, scrblt->nWidth, scrblt->nHeight,
413
scrblt->nLeftRect, scrblt->nTopRect);
417
XSetFunction(xfi->display, xfi->gc, GXcopy);
418
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc,
419
scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight,
420
scrblt->nLeftRect, scrblt->nTopRect);
424
gdi_InvalidateRegion(xfi->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
423
gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
427
XSetFunction(xfi->display, xfi->gc, GXcopy);
426
XSetFunction(xfc->display, xfc->gc, GXcopy);
428
xf_unlock_x11(xfc, FALSE);
430
431
void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
433
xfInfo* xfi = ((xfContext*) context)->xfi;
435
color = freerdp_color_convert_var(opaque_rect->color, xfi->srcBpp, xfi->bpp, xfi->clrconv);
437
XSetFunction(xfi->display, xfi->gc, GXcopy);
438
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
439
XSetForeground(xfi->display, xfi->gc, color);
441
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
434
xfContext* xfc = (xfContext*) context;
436
xf_lock_x11(xfc, FALSE);
438
color = freerdp_color_convert_var(opaque_rect->color, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
440
XSetFunction(xfc->display, xfc->gc, GXcopy);
441
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
442
XSetForeground(xfc->display, xfc->gc, color);
444
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
442
445
opaque_rect->nLeftRect, opaque_rect->nTopRect,
443
446
opaque_rect->nWidth, opaque_rect->nHeight);
445
if (xfi->drawing == xfi->primary)
448
if (xfc->drawing == xfc->primary)
447
if (xfi->remote_app != true)
449
XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
450
opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight);
453
gdi_InvalidateRegion(xfi->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
450
gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
454
451
opaque_rect->nWidth, opaque_rect->nHeight);
454
xf_unlock_x11(xfc, FALSE);
458
457
void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
462
461
DELTA_RECT* rectangle;
463
xfInfo* xfi = ((xfContext*) context)->xfi;
465
color = freerdp_color_convert_var(multi_opaque_rect->color, xfi->srcBpp, xfi->bpp, xfi->clrconv);
467
XSetFunction(xfi->display, xfi->gc, GXcopy);
468
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
469
XSetForeground(xfi->display, xfi->gc, color);
462
xfContext* xfc = (xfContext*) context;
464
xf_lock_x11(xfc, FALSE);
466
color = freerdp_color_convert_var(multi_opaque_rect->color, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
468
XSetFunction(xfc->display, xfc->gc, GXcopy);
469
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
470
XSetForeground(xfc->display, xfc->gc, color);
471
472
for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
473
474
rectangle = &multi_opaque_rect->rectangles[i];
475
XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
476
XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
476
477
rectangle->left, rectangle->top,
477
478
rectangle->width, rectangle->height);
479
if (xfi->drawing == xfi->primary)
480
if (xfc->drawing == xfc->primary)
481
if (xfi->remote_app != true)
483
XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
484
rectangle->left, rectangle->top, rectangle->width, rectangle->height);
487
gdi_InvalidateRegion(xfi->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height);
482
gdi_InvalidateRegion(xfc->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height);
486
xf_unlock_x11(xfc, FALSE);
489
void xf_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid)
491
fprintf(stderr, "DrawNineGrid\n");
492
494
void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
495
xfInfo* xfi = ((xfContext*) context)->xfi;
497
xf_set_rop2(xfi, line_to->bRop2);
498
color = freerdp_color_convert_rgb(line_to->penColor, xfi->srcBpp, xfi->bpp, xfi->clrconv);
500
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
501
XSetForeground(xfi->display, xfi->gc, color);
503
XDrawLine(xfi->display, xfi->drawing, xfi->gc,
497
xfContext* xfc = (xfContext*) context;
499
xf_lock_x11(xfc, FALSE);
501
xf_set_rop2(xfc, line_to->bRop2);
502
color = freerdp_color_convert_var(line_to->penColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
504
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
505
XSetForeground(xfc->display, xfc->gc, color);
507
XDrawLine(xfc->display, xfc->drawing, xfc->gc,
504
508
line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd);
506
if (xfi->drawing == xfi->primary)
510
if (xfc->drawing == xfc->primary)
508
512
int width, height;
510
if (xfi->remote_app != true)
512
XDrawLine(xfi->display, xfi->drawable, xfi->gc,
513
line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd);
516
514
width = line_to->nXStart - line_to->nXEnd;
517
515
height = line_to->nYStart - line_to->nYEnd;
586
gdi_InvalidateRegion(xfi->hdc, x, y, width, height);
585
gdi_InvalidateRegion(xfc->hdc, x, y, width, height);
590
XSetFunction(xfi->display, xfi->gc, GXcopy);
589
XSetFunction(xfc->display, xfc->gc, GXcopy);
592
xf_unlock_x11(xfc, FALSE);
594
595
void xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
596
597
xfBitmap* bitmap;
597
xfInfo* xfi = ((xfContext*) context)->xfi;
598
xfContext* xfc = (xfContext*) context;
600
xf_lock_x11(xfc, FALSE);
599
602
bitmap = (xfBitmap*) memblt->bitmap;
600
xf_set_rop3(xfi, gdi_rop3_code(memblt->bRop));
603
xf_set_rop3(xfc, gdi_rop3_code(memblt->bRop));
602
XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc,
605
XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc,
603
606
memblt->nXSrc, memblt->nYSrc, memblt->nWidth, memblt->nHeight,
604
607
memblt->nLeftRect, memblt->nTopRect);
606
if (xfi->drawing == xfi->primary)
609
if (xfc->drawing == xfc->primary)
608
if (xfi->remote_app != true)
610
XCopyArea(xfi->display, bitmap->pixmap, xfi->drawable, xfi->gc,
611
memblt->nXSrc, memblt->nYSrc, memblt->nWidth, memblt->nHeight,
612
memblt->nLeftRect, memblt->nTopRect);
615
gdi_InvalidateRegion(xfi->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
611
gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, memblt->nHeight);
618
XSetFunction(xfi->display, xfi->gc, GXcopy);
614
XSetFunction(xfc->display, xfc->gc, GXcopy);
616
xf_unlock_x11(xfc, FALSE);
621
619
void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
626
xfContext* xfc = (xfContext*) context;
628
xf_lock_x11(xfc, FALSE);
630
brush = &mem3blt->brush;
631
bitmap = (xfBitmap*) mem3blt->bitmap;
632
xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop));
633
foreColor = freerdp_color_convert_var(mem3blt->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
634
backColor = freerdp_color_convert_var(mem3blt->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
636
if (brush->style == GDI_BS_PATTERN)
640
pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
642
XSetFillStyle(xfc->display, xfc->gc, FillTiled);
643
XSetTile(xfc->display, xfc->gc, pattern);
644
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
648
pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
650
XSetForeground(xfc->display, xfc->gc, backColor);
651
XSetBackground(xfc->display, xfc->gc, foreColor);
652
XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
653
XSetStipple(xfc->display, xfc->gc, pattern);
654
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
657
else if (brush->style == GDI_BS_SOLID)
659
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
660
XSetForeground(xfc->display, xfc->gc, backColor);
661
XSetBackground(xfc->display, xfc->gc, foreColor);
663
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
667
fprintf(stderr, "Mem3Blt unimplemented brush style:%d\n", brush->style);
670
XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc,
671
mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight,
672
mem3blt->nLeftRect, mem3blt->nTopRect);
674
if (xfc->drawing == xfc->primary)
676
gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight);
679
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
680
XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
683
XFreePixmap(xfc->display, pattern);
685
XSetFunction(xfc->display, xfc->gc, GXcopy);
687
xf_unlock_x11(xfc, FALSE);
690
void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
695
xfContext* xfc = (xfContext*) context;
697
xf_lock_x11(xfc, FALSE);
699
xf_set_rop2(xfc, polygon_sc->bRop2);
700
brush_color = freerdp_color_convert_var(polygon_sc->brushColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
702
npoints = polygon_sc->numPoints + 1;
703
points = malloc(sizeof(XPoint) * npoints);
705
points[0].x = polygon_sc->xStart;
706
points[0].y = polygon_sc->yStart;
708
for (i = 0; i < polygon_sc->numPoints; i++)
710
points[i + 1].x = polygon_sc->points[i].x;
711
points[i + 1].y = polygon_sc->points[i].y;
714
switch (polygon_sc->fillMode)
716
case 1: /* alternate */
717
XSetFillRule(xfc->display, xfc->gc, EvenOddRule);
720
case 2: /* winding */
721
XSetFillRule(xfc->display, xfc->gc, WindingRule);
725
fprintf(stderr, "PolygonSC unknown fillMode: %d\n", polygon_sc->fillMode);
729
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
730
XSetForeground(xfc->display, xfc->gc, brush_color);
732
XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
733
points, npoints, Complex, CoordModePrevious);
735
if (xfc->drawing == xfc->primary)
737
XFillPolygon(xfc->display, xfc->drawable, xfc->gc,
738
points, npoints, Complex, CoordModePrevious);
741
XSetFunction(xfc->display, xfc->gc, GXcopy);
744
xf_unlock_x11(xfc, FALSE);
747
void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
755
xfContext* xfc = (xfContext*) context;
757
xf_lock_x11(xfc, FALSE);
759
brush = &(polygon_cb->brush);
760
xf_set_rop2(xfc, polygon_cb->bRop2);
761
foreColor = freerdp_color_convert_var(polygon_cb->foreColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
762
backColor = freerdp_color_convert_var(polygon_cb->backColor, context->settings->ColorDepth, xfc->bpp, xfc->clrconv);
764
npoints = polygon_cb->numPoints + 1;
765
points = malloc(sizeof(XPoint) * npoints);
767
points[0].x = polygon_cb->xStart;
768
points[0].y = polygon_cb->yStart;
770
for (i = 0; i < polygon_cb->numPoints; i++)
772
points[i + 1].x = polygon_cb->points[i].x;
773
points[i + 1].y = polygon_cb->points[i].y;
776
switch (polygon_cb->fillMode)
778
case 1: /* alternate */
779
XSetFillRule(xfc->display, xfc->gc, EvenOddRule);
782
case 2: /* winding */
783
XSetFillRule(xfc->display, xfc->gc, WindingRule);
787
fprintf(stderr, "PolygonCB unknown fillMode: %d\n", polygon_cb->fillMode);
791
if (brush->style == GDI_BS_PATTERN)
795
pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data);
797
XSetFillStyle(xfc->display, xfc->gc, FillTiled);
798
XSetTile(xfc->display, xfc->gc, pattern);
799
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
801
XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
802
points, npoints, Complex, CoordModePrevious);
804
if (xfc->drawing == xfc->primary)
806
XFillPolygon(xfc->display, xfc->drawable, xfc->gc,
807
points, npoints, Complex, CoordModePrevious);
810
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
811
XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
812
XFreePixmap(xfc->display, pattern);
816
pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data);
818
XSetForeground(xfc->display, xfc->gc, backColor);
819
XSetBackground(xfc->display, xfc->gc, foreColor);
821
if (polygon_cb->backMode == BACKMODE_TRANSPARENT)
822
XSetFillStyle(xfc->display, xfc->gc, FillStippled);
823
else if (polygon_cb->backMode == BACKMODE_OPAQUE)
824
XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
826
XSetStipple(xfc->display, xfc->gc, pattern);
827
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
829
XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
830
points, npoints, Complex, CoordModePrevious);
832
if (xfc->drawing == xfc->primary)
834
XFillPolygon(xfc->display, xfc->drawable, xfc->gc,
835
points, npoints, Complex, CoordModePrevious);
838
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
839
XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
840
XFreePixmap(xfc->display, pattern);
845
fprintf(stderr, "PolygonCB unimplemented brush style:%d\n", brush->style);
848
XSetFunction(xfc->display, xfc->gc, GXcopy);
851
xf_unlock_x11(xfc, FALSE);
854
void xf_gdi_ellipse_sc(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc)
856
fprintf(stderr, "EllipseSC\n");
859
void xf_gdi_ellipse_cb(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb)
861
fprintf(stderr, "EllipseCB\n");
626
864
void xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker)
866
rdpSettings* settings;
867
xfContext* xfc = (xfContext*) context;
869
settings = xfc->instance->settings;
871
xf_lock_x11(xfc, FALSE);
873
switch (surface_frame_marker->frameAction)
875
case SURFACECMD_FRAMEACTION_BEGIN:
876
xfc->frame_begin = TRUE;
883
case SURFACECMD_FRAMEACTION_END:
884
xfc->frame_begin = FALSE;
885
if ((xfc->frame_x2 > xfc->frame_x1) && (xfc->frame_y2 > xfc->frame_y1))
887
gdi_InvalidateRegion(xfc->hdc, xfc->frame_x1, xfc->frame_y1,
888
xfc->frame_x2 - xfc->frame_x1, xfc->frame_y2 - xfc->frame_y1);
890
if (settings->FrameAcknowledge > 0)
892
IFCALL(xfc->instance->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
897
xf_unlock_x11(xfc, FALSE);
900
static void xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UINT16 width, UINT16 height)
902
if (!xfc->remote_app)
904
if (xfc->frame_begin)
906
if (xfc->frame_x2 > xfc->frame_x1 && xfc->frame_y2 > xfc->frame_y1)
908
xfc->frame_x1 = MIN(xfc->frame_x1, tx);
909
xfc->frame_y1 = MIN(xfc->frame_y1, ty);
910
xfc->frame_x2 = MAX(xfc->frame_x2, tx + width);
911
xfc->frame_y2 = MAX(xfc->frame_y2, ty + height);
917
xfc->frame_x2 = tx + width;
918
xfc->frame_y2 = ty + height;
923
gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
928
gdi_InvalidateRegion(xfc->hdc, tx, ty, width, height);
631
932
void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits_command)
668
971
tx = message->rects[i].x + surface_bits_command->destLeft;
669
972
ty = message->rects[i].y + surface_bits_command->destTop;
671
if (xfi->remote_app != true)
673
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc,
674
tx, ty, message->rects[i].width, message->rects[i].height, tx, ty);
677
gdi_InvalidateRegion(xfi->hdc, tx, ty, message->rects[i].width, message->rects[i].height);
974
xf_gdi_surface_update_frame(xfc, tx, ty, message->rects[i].width, message->rects[i].height);
680
XSetClipMask(xfi->display, xfi->gc, None);
977
XSetClipMask(xfc->display, xfc->gc, None);
681
978
rfx_message_free(rfx_context, message);
683
else if (surface_bits_command->codecID == CODEC_ID_NSCODEC)
980
else if (surface_bits_command->codecID == RDP_CODEC_ID_NSCODEC)
685
nsc_context->width = surface_bits_command->width;
686
nsc_context->height = surface_bits_command->height;
687
nsc_process_message(nsc_context, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
688
XSetFunction(xfi->display, xfi->gc, GXcopy);
689
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
691
xfi->bmp_codec_nsc = (uint8*) xrealloc(xfi->bmp_codec_nsc,
982
nsc_process_message(nsc_context, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height,
983
surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
985
XSetFunction(xfc->display, xfc->gc, GXcopy);
986
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
988
xfc->bmp_codec_nsc = (BYTE*) realloc(xfc->bmp_codec_nsc,
692
989
surface_bits_command->width * surface_bits_command->height * 4);
694
freerdp_image_flip(nsc_context->bmpdata, xfi->bmp_codec_nsc,
991
freerdp_image_flip(nsc_context->bmpdata, xfc->bmp_codec_nsc,
695
992
surface_bits_command->width, surface_bits_command->height, 32);
697
image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0,
698
(char*) xfi->bmp_codec_nsc, surface_bits_command->width, surface_bits_command->height, 32, 0);
700
XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0,
701
surface_bits_command->destLeft, surface_bits_command->destTop,
702
surface_bits_command->width, surface_bits_command->height);
704
if (xfi->remote_app != true)
706
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc,
707
surface_bits_command->destLeft, surface_bits_command->destTop,
708
surface_bits_command->width, surface_bits_command->height,
709
surface_bits_command->destLeft, surface_bits_command->destTop);
712
gdi_InvalidateRegion(xfi->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
713
surface_bits_command->width, surface_bits_command->height);
715
XSetClipMask(xfi->display, xfi->gc, None);
716
nsc_context_destroy(nsc_context);
994
image = XCreateImage(xfc->display, xfc->visual, 24, ZPixmap, 0,
995
(char*) xfc->bmp_codec_nsc, surface_bits_command->width, surface_bits_command->height, 32, 0);
997
XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
998
surface_bits_command->destLeft, surface_bits_command->destTop,
999
surface_bits_command->width, surface_bits_command->height);
1002
xf_gdi_surface_update_frame(xfc,
1003
surface_bits_command->destLeft, surface_bits_command->destTop,
1004
surface_bits_command->width, surface_bits_command->height);
1006
XSetClipMask(xfc->display, xfc->gc, None);
718
else if (surface_bits_command->codecID == CODEC_ID_NONE)
1008
else if (surface_bits_command->codecID == RDP_CODEC_ID_NONE)
720
XSetFunction(xfi->display, xfi->gc, GXcopy);
721
XSetFillStyle(xfi->display, xfi->gc, FillSolid);
723
xfi->bmp_codec_none = (uint8*) xrealloc(xfi->bmp_codec_none,
724
surface_bits_command->width * surface_bits_command->height * 4);
726
freerdp_image_flip(surface_bits_command->bitmapData, xfi->bmp_codec_none,
727
surface_bits_command->width, surface_bits_command->height, 32);
729
image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0,
730
(char*) xfi->bmp_codec_none, surface_bits_command->width, surface_bits_command->height, 32, 0);
732
XPutImage(xfi->display, xfi->primary, xfi->gc, image, 0, 0,
733
surface_bits_command->destLeft, surface_bits_command->destTop,
734
surface_bits_command->width, surface_bits_command->height);
736
if (xfi->remote_app != true)
738
XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc,
739
surface_bits_command->destLeft, surface_bits_command->destTop,
740
surface_bits_command->width, surface_bits_command->height,
741
surface_bits_command->destLeft, surface_bits_command->destTop);
744
gdi_InvalidateRegion(xfi->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
745
surface_bits_command->width, surface_bits_command->height);
747
XSetClipMask(xfi->display, xfi->gc, None);
1010
XSetFunction(xfc->display, xfc->gc, GXcopy);
1011
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
1013
/* Validate that the data received is large enough */
1014
if ((surface_bits_command->width * surface_bits_command->height * surface_bits_command->bpp / 8) <= (surface_bits_command->bitmapDataLength))
1016
xfc->bmp_codec_none = (BYTE*) realloc(xfc->bmp_codec_none,
1017
surface_bits_command->width * surface_bits_command->height * 4);
1019
freerdp_image_flip(surface_bits_command->bitmapData, xfc->bmp_codec_none,
1020
surface_bits_command->width, surface_bits_command->height, 32);
1022
image = XCreateImage(xfc->display, xfc->visual, 24, ZPixmap, 0,
1023
(char*) xfc->bmp_codec_none, surface_bits_command->width, surface_bits_command->height, 32, 0);
1025
XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
1026
surface_bits_command->destLeft, surface_bits_command->destTop,
1027
surface_bits_command->width, surface_bits_command->height);
1030
xf_gdi_surface_update_frame(xfc,
1031
surface_bits_command->destLeft, surface_bits_command->destTop,
1032
surface_bits_command->width, surface_bits_command->height);
1034
XSetClipMask(xfc->display, xfc->gc, None);
1038
fprintf(stderr, "Invalid bitmap size - data is %d bytes for %dx%d\n update", surface_bits_command->bitmapDataLength, surface_bits_command->width, surface_bits_command->height);
751
printf("Unsupported codecID %d\n", surface_bits_command->codecID);
1043
fprintf(stderr, "Unsupported codecID %d\n", surface_bits_command->codecID);
1046
xf_unlock_x11(xfc, FALSE);
755
1049
void xf_gdi_register_update_callbacks(rdpUpdate* update)