summaryrefslogtreecommitdiffstats
path: root/xorg/server
diff options
context:
space:
mode:
Diffstat (limited to 'xorg/server')
-rw-r--r--xorg/server/module/rdp.h106
-rw-r--r--xorg/server/module/rdpClientCon.c1100
-rw-r--r--xorg/server/module/rdpClientCon.h39
-rw-r--r--xorg/server/module/rdpDraw.c89
-rw-r--r--xorg/server/module/rdpDraw.h6
-rw-r--r--xorg/server/module/rdpGlyphs.c26
-rw-r--r--xorg/server/module/rdpGlyphs.h29
-rw-r--r--xorg/server/module/rdpMisc.c28
-rw-r--r--xorg/server/module/rdpMisc.h260
-rw-r--r--xorg/server/module/rdpPolyFillRect.c33
10 files changed, 1568 insertions, 148 deletions
diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h
index c3533e98..4c6511e0 100644
--- a/xorg/server/module/rdp.h
+++ b/xorg/server/module/rdp.h
@@ -65,6 +65,26 @@ struct _rdpKeyboard
};
typedef struct _rdpKeyboard rdpKeyboard;
+
+struct _rdpPixmapRec
+{
+ int status;
+ int rdpindex;
+ int con_number;
+ int is_dirty;
+ int is_scratch;
+ int is_alpha_dirty_not;
+ /* number of times used in a remote operation
+ if this gets above XRDP_USE_COUNT_THRESHOLD
+ then we force remote the pixmap */
+ int use_count;
+ int kind_width;
+ struct rdp_draw_item *draw_item_head;
+ struct rdp_draw_item *draw_item_tail;
+};
+typedef struct _rdpPixmapRec rdpPixmapRec;
+typedef struct _rdpPixmapRec * rdpPixmapPtr;
+
/* move this to common header */
struct _rdpRec
{
@@ -75,6 +95,8 @@ struct _rdpRec
int sizeInBytes;
int num_modes;
int bitsPerPixel;
+ int Bpp;
+ int Bpp_mask;
char *pfbMemory;
ScreenPtr pScreen;
rdpDevPrivateKey privateKeyRecGC;
@@ -114,6 +136,20 @@ struct _rdpRec
char uds_data[256];
rdpClientCon *clientConHead;
rdpClientCon *clientConTail;
+
+ rdpPixmapRec screenPriv;
+ int sendUpdateScheduled; /* boolean */
+ OsTimerPtr sendUpdateTimer;
+
+ int do_dirty_ons; /* boolean */
+ int disconnect_scheduled; /* boolean */
+ int do_kill_disconnected; /* boolean */
+
+ OsTimerPtr disconnectTimer;
+ int disconnectScheduled; /* boolean */
+ int disconnect_timeout_s;
+ int disconnect_time_ms;
+
};
typedef struct _rdpRec rdpRec;
typedef struct _rdpRec * rdpPtr;
@@ -127,11 +163,73 @@ struct _rdpGCRec
typedef struct _rdpGCRec rdpGCRec;
typedef struct _rdpGCRec * rdpGCPtr;
-struct _rdpPixmapRec
+#define RDI_FILL 1
+#define RDI_IMGLL 2 /* lossless */
+#define RDI_IMGLY 3 /* lossy */
+#define RDI_LINE 4
+#define RDI_SCRBLT 5
+#define RDI_TEXT 6
+
+struct urdp_draw_item_fill
{
- int i1;
+ int opcode;
+ int fg_color;
+ int bg_color;
+ int pad0;
+};
+
+struct urdp_draw_item_img
+{
+ int opcode;
+ int pad0;
+};
+
+struct urdp_draw_item_line
+{
+ int opcode;
+ int fg_color;
+ int bg_color;
+ int width;
+ xSegment* segs;
+ int nseg;
+ int flags;
+};
+
+struct urdp_draw_item_scrblt
+{
+ int srcx;
+ int srcy;
+ int dstx;
+ int dsty;
+ int cx;
+ int cy;
+};
+
+struct urdp_draw_item_text
+{
+ int opcode;
+ int fg_color;
+ struct rdp_text* rtext; /* in rdpglyph.h */
+};
+
+union urdp_draw_item
+{
+ struct urdp_draw_item_fill fill;
+ struct urdp_draw_item_img img;
+ struct urdp_draw_item_line line;
+ struct urdp_draw_item_scrblt scrblt;
+ struct urdp_draw_item_text text;
+};
+
+struct rdp_draw_item
+{
+ int type; /* RDI_FILL, RDI_IMGLL, ... */
+ int flags;
+ struct rdp_draw_item* prev;
+ struct rdp_draw_item* next;
+ RegionPtr reg;
+ union urdp_draw_item u;
};
-typedef struct _rdpPixmapRec rdpPixmapRec;
-typedef struct _rdpPixmapRec * rdpPixmapPtr;
+#define XRDP_USE_COUNT_THRESHOLD 1
#endif
diff --git a/xorg/server/module/rdpClientCon.c b/xorg/server/module/rdpClientCon.c
index 3edd1e0c..b0ca3776 100644
--- a/xorg/server/module/rdpClientCon.c
+++ b/xorg/server/module/rdpClientCon.c
@@ -24,6 +24,8 @@ Client connection to xrdp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
@@ -43,6 +45,53 @@ Client connection to xrdp
#define LTOUI32(_in) ((unsigned int)(_in))
+#define USE_MAX_OS_BYTES 1
+#define MAX_OS_BYTES (16 * 1024 * 1024)
+
+/*
+0 GXclear, 0
+1 GXnor, DPon
+2 GXandInverted, DPna
+3 GXcopyInverted, Pn
+4 GXandReverse, PDna
+5 GXinvert, Dn
+6 GXxor, DPx
+7 GXnand, DPan
+8 GXand, DPa
+9 GXequiv, DPxn
+a GXnoop, D
+b GXorInverted, DPno
+c GXcopy, P
+d GXorReverse, PDno
+e GXor, DPo
+f GXset 1
+*/
+
+static int g_rdp_opcodes[16] =
+{
+ 0x00, /* GXclear 0x0 0 */
+ 0x88, /* GXand 0x1 src AND dst */
+ 0x44, /* GXandReverse 0x2 src AND NOT dst */
+ 0xcc, /* GXcopy 0x3 src */
+ 0x22, /* GXandInverted 0x4 NOT src AND dst */
+ 0xaa, /* GXnoop 0x5 dst */
+ 0x66, /* GXxor 0x6 src XOR dst */
+ 0xee, /* GXor 0x7 src OR dst */
+ 0x11, /* GXnor 0x8 NOT src AND NOT dst */
+ 0x99, /* GXequiv 0x9 NOT src XOR dst */
+ 0x55, /* GXinvert 0xa NOT dst */
+ 0xdd, /* GXorReverse 0xb src OR NOT dst */
+ 0x33, /* GXcopyInverted 0xc NOT src */
+ 0xbb, /* GXorInverted 0xd NOT src OR dst */
+ 0x77, /* GXnand 0xe NOT src OR NOT dst */
+ 0xff /* GXset 0xf 1 */
+};
+
+static int
+rdpClientConSendPending(rdpPtr dev, rdpClientCon *clientCon);
+static int
+rdpClientConSendMsg(rdpPtr dev, rdpClientCon *clientCon);
+
/******************************************************************************/
static int
rdpClientConGotConnection(ScreenPtr pScreen, rdpPtr dev)
@@ -219,13 +268,13 @@ rdpClientConInit(rdpPtr dev)
if (dev->listen_sck == 0)
{
unlink(dev->uds_data);
- dev->listen_sck = g_tcp_local_socket_stream();
- if (g_tcp_local_bind(dev->listen_sck, dev->uds_data) != 0)
+ dev->listen_sck = g_sck_local_socket_stream();
+ if (g_sck_local_bind(dev->listen_sck, dev->uds_data) != 0)
{
LLOGLN(0, ("rdpClientConInit: g_tcp_local_bind failed"));
return 1;
}
- g_tcp_listen(dev->listen_sck);
+ g_sck_listen(dev->listen_sck);
AddEnabledDevice(dev->listen_sck);
}
return 0;
@@ -243,3 +292,1048 @@ rdpClientConDeinit(rdpPtr dev)
}
return 0;
}
+
+/******************************************************************************/
+static CARD32
+rdpClientConDeferredDisconnectCallback(OsTimerPtr timer, CARD32 now,
+ pointer arg)
+{
+ CARD32 lnow_ms;
+ rdpPtr dev;
+
+ LLOGLN(10, ("rdpClientConDeferredDisconnectCallback"));
+ dev = (rdpPtr) arg;
+ if (dev->clientConHead != NULL) /* is there any connection ? */
+ {
+ LLOGLN(0, ("rdpClientConDeferredDisconnectCallback: one connected"));
+ if (dev->disconnectTimer != NULL)
+ {
+ LLOGLN(0, ("rdpClientConDeferredDisconnectCallback: "
+ "canceling disconnectTimer"));
+ TimerCancel(dev->disconnectTimer);
+ TimerFree(dev->disconnectTimer);
+ dev->disconnectTimer = NULL;
+ }
+ dev->disconnectScheduled = FALSE;
+ return 0;
+ }
+ else
+ {
+ LLOGLN(10, ("rdpClientConDeferredDisconnectCallback: not connected"));
+ }
+ lnow_ms = GetTimeInMillis();
+ if (lnow_ms - dev->disconnect_time_ms > dev->disconnect_timeout_s * 1000)
+ {
+ LLOGLN(0, ("rdpClientConDeferredDisconnectCallback: exit X11rdp"));
+ kill(getpid(), SIGTERM);
+ return 0;
+ }
+ dev->disconnectTimer = TimerSet(dev->disconnectTimer, 0, 1000 * 10,
+ rdpClientConDeferredDisconnectCallback,
+ dev);
+ return 0;
+}
+
+
+/*****************************************************************************/
+static int
+rdpClientConDisconnect(rdpPtr dev, rdpClientCon *clientCon)
+{
+ //int index;
+
+ LLOGLN(0, ("rdpClientConDisconnect:"));
+ if (dev->do_kill_disconnected)
+ {
+ if (dev->disconnect_scheduled == FALSE)
+ {
+ LLOGLN(0, ("rdpClientConDisconnect: starting g_dis_timer"));
+ dev->disconnectTimer = TimerSet(dev->disconnectTimer, 0, 1000 * 10,
+ rdpClientConDeferredDisconnectCallback, dev);
+ dev->disconnect_scheduled = TRUE;
+ }
+ dev->disconnect_time_ms = GetTimeInMillis();
+ }
+
+ //rdpClientConDelete(dev, clientCon);
+
+#if 0
+
+ // TODO
+
+ RemoveEnabledDevice(clientCon->sck);
+ clientCon->connected = FALSE;
+ g_sck_close(clientCon->sck);
+ clientCon->sck = 0;
+ clientCon->sckClosed = TRUE;
+ clientCon->osBitmapNumUsed = 0;
+ clientCon->rdpIndex = -1;
+
+ if (clientCon->maxOsBitmaps > 0)
+ {
+ for (index = 0; index < clientCon->maxOsBitmaps; index++)
+ {
+ if (clientCon->osBitmaps[index].used)
+ {
+ if (g_os_bitmaps[index].priv != 0)
+ {
+ g_os_bitmaps[index].priv->status = 0;
+ }
+ }
+ }
+ }
+ g_os_bitmap_alloc_size = 0;
+
+ g_max_os_bitmaps = 0;
+ g_free(g_os_bitmaps);
+ g_os_bitmaps = 0;
+ g_use_rail = 0;
+ g_do_glyph_cache = 0;
+ g_do_composite = 0;
+
+#endif
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConBeginUpdate(rdpPtr dev, rdpClientCon *clientCon)
+{
+ LLOGLN(10, ("rdpClientConBeginUpdate:"));
+
+ if (clientCon->connected)
+ {
+ if (clientCon->begin)
+ {
+ return 0;
+ }
+ init_stream(clientCon->out_s, 0);
+ s_push_layer(clientCon->out_s, iso_hdr, 8);
+ out_uint16_le(clientCon->out_s, 1); /* begin update */
+ out_uint16_le(clientCon->out_s, 4); /* size */
+ clientCon->begin = TRUE;
+ clientCon->count = 1;
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConEndUpdate(rdpPtr dev, rdpClientCon *clientCon)
+{
+ LLOGLN(10, ("rdpClientConEndUpdate"));
+
+ if (clientCon->connected && clientCon->begin)
+ {
+ if (dev->do_dirty_ons)
+ {
+ /* in this mode, end update is only called in check dirty */
+ rdpClientConSendPending(dev, clientCon);
+ }
+ else
+ {
+ rdpClientConScheduleDeferredUpdate(dev);
+ }
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConPreCheck(rdpPtr dev, rdpClientCon *clientCon, int in_size)
+{
+ int rv;
+
+ rv = 0;
+ if (clientCon->begin == FALSE)
+ {
+ rdpClientConBeginUpdate(dev, clientCon);
+ }
+
+ if ((clientCon->out_s->p - clientCon->out_s->data) >
+ (clientCon->out_s->size - (in_size + 20)))
+ {
+ s_mark_end(clientCon->out_s);
+ if (rdpClientConSendMsg(dev, clientCon) != 0)
+ {
+ LLOGLN(0, ("rdpClientConPreCheck: rdpup_send_msg failed"));
+ rv = 1;
+ }
+ clientCon->count = 0;
+ init_stream(clientCon->out_s, 0);
+ s_push_layer(clientCon->out_s, iso_hdr, 8);
+ }
+
+ return rv;
+}
+
+/******************************************************************************/
+int
+rdpClientConFillRect(rdpPtr dev, rdpClientCon *clientCon,
+ short x, short y, int cx, int cy)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConFillRect:"));
+ rdpClientConPreCheck(dev, clientCon, 12);
+ out_uint16_le(clientCon->out_s, 3); /* fill rect */
+ out_uint16_le(clientCon->out_s, 12); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, x);
+ out_uint16_le(clientCon->out_s, y);
+ out_uint16_le(clientCon->out_s, cx);
+ out_uint16_le(clientCon->out_s, cy);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConScreenBlt(rdpPtr dev, rdpClientCon *clientCon,
+ short x, short y, int cx, int cy, short srcx, short srcy)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConScreenBlt: x %d y %d cx %d cy %d "
+ "srcx %d srcy %d",
+ x, y, cx, cy, srcx, srcy));
+ rdpClientConPreCheck(dev, clientCon, 16);
+ out_uint16_le(clientCon->out_s, 4); /* screen blt */
+ out_uint16_le(clientCon->out_s, 16); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, x);
+ out_uint16_le(clientCon->out_s, y);
+ out_uint16_le(clientCon->out_s, cx);
+ out_uint16_le(clientCon->out_s, cy);
+ out_uint16_le(clientCon->out_s, srcx);
+ out_uint16_le(clientCon->out_s, srcy);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetClip(rdpPtr dev, rdpClientCon *clientCon,
+ short x, short y, int cx, int cy)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetClip:"));
+ rdpClientConPreCheck(dev, clientCon, 12);
+ out_uint16_le(clientCon->out_s, 10); /* set clip */
+ out_uint16_le(clientCon->out_s, 12); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, x);
+ out_uint16_le(clientCon->out_s, y);
+ out_uint16_le(clientCon->out_s, cx);
+ out_uint16_le(clientCon->out_s, cy);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConResetClip(rdpPtr dev, rdpClientCon *clientCon)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConResetClip:"));
+ rdpClientConPreCheck(dev, clientCon, 4);
+ out_uint16_le(clientCon->out_s, 11); /* reset clip */
+ out_uint16_le(clientCon->out_s, 4); /* size */
+ clientCon->count++;
+ }
+
+ return 0;
+}
+
+#define COLOR8(r, g, b) \
+ ((((r) >> 5) << 0) | (((g) >> 5) << 3) | (((b) >> 6) << 6))
+#define COLOR15(r, g, b) \
+ ((((r) >> 3) << 10) | (((g) >> 3) << 5) | (((b) >> 3) << 0))
+#define COLOR16(r, g, b) \
+ ((((r) >> 3) << 11) | (((g) >> 2) << 5) | (((b) >> 3) << 0))
+#define COLOR24(r, g, b) \
+ ((((r) >> 0) << 0) | (((g) >> 0) << 8) | (((b) >> 0) << 16))
+#define SPLITCOLOR32(r, g, b, c) \
+ { \
+ r = ((c) >> 16) & 0xff; \
+ g = ((c) >> 8) & 0xff; \
+ b = (c) & 0xff; \
+ }
+
+/******************************************************************************/
+int
+rdpClientConConvertPixel(rdpPtr dev, rdpClientCon *clientCon, int in_pixel)
+{
+ int red;
+ int green;
+ int blue;
+ int rv;
+
+ rv = 0;
+
+ if (dev->depth == 24)
+ {
+ if (clientCon->rdp_bpp == 24)
+ {
+ rv = in_pixel;
+ SPLITCOLOR32(red, green, blue, rv);
+ rv = COLOR24(red, green, blue);
+ }
+ else if (clientCon->rdp_bpp == 16)
+ {
+ rv = in_pixel;
+ SPLITCOLOR32(red, green, blue, rv);
+ rv = COLOR16(red, green, blue);
+ }
+ else if (clientCon->rdp_bpp == 15)
+ {
+ rv = in_pixel;
+ SPLITCOLOR32(red, green, blue, rv);
+ rv = COLOR15(red, green, blue);
+ }
+ else if (clientCon->rdp_bpp == 8)
+ {
+ rv = in_pixel;
+ SPLITCOLOR32(red, green, blue, rv);
+ rv = COLOR8(red, green, blue);
+ }
+ }
+ else if (dev->depth == clientCon->rdp_bpp)
+ {
+ return in_pixel;
+ }
+
+ return rv;
+}
+
+/******************************************************************************/
+int
+rdpClientConConvertPixels(rdpPtr dev, rdpClientCon *clientCon,
+ void *src, void *dst, int num_pixels)
+{
+ unsigned int pixel;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ unsigned int *src32;
+ unsigned int *dst32;
+ unsigned short *dst16;
+ unsigned char *dst8;
+ int index;
+
+ if (dev->depth == clientCon->rdp_bpp)
+ {
+ memcpy(dst, src, num_pixels * dev->Bpp);
+ return 0;
+ }
+
+ if (dev->depth == 24)
+ {
+ src32 = (unsigned int *)src;
+
+ if (clientCon->rdp_bpp == 24)
+ {
+ dst32 = (unsigned int *)dst;
+
+ for (index = 0; index < num_pixels; index++)
+ {
+ pixel = *src32;
+ *dst32 = pixel;
+ dst32++;
+ src32++;
+ }
+ }
+ else if (clientCon->rdp_bpp == 16)
+ {
+ dst16 = (unsigned short *)dst;
+
+ for (index = 0; index < num_pixels; index++)
+ {
+ pixel = *src32;
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR16(red, green, blue);
+ *dst16 = pixel;
+ dst16++;
+ src32++;
+ }
+ }
+ else if (clientCon->rdp_bpp == 15)
+ {
+ dst16 = (unsigned short *)dst;
+
+ for (index = 0; index < num_pixels; index++)
+ {
+ pixel = *src32;
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR15(red, green, blue);
+ *dst16 = pixel;
+ dst16++;
+ src32++;
+ }
+ }
+ else if (clientCon->rdp_bpp == 8)
+ {
+ dst8 = (unsigned char *)dst;
+
+ for (index = 0; index < num_pixels; index++)
+ {
+ pixel = *src32;
+ SPLITCOLOR32(red, green, blue, pixel);
+ pixel = COLOR8(red, green, blue);
+ *dst8 = pixel;
+ dst8++;
+ src32++;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConAlphaPixels(void* src, void* dst, int num_pixels)
+{
+ unsigned int* src32;
+ unsigned char* dst8;
+ int index;
+
+ src32 = (unsigned int*)src;
+ dst8 = (unsigned char*)dst;
+ for (index = 0; index < num_pixels; index++)
+ {
+ *dst8 = (*src32) >> 24;
+ dst8++;
+ src32++;
+ }
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetFgcolor(rdpPtr dev, rdpClientCon *clientCon, int fgcolor)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetFgcolor:"));
+ rdpClientConPreCheck(dev, clientCon, 8);
+ out_uint16_le(clientCon->out_s, 12); /* set fgcolor */
+ out_uint16_le(clientCon->out_s, 8); /* size */
+ clientCon->count++;
+ fgcolor = fgcolor & dev->Bpp_mask;
+ fgcolor = rdpClientConConvertPixel(dev, clientCon, fgcolor) &
+ clientCon->rdp_Bpp_mask;
+ out_uint32_le(clientCon->out_s, fgcolor);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetBgcolor(rdpPtr dev, rdpClientCon *clientCon, int bgcolor)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetBgcolor:"));
+ rdpClientConPreCheck(dev, clientCon, 8);
+ out_uint16_le(clientCon->out_s, 13); /* set bg color */
+ out_uint16_le(clientCon->out_s, 8); /* size */
+ clientCon->count++;
+ bgcolor = bgcolor & dev->Bpp_mask;
+ bgcolor = rdpClientConConvertPixel(dev, clientCon, bgcolor) &
+ clientCon->rdp_Bpp_mask;
+ out_uint32_le(clientCon->out_s, bgcolor);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetOpcode(rdpPtr dev, rdpClientCon *clientCon, int opcode)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetOpcode:"));
+ rdpClientConPreCheck(dev, clientCon, 6);
+ out_uint16_le(clientCon->out_s, 14); /* set opcode */
+ out_uint16_le(clientCon->out_s, 6); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, g_rdp_opcodes[opcode & 0xf]);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetPen(rdpPtr dev, rdpClientCon *clientCon, int style, int width)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetPen:"));
+ rdpClientConPreCheck(dev, clientCon, 8);
+ out_uint16_le(clientCon->out_s, 17); /* set pen */
+ out_uint16_le(clientCon->out_s, 8); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, style);
+ out_uint16_le(clientCon->out_s, width);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConDrawLine(rdpPtr dev, rdpClientCon *clientCon,
+ short x1, short y1, short x2, short y2)
+{
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConDrawLine:"));
+ rdpClientConPreCheck(dev, clientCon, 12);
+ out_uint16_le(clientCon->out_s, 18); /* draw line */
+ out_uint16_le(clientCon->out_s, 12); /* size */
+ clientCon->count++;
+ out_uint16_le(clientCon->out_s, x1);
+ out_uint16_le(clientCon->out_s, y1);
+ out_uint16_le(clientCon->out_s, x2);
+ out_uint16_le(clientCon->out_s, y2);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetCursor(rdpPtr dev, rdpClientCon *clientCon,
+ short x, short y, char *cur_data, char *cur_mask)
+{
+ int size;
+
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetCursor:"));
+ size = 8 + 32 * (32 * 3) + 32 * (32 / 8);
+ rdpClientConPreCheck(dev, clientCon, size);
+ out_uint16_le(clientCon->out_s, 19); /* set cursor */
+ out_uint16_le(clientCon->out_s, size); /* size */
+ clientCon->count++;
+ x = RDPMAX(0, x);
+ x = RDPMIN(31, x);
+ y = RDPMAX(0, y);
+ y = RDPMIN(31, y);
+ out_uint16_le(clientCon->out_s, x);
+ out_uint16_le(clientCon->out_s, y);
+ out_uint8a(clientCon->out_s, cur_data, 32 * (32 * 3));
+ out_uint8a(clientCon->out_s, cur_mask, 32 * (32 / 8));
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSetCursorEx(rdpPtr dev, rdpClientCon *clientCon,
+ short x, short y, char *cur_data,
+ char *cur_mask, int bpp)
+{
+ int size;
+ int Bpp;
+
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConSetCursorEx:"));
+ Bpp = (bpp == 0) ? 3 : (bpp + 7) / 8;
+ size = 10 + 32 * (32 * Bpp) + 32 * (32 / 8);
+ rdpClientConPreCheck(dev, clientCon, size);
+ out_uint16_le(clientCon->out_s, 51); /* set cursor ex */
+ out_uint16_le(clientCon->out_s, size); /* size */
+ clientCon->count++;
+ x = RDPMAX(0, x);
+ x = RDPMIN(31, x);
+ y = RDPMAX(0, y);
+ y = RDPMIN(31, y);
+ out_uint16_le(clientCon->out_s, x);
+ out_uint16_le(clientCon->out_s, y);
+ out_uint16_le(clientCon->out_s, bpp);
+ out_uint8a(clientCon->out_s, cur_data, 32 * (32 * Bpp));
+ out_uint8a(clientCon->out_s, cur_mask, 32 * (32 / 8));
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConCreateOsSurface(rdpPtr dev, rdpClientCon *clientCon,
+ int rdpindex, int width, int height)
+{
+ LLOGLN(10, ("rdpClientConCreateOsSurface:"));
+
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConCreateOsSurface: width %d height %d", width, height));
+ rdpClientConPreCheck(dev, clientCon, 12);
+ out_uint16_le(clientCon->out_s, 20);
+ out_uint16_le(clientCon->out_s, 12);
+ clientCon->count++;
+ out_uint32_le(clientCon->out_s, rdpindex);
+ out_uint16_le(clientCon->out_s, width);
+ out_uint16_le(clientCon->out_s, height);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConCreateOsSurfaceBpp(rdpPtr dev, rdpClientCon *clientCon,
+ int rdpindex, int width, int height, int bpp)
+{
+ LLOGLN(10, ("rdpClientConCreateOsSurfaceBpp:"));
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConCreateOsSurfaceBpp: width %d height %d "
+ "bpp %d", width, height, bpp));
+ rdpClientConPreCheck(dev, clientCon, 13);
+ out_uint16_le(clientCon->out_s, 31);
+ out_uint16_le(clientCon->out_s, 13);
+ clientCon->count++;
+ out_uint32_le(clientCon->out_s, rdpindex);
+ out_uint16_le(clientCon->out_s, width);
+ out_uint16_le(clientCon->out_s, height);
+ out_uint8(clientCon->out_s, bpp);
+ }
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConSwitchOsSurface(rdpPtr dev, rdpClientCon *clientCon, int rdpindex)
+{
+ LLOGLN(10, ("rdpClientConSwitchOsSurface:"));
+
+ if (clientCon->connected)
+ {
+ if (clientCon->rdpIndex == rdpindex)
+ {
+ return 0;
+ }
+
+ clientCon->rdpIndex = rdpindex;
+ LLOGLN(10, ("rdpClientConSwitchOsSurface: rdpindex %d", rdpindex));
+ /* switch surface */
+ rdpClientConPreCheck(dev, clientCon, 8);
+ out_uint16_le(clientCon->out_s, 21);
+ out_uint16_le(clientCon->out_s, 8);
+ out_uint32_le(clientCon->out_s, rdpindex);
+ clientCon->count++;
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpClientConDeleteOsSurface(rdpPtr dev, rdpClientCon *clientCon, int rdpindex)
+{
+ LLOGLN(10, ("rdpClientConDeleteOsSurface: rdpindex %d", rdpindex));
+
+ if (clientCon->connected)
+ {
+ LLOGLN(10, ("rdpClientConDeleteOsSurface: rdpindex %d", rdpindex));
+ rdpClientConPreCheck(dev, clientCon, 8);
+ out_uint16_le(clientCon->out_s, 22);
+ out_uint16_le(clientCon->out_s, 8);
+ clientCon->count++;
+ out_uint32_le(clientCon->out_s, rdpindex);
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns -1 on error */
+int
+rdpClientConAddOsBitmap(rdpPtr dev, rdpClientCon *clientCon,
+ PixmapPtr pixmap, rdpPixmapPtr priv)
+{
+ int index;
+ int rv;
+ int oldest;
+ int oldest_index;
+ int this_bytes;
+
+ LLOGLN(10, ("rdpClientConAddOsBitmap:"));
+ if (clientCon->connected == FALSE)
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: test error 1"));
+ return -1;
+ }
+
+ if (clientCon->osBitmaps == NULL)
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: test error 2"));
+ return -1;
+ }
+
+ this_bytes = pixmap->devKind * pixmap->drawable.height;
+ if (this_bytes > MAX_OS_BYTES)
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: error, too big this_bytes %d "
+ "width %d height %d", this_bytes,
+ pixmap->drawable.height, pixmap->drawable.height));
+ return -1;
+ }
+
+ oldest = 0x7fffffff;
+ oldest_index = -1;
+ rv = -1;
+ index = 0;
+
+ while (index < clientCon->maxOsBitmaps)
+ {
+ if (clientCon->osBitmaps[index].used == FALSE)
+ {
+ clientCon->osBitmaps[index].used = TRUE;
+ clientCon->osBitmaps[index].pixmap = pixmap;
+ clientCon->osBitmaps[index].priv = priv;
+ clientCon->osBitmaps[index].stamp = clientCon->osBitmapStamp;
+ clientCon->osBitmapStamp++;
+ clientCon->osBitmapNumUsed++;
+ rv = index;
+ break;
+ }
+ else
+ {
+ if (clientCon->osBitmaps[index].stamp < oldest)
+ {
+ oldest = clientCon->osBitmaps[index].stamp;
+ oldest_index = index;
+ }
+ }
+ index++;
+ }
+
+ if (rv == -1)
+ {
+ if (oldest_index == -1)
+ {
+ LLOGLN(0, ("rdpClientConAddOsBitmap: error"));
+ }
+ else
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: too many pixmaps removing "
+ "oldest_index %d", oldest_index));
+ rdpClientConRemoveOsBitmap(dev, clientCon, oldest_index);
+ rdpClientConDeleteOsSurface(dev, clientCon, oldest_index);
+ clientCon->osBitmaps[oldest_index].used = TRUE;
+ clientCon->osBitmaps[oldest_index].pixmap = pixmap;
+ clientCon->osBitmaps[oldest_index].priv = priv;
+ clientCon->osBitmaps[oldest_index].stamp = clientCon->osBitmapStamp;
+ clientCon->osBitmapStamp++;
+ clientCon->osBitmapNumUsed++;
+ rv = oldest_index;
+ }
+ }
+
+ if (rv < 0)
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: test error 3"));
+ return rv;
+ }
+
+ clientCon->osBitmapAllocSize += this_bytes;
+ LLOGLN(10, ("rdpClientConAddOsBitmap: this_bytes %d "
+ "clientCon->osBitmapAllocSize %d",
+ this_bytes, clientCon->osBitmapAllocSize));
+#if USE_MAX_OS_BYTES
+ while (clientCon->osBitmapAllocSize > MAX_OS_BYTES)
+ {
+ LLOGLN(10, ("rdpClientConAddOsBitmap: must delete "
+ "clientCon->osBitmapNumUsed %d",
+ clientCon->osBitmapNumUsed));
+ /* find oldest */
+ oldest = 0x7fffffff;
+ oldest_index = -1;
+ index = 0;
+ while (index < clientCon->maxOsBitmaps)
+ {
+ if (clientCon->osBitmaps[index].used &&
+ (clientCon->osBitmaps[index].stamp < oldest))
+ {
+ oldest = clientCon->osBitmaps[index].stamp;
+ oldest_index = index;
+ }
+ index++;
+ }
+ if (oldest_index == -1)
+ {
+ LLOGLN(0, ("rdpClientConAddOsBitmap: error 1"));
+ break;
+ }
+ if (oldest_index == rv)
+ {
+ LLOGLN(0, ("rdpClientConAddOsBitmap: error 2"));
+ break;
+ }
+ rdpClientConRemoveOsBitmap(dev, clientCon, oldest_index);
+ rdpClientConDeleteOsSurface(dev, clientCon, oldest_index);
+ }
+#endif
+ LLOGLN(10, ("rdpClientConAddOsBitmap: new bitmap index %d", rv));
+ LLOGLN(10, ("rdpClientConAddOsBitmap: clientCon->osBitmapNumUsed %d "
+ "clientCon->osBitmapStamp 0x%8.8x",
+ clientCon->osBitmapNumUsed, clientCon->osBitmapStamp));
+ return rv;
+}
+
+/*****************************************************************************/
+int
+rdpClientConRemoveOsBitmap(rdpPtr dev, rdpClientCon *clientCon, int rdpindex)
+{
+ PixmapPtr pixmap;
+ rdpPixmapPtr priv;
+ int this_bytes;
+
+ if (clientCon->osBitmaps == NULL)
+ {
+ LLOGLN(10, ("rdpClientConRemoveOsBitmap: test error 1"));
+ return 1;
+ }
+
+ LLOGLN(10, ("rdpClientConRemoveOsBitmap: index %d stamp %d",
+ rdpindex, clientCon->osBitmaps[rdpindex].stamp));
+
+ if ((rdpindex < 0) && (rdpindex >= clientCon->maxOsBitmaps))
+ {
+ LLOGLN(10, ("rdpClientConRemoveOsBitmap: test error 2"));
+ return 1;
+ }
+
+ if (clientCon->osBitmaps[rdpindex].used)
+ {
+ pixmap = clientCon->osBitmaps[rdpindex].pixmap;
+ priv = clientCon->osBitmaps[rdpindex].priv;
+ rdpDrawItemRemoveAll(dev, priv);
+ this_bytes = pixmap->devKind * pixmap->drawable.height;
+ clientCon->osBitmapAllocSize -= this_bytes;
+ LLOGLN(10, ("rdpClientConRemoveOsBitmap: this_bytes %d "
+ "clientCon->osBitmapAllocSize %d", this_bytes,
+ clientCon->osBitmapAllocSize));
+ clientCon->osBitmaps[rdpindex].used = 0;
+ clientCon->osBitmaps[rdpindex].pixmap = 0;
+ clientCon->osBitmaps[rdpindex].priv = 0;
+ clientCon->osBitmapNumUsed--;
+ priv->status = 0;
+ priv->con_number = 0;
+ priv->use_count = 0;
+ }
+ else
+ {
+ LLOGLN(0, ("rdpup_remove_os_bitmap: error"));
+ }
+
+ LLOGLN(10, ("rdpup_remove_os_bitmap: clientCon->osBitmapNumUsed %d",
+ clientCon->osBitmapNumUsed));
+ return 0;
+}
+
+/*****************************************************************************/
+int
+rdpClientConUpdateOsUse(rdpPtr dev, rdpClientCon *clientCon, int rdpindex)
+{
+ if (clientCon->osBitmaps == NULL)
+ {
+ return 1;
+ }
+
+ LLOGLN(10, ("rdpClientConUpdateOsUse: index %d stamp %d",
+ rdpindex, clientCon->osBitmaps[rdpindex].stamp));
+
+ if ((rdpindex < 0) && (rdpindex >= clientCon->maxOsBitmaps))
+ {
+ return 1;
+ }
+
+ if (clientCon->osBitmaps[rdpindex].used)
+ {
+ clientCon->osBitmaps[rdpindex].stamp = clientCon->osBitmapStamp;
+ clientCon->osBitmapStamp++;
+ }
+ else
+ {
+ LLOGLN(0, ("rdpClientConUpdateOsUse: error rdpindex %d", rdpindex));
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns error */
+static int
+rdpClientConSend(rdpPtr dev, rdpClientCon *clientCon, char *data, int len)
+{
+ int sent;
+
+ LLOGLN(10, ("rdpClientConSend - sending %d bytes", len));
+
+ if (clientCon->sckClosed)
+ {
+ return 1;
+ }
+
+ while (len > 0)
+ {
+ sent = g_sck_send(clientCon->sck, data, len, 0);
+
+ if (sent == -1)
+ {
+ if (g_sck_last_error_would_block(clientCon->sck))
+ {
+ g_sleep(1);
+ }
+ else
+ {
+ LLOGLN(0, ("rdpClientConSend: g_tcp_send failed(returned -1)"));
+ rdpClientConDisconnect(dev, clientCon);
+ return 1;
+ }
+ }
+ else if (sent == 0)
+ {
+ LLOGLN(0, ("rdpClientConSend: g_tcp_send failed(returned zero)"));
+ rdpClientConDisconnect(dev, clientCon);
+ return 1;
+ }
+ else
+ {
+ data += sent;
+ len -= sent;
+ }
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+static int
+rdpClientConSendMsg(rdpPtr dev, rdpClientCon *clientCon)
+{
+ int len;
+ int rv;
+ struct stream *s;
+
+ rv = 1;
+ s = clientCon->out_s;
+ if (s != NULL)
+ {
+ len = (int) (s->end - s->data);
+
+ if (len > s->size)
+ {
+ LLOGLN(0, ("rdpClientConSendMsg: overrun error len %d count %d",
+ len, clientCon->count));
+ }
+
+ s_pop_layer(s, iso_hdr);
+ out_uint16_le(s, 3);
+ out_uint16_le(s, clientCon->count);
+ out_uint32_le(s, len - 8);
+ rv = rdpClientConSend(dev, clientCon, s->data, len);
+ }
+
+ if (rv != 0)
+ {
+ LLOGLN(0, ("rdpClientConSendMsg: error in rdpup_send_msg"));
+ }
+
+ return rv;
+}
+
+/******************************************************************************/
+static int
+rdpClientConSendPending(rdpPtr dev, rdpClientCon *clientCon)
+{
+ int rv;
+
+ rv = 0;
+ if (clientCon->connected && clientCon->begin)
+ {
+ out_uint16_le(clientCon->out_s, 2); /* XR_SERVER_END_UPDATE */
+ out_uint16_le(clientCon->out_s, 4); /* size */
+ clientCon->count++;
+ s_mark_end(clientCon->out_s);
+ if (rdpClientConSendMsg(dev, clientCon) != 0)
+ {
+ LLOGLN(0, ("rdpClientConSendPending: rdpClientConSendMsg failed"));
+ rv = 1;
+ }
+ }
+ clientCon->count = 0;
+ clientCon->begin = FALSE;
+ return rv;
+}
+
+/******************************************************************************/
+static CARD32
+rdpClientConDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ rdpPtr dev;
+ rdpClientCon *clientCon;
+
+ LLOGLN(10, ("rdpClientConDeferredUpdateCallback"));
+
+ dev = (rdpPtr) arg;
+ clientCon = dev->clientConHead;
+ while (clientCon != NULL)
+ {
+ if (dev->do_dirty_ons)
+ {
+ if (clientCon->rectId == clientCon->rectIdAck)
+ {
+ rdpClientConCheckDirtyScreen(dev, clientCon);
+ }
+ else
+ {
+ LLOGLN(0, ("rdpClientConDeferredUpdateCallback: skipping"));
+ }
+ }
+ else
+ {
+ rdpClientConSendPending(dev, clientCon);
+ }
+ clientCon = clientCon->next;
+ }
+ dev->sendUpdateScheduled = FALSE;
+ return 0;
+}
+
+/******************************************************************************/
+void
+rdpClientConScheduleDeferredUpdate(rdpPtr dev)
+{
+ if (dev->sendUpdateScheduled == FALSE)
+ {
+ dev->sendUpdateScheduled = TRUE;
+ dev->sendUpdateTimer = TimerSet(dev->sendUpdateTimer, 0, 40,
+ rdpClientConDeferredUpdateCallback,
+ dev);
+ }
+}
+
+/******************************************************************************/
+int
+rdpClientConCheckDirtyScreen(rdpPtr dev, rdpClientCon *clientCon)
+{
+ return 0;
+}
diff --git a/xorg/server/module/rdpClientCon.h b/xorg/server/module/rdpClientCon.h
index 85a3925a..f288fd7c 100644
--- a/xorg/server/module/rdpClientCon.h
+++ b/xorg/server/module/rdpClientCon.h
@@ -24,6 +24,15 @@ Client connection to xrdp
#ifndef _RDPCLIENTCON_H
#define _RDPCLIENTCON_H
+struct rdpup_os_bitmap
+{
+ int used;
+ PixmapPtr pixmap;
+ rdpPixmapPtr priv;
+ int stamp;
+};
+
+/* one of these for each client */
struct _rdpClientCon
{
int sck;
@@ -31,6 +40,24 @@ struct _rdpClientCon
int sckControl;
struct stream *out_s;
struct stream *in_s;
+
+ int rectIdAck;
+ int rectId;
+ int connected; /* boolean */
+ int begin; /* boolean */
+ int count;
+ int sckClosed; /* boolean */
+ struct rdpup_os_bitmap *osBitmaps;
+ int maxOsBitmaps;
+ int osBitmapStamp;
+ int osBitmapAllocSize;
+ int osBitmapNumUsed;
+
+ int rdp_bpp; /* client depth */
+ int rdp_Bpp_mask;
+
+ int rdpIndex; /* current os target */
+
struct _rdpClientCon *next;
};
@@ -41,4 +68,16 @@ rdpClientConInit(rdpPtr dev);
int
rdpClientConDeinit(rdpPtr dev);
+int
+rdpClientConDeleteOsSurface(rdpPtr dev, rdpClientCon *clientCon, int rdpindex);
+
+int
+rdpClientConRemoveOsBitmap(rdpPtr dev, rdpClientCon *clientCon, int rdpindex);
+
+void
+rdpClientConScheduleDeferredUpdate(rdpPtr dev);
+int
+rdpClientConCheckDirtyScreen(rdpPtr dev, rdpClientCon *clientCon);
+
+
#endif
diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c
index 08fe4b85..cbb7ce75 100644
--- a/xorg/server/module/rdpDraw.c
+++ b/xorg/server/module/rdpDraw.c
@@ -39,11 +39,100 @@ misc draw calls
#include "rdp.h"
#include "rdpDraw.h"
+#include "rdpClientCon.h"
+#include "rdpMisc.h"
+#include "rdpGlyphs.h"
+#include "rdpReg.h"
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
+/******************************************************************************/
+int
+rdpDrawItemAdd(rdpPtr dev, rdpPixmapRec *priv, struct rdp_draw_item *di)
+{
+ priv->is_alpha_dirty_not = FALSE;
+
+ if (priv->draw_item_tail == NULL)
+ {
+ priv->draw_item_tail = di;
+ priv->draw_item_head = di;
+ }
+ else
+ {
+ di->prev = priv->draw_item_tail;
+ priv->draw_item_tail->next = di;
+ priv->draw_item_tail = di;
+ }
+
+ if (priv == &(dev->screenPriv))
+ {
+ rdpClientConScheduleDeferredUpdate(dev);
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpDrawItemRemove(rdpPtr dev, rdpPixmapRec *priv, struct rdp_draw_item *di)
+{
+ if (di->prev != NULL)
+ {
+ di->prev->next = di->next;
+ }
+
+ if (di->next != NULL)
+ {
+ di->next->prev = di->prev;
+ }
+
+ if (priv->draw_item_head == di)
+ {
+ priv->draw_item_head = di->next;
+ }
+
+ if (priv->draw_item_tail == di)
+ {
+ priv->draw_item_tail = di->prev;
+ }
+
+ if (di->type == RDI_LINE)
+ {
+ if (di->u.line.segs != NULL)
+ {
+ g_free(di->u.line.segs);
+ }
+ }
+
+ if (di->type == RDI_TEXT)
+ {
+ rdpGlyphDeleteRdpText(di->u.text.rtext);
+ }
+
+ rdpRegionDestroy(di->reg);
+ g_free(di);
+ return 0;
+}
+
+/******************************************************************************/
+int
+rdpDrawItemRemoveAll(rdpPtr dev, rdpPixmapRec *priv)
+{
+ struct rdp_draw_item *di;
+
+ di = priv->draw_item_head;
+
+ while (di != NULL)
+ {
+ rdpDrawItemRemove(dev, priv, di);
+ di = priv->draw_item_head;
+ }
+
+ return 0;
+}
+
/*****************************************************************************/
void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
diff --git a/xorg/server/module/rdpDraw.h b/xorg/server/module/rdpDraw.h
index e2711768..2f4aea2f 100644
--- a/xorg/server/module/rdpDraw.h
+++ b/xorg/server/module/rdpDraw.h
@@ -50,6 +50,12 @@ do { \
extern GCOps g_rdpGCOps; /* in rdpGC.c */
+int
+rdpDrawItemAdd(rdpPtr dev, rdpPixmapRec *priv, struct rdp_draw_item *di);
+int
+rdpDrawItemRemove(rdpPtr dev, rdpPixmapRec *priv, struct rdp_draw_item *di);
+int
+rdpDrawItemRemoveAll(rdpPtr dev, rdpPixmapRec *priv);
void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion);
Bool
diff --git a/xorg/server/module/rdpGlyphs.c b/xorg/server/module/rdpGlyphs.c
index fc2d347b..71e8a660 100644
--- a/xorg/server/module/rdpGlyphs.c
+++ b/xorg/server/module/rdpGlyphs.c
@@ -38,6 +38,8 @@ gylph(font) calls
#include "rdp.h"
#include "rdpGlyphs.h"
#include "rdpDraw.h"
+#include "rdpMisc.h"
+#include "rdpReg.h"
/******************************************************************************/
#define LOG_LEVEL 1
@@ -45,6 +47,30 @@ gylph(font) calls
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/******************************************************************************/
+int
+rdpGlyphDeleteRdpText(struct rdp_text *rtext)
+{
+ int index;
+
+ if (rtext == NULL)
+ {
+ return 0;
+ }
+ for (index = 0; index < rtext->num_chars; index++)
+ {
+ if (rtext->chars[index] != NULL)
+ {
+ g_free(rtext->chars[index]->data);
+ g_free(rtext->chars[index]);
+ }
+ }
+ rdpRegionDestroy(rtext->reg);
+ rdpGlyphDeleteRdpText(rtext->next);
+ g_free(rtext);
+ return 0;
+}
+
+/******************************************************************************/
static void
rdpGlyphsOrg(PictureScreenPtr ps, rdpPtr dev,
CARD8 op, PicturePtr pSrc, PicturePtr pDst,
diff --git a/xorg/server/module/rdpGlyphs.h b/xorg/server/module/rdpGlyphs.h
index d451d9f9..24e978a1 100644
--- a/xorg/server/module/rdpGlyphs.h
+++ b/xorg/server/module/rdpGlyphs.h
@@ -24,6 +24,35 @@ gylph(font) calls
#ifndef _RDPGLYPHS_H
#define _RDPGLYPHS_H
+struct rdp_font_char
+{
+ int offset; /* x */
+ int baseline; /* y */
+ int width; /* cx */
+ int height; /* cy */
+ int incby;
+ int bpp;
+ char *data;
+ int data_bytes;
+};
+
+struct rdp_text
+{
+ RegionPtr reg;
+ int font;
+ int x;
+ int y;
+ int flags;
+ int mixmode;
+ char data[256];
+ int data_bytes;
+ struct rdp_font_char* chars[256];
+ int num_chars;
+ struct rdp_text* next;
+};
+
+int
+rdpGlyphDeleteRdpText(struct rdp_text* rtext);
void
rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat,
diff --git a/xorg/server/module/rdpMisc.c b/xorg/server/module/rdpMisc.c
index 34e71110..326deff3 100644
--- a/xorg/server/module/rdpMisc.c
+++ b/xorg/server/module/rdpMisc.c
@@ -67,14 +67,14 @@ rdpBitsPerPixel(int depth)
/*****************************************************************************/
int
-g_tcp_recv(int sck, void *ptr, int len, int flags)
+g_sck_recv(int sck, void *ptr, int len, int flags)
{
return recv(sck, ptr, len, flags);
}
/*****************************************************************************/
void
-g_tcp_close(int sck)
+g_sck_close(int sck)
{
if (sck == 0)
{
@@ -87,7 +87,7 @@ g_tcp_close(int sck)
/*****************************************************************************/
int
-g_tcp_last_error_would_block(int sck)
+g_sck_last_error_would_block(int sck)
{
return (errno == EWOULDBLOCK) || (errno == EINPROGRESS);
}
@@ -101,7 +101,7 @@ g_sleep(int msecs)
/*****************************************************************************/
int
-g_tcp_send(int sck, void *ptr, int len, int flags)
+g_sck_send(int sck, void *ptr, int len, int flags)
{
return send(sck, ptr, len, flags);
}
@@ -146,7 +146,7 @@ g_sprintf(char *dest, char *format, ...)
/*****************************************************************************/
int
-g_tcp_socket(void)
+g_sck_tcp_socket(void)
{
int rv;
int i;
@@ -160,14 +160,14 @@ g_tcp_socket(void)
/*****************************************************************************/
int
-g_tcp_local_socket_dgram(void)
+g_sck_local_socket_dgram(void)
{
return socket(AF_UNIX, SOCK_DGRAM, 0);
}
/*****************************************************************************/
int
-g_tcp_local_socket_stream(void)
+g_sck_local_socket_stream(void)
{
return socket(AF_UNIX, SOCK_STREAM, 0);
}
@@ -188,7 +188,7 @@ g_memset(void *d_ptr, const unsigned char chr, int size)
/*****************************************************************************/
int
-g_tcp_set_no_delay(int sck)
+g_sck_tcp_set_no_delay(int sck)
{
int i;
@@ -199,7 +199,7 @@ g_tcp_set_no_delay(int sck)
/*****************************************************************************/
int
-g_tcp_set_non_blocking(int sck)
+g_sck_set_non_blocking(int sck)
{
unsigned long i;
@@ -211,7 +211,7 @@ g_tcp_set_non_blocking(int sck)
/*****************************************************************************/
int
-g_tcp_accept(int sck)
+g_sck_accept(int sck)
{
struct sockaddr_in s;
unsigned int i;
@@ -223,7 +223,7 @@ g_tcp_accept(int sck)
/*****************************************************************************/
int
-g_tcp_select(int sck1, int sck2, int sck3)
+g_sck_select(int sck1, int sck2, int sck3)
{
fd_set rfds;
struct timeval time;
@@ -292,7 +292,7 @@ g_tcp_select(int sck1, int sck2, int sck3)
/*****************************************************************************/
int
-g_tcp_bind(int sck, char *port)
+g_sck_tcp_bind(int sck, char *port)
{
struct sockaddr_in s;
@@ -305,7 +305,7 @@ g_tcp_bind(int sck, char *port)
/*****************************************************************************/
int
-g_tcp_local_bind(int sck, char *port)
+g_sck_local_bind(int sck, char *port)
{
struct sockaddr_un s;
@@ -317,7 +317,7 @@ g_tcp_local_bind(int sck, char *port)
/*****************************************************************************/
int
-g_tcp_listen(int sck)
+g_sck_listen(int sck)
{
return listen(sck, 2);
}
diff --git a/xorg/server/module/rdpMisc.h b/xorg/server/module/rdpMisc.h
index bed95891..ff54dc0e 100644
--- a/xorg/server/module/rdpMisc.h
+++ b/xorg/server/module/rdpMisc.h
@@ -29,15 +29,15 @@ the rest
int
rdpBitsPerPixel(int depth);
int
-g_tcp_recv(int sck, void *ptr, int len, int flags);
+g_sck_recv(int sck, void *ptr, int len, int flags);
void
-g_tcp_close(int sck);
+g_sck_close(int sck);
int
-g_tcp_last_error_would_block(int sck);
+g_sck_last_error_would_block(int sck);
void
g_sleep(int msecs);
int
-g_tcp_send(int sck, void *ptr, int len, int flags);
+g_sck_send(int sck, void *ptr, int len, int flags);
void *
g_malloc(int size, int zero);
void
@@ -45,29 +45,29 @@ g_free(void *ptr);
void
g_sprintf(char *dest, char *format, ...);
int
-g_tcp_socket(void);
+g_sck_tcp_socket(void);
int
-g_tcp_local_socket_dgram(void);
+g_sck_local_socket_dgram(void);
int
-g_tcp_local_socket_stream(void);
+g_sck_local_socket_stream(void);
void
g_memcpy(void *d_ptr, const void *s_ptr, int size);
void
g_memset(void *d_ptr, const unsigned char chr, int size);
int
-g_tcp_set_no_delay(int sck);
+g_sck_tcp_set_no_delay(int sck);
int
-g_tcp_set_non_blocking(int sck);
+g_sck_set_non_blocking(int sck);
int
-g_tcp_accept(int sck);
+g_sck_accept(int sck);
int
-g_tcp_select(int sck1, int sck2, int sck3);
+g_sck_select(int sck1, int sck2, int sck3);
int
-g_tcp_bind(int sck, char *port);
+g_sck_tcp_bind(int sck, char *port);
int
-g_tcp_local_bind(int sck, char *port);
+g_sck_local_bind(int sck, char *port);
int
-g_tcp_listen(int sck);
+g_sck_listen(int sck);
int
g_create_dir(const char *dirname);
int
@@ -87,7 +87,6 @@ g_hexdump(unsigned char *p, unsigned int len);
# error Unknown endianness in rdp.h
#endif
/* check if we need to align data */
-/* check if we need to align data */
#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \
defined(__ia64__) || defined(__ppc__) || defined(__arm__)
@@ -97,157 +96,164 @@ g_hexdump(unsigned char *p, unsigned int len);
/* parser state */
struct stream
{
- char* p;
- char* end;
- char* data;
- int size;
- /* offsets of various headers */
- char* iso_hdr;
- char* mcs_hdr;
- char* sec_hdr;
- char* rdp_hdr;
- char* channel_hdr;
- char* next_packet;
+ char *p;
+ char *end;
+ char *data;
+ int size;
+ /* offsets of various headers */
+ char *iso_hdr;
+ char *mcs_hdr;
+ char *sec_hdr;
+ char *rdp_hdr;
+ char *channel_hdr;
+ char *next_packet;
};
/******************************************************************************/
#define s_push_layer(s, h, n) \
-{ \
- (s)->h = (s)->p; \
- (s)->p += (n); \
-}
+do { \
+ (s)->h = (s)->p; \
+ (s)->p += (n); \
+} while (0)
/******************************************************************************/
#define s_pop_layer(s, h) \
-{ \
- (s)->p = (s)->h; \
-}
+do { \
+ (s)->p = (s)->h; \
+} while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
-#define out_uint16_le(s, v) \
-{ \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
-}
+#define out_uint16_le(s, v) \
+do { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+} while (0)
#else
-#define out_uint16_le(s, v) \
-{ \
- *((unsigned short*)((s)->p)) = (unsigned short)(v); \
- (s)->p += 2; \
-}
+#define out_uint16_le(s, v) \
+do { \
+ *((unsigned short*)((s)->p)) = (unsigned short)(v); \
+ (s)->p += 2; \
+} while (0)
#endif
/******************************************************************************/
-#define init_stream(s, v) \
-{ \
- if ((v) > (s)->size) \
- { \
- g_free((s)->data); \
- (s)->data = (char*)g_malloc((v), 0); \
- (s)->size = (v); \
- } \
- (s)->p = (s)->data; \
- (s)->end = (s)->data; \
- (s)->next_packet = 0; \
-}
+#define init_stream(s, v) \
+do { \
+ if ((v) > (s)->size) \
+ { \
+ g_free((s)->data); \
+ (s)->data = (char*)g_malloc((v), 0); \
+ (s)->size = (v); \
+ } \
+ (s)->p = (s)->data; \
+ (s)->end = (s)->data; \
+ (s)->next_packet = 0; \
+} while (0)
/******************************************************************************/
-#define out_uint8p(s, v, n) \
-{ \
- g_memcpy((s)->p, (v), (n)); \
- (s)->p += (n); \
-}
+#define out_uint8p(s, v, n) \
+do { \
+ g_memcpy((s)->p, (v), (n)); \
+ (s)->p += (n); \
+} while (0)
/******************************************************************************/
-#define out_uint8a(s, v, n) \
-{ \
- out_uint8p((s), (v), (n)); \
-}
+#define out_uint8a(s, v, n) \
+do { \
+ out_uint8p((s), (v), (n)); \
+} while (0)
+
+/******************************************************************************/
+#define out_uint8(s, v) \
+do { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+} while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
-#define out_uint32_le(s, v) \
-{ \
- *((s)->p) = (unsigned char)((v) >> 0); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 8); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 16); \
- (s)->p++; \
- *((s)->p) = (unsigned char)((v) >> 24); \
- (s)->p++; \
-}
+#define out_uint32_le(s, v) \
+do { \
+ *((s)->p) = (unsigned char)((v) >> 0); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 8); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 16); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 24); \
+ (s)->p++; \
+} while (0)
#else
-#define out_uint32_le(s, v) \
-{ \
- *((unsigned int*)((s)->p)) = (v); \
- (s)->p += 4; \
-}
+#define out_uint32_le(s, v) \
+do { \
+ *((unsigned int*)((s)->p)) = (v); \
+ (s)->p += 4; \
+} while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
-#define in_uint32_le(s, v) \
-{ \
- (v) = (unsigned int) \
- ( \
- (*((unsigned char*)((s)->p + 0)) << 0) | \
- (*((unsigned char*)((s)->p + 1)) << 8) | \
- (*((unsigned char*)((s)->p + 2)) << 16) | \
- (*((unsigned char*)((s)->p + 3)) << 24) \
- ); \
- (s)->p += 4; \
-}
+#define in_uint32_le(s, v) \
+do { \
+ (v) = (unsigned int) \
+ ( \
+ (*((unsigned char*)((s)->p + 0)) << 0) | \
+ (*((unsigned char*)((s)->p + 1)) << 8) | \
+ (*((unsigned char*)((s)->p + 2)) << 16) | \
+ (*((unsigned char*)((s)->p + 3)) << 24) \
+ ); \
+ (s)->p += 4; \
+} while (0)
#else
-#define in_uint32_le(s, v) \
-{ \
- (v) = *((unsigned int*)((s)->p)); \
- (s)->p += 4; \
-}
+#define in_uint32_le(s, v) \
+do { \
+ (v) = *((unsigned int*)((s)->p)); \
+ (s)->p += 4; \
+} while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
-#define in_uint16_le(s, v) \
-{ \
- (v) = (unsigned short) \
- ( \
- (*((unsigned char*)((s)->p + 0)) << 0) | \
- (*((unsigned char*)((s)->p + 1)) << 8) \
- ); \
- (s)->p += 2; \
-}
+#define in_uint16_le(s, v) \
+do { \
+ (v) = (unsigned short) \
+ ( \
+ (*((unsigned char*)((s)->p + 0)) << 0) | \
+ (*((unsigned char*)((s)->p + 1)) << 8) \
+ ); \
+ (s)->p += 2; \
+} while (0)
#else
-#define in_uint16_le(s, v) \
-{ \
- (v) = *((unsigned short*)((s)->p)); \
- (s)->p += 2; \
-}
+#define in_uint16_le(s, v) \
+do { \
+ (v) = *((unsigned short*)((s)->p)); \
+ (s)->p += 2; \
+} while (0)
#endif
/******************************************************************************/
-#define s_mark_end(s) \
-{ \
- (s)->end = (s)->p; \
-}
+#define s_mark_end(s) \
+do { \
+ (s)->end = (s)->p; \
+} while (0)
/******************************************************************************/
-#define make_stream(s) \
-{ \
- (s) = (struct stream*)g_malloc(sizeof(struct stream), 1); \
-}
+#define make_stream(s) \
+do { \
+ (s) = (struct stream*)g_malloc(sizeof(struct stream), 1); \
+} while (0)
/******************************************************************************/
-#define free_stream(s) do \
-{ \
- if ((s) != 0) \
- { \
- g_free((s)->data); \
- } \
- g_free((s)); \
+#define free_stream(s) \
+do { \
+ if ((s) != 0) \
+ { \
+ g_free((s)->data); \
+ } \
+ g_free((s)); \
} while (0)
#endif
diff --git a/xorg/server/module/rdpPolyFillRect.c b/xorg/server/module/rdpPolyFillRect.c
index 1de9cee1..63898e23 100644
--- a/xorg/server/module/rdpPolyFillRect.c
+++ b/xorg/server/module/rdpPolyFillRect.c
@@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "rdp.h"
#include "rdpDraw.h"
+#include "rdpClientCon.h"
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
@@ -39,6 +40,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/******************************************************************************/
static void
+rdpPolyFillRectPre(rdpClientCon *clientCon,
+ DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit)
+{
+}
+
+/******************************************************************************/
+static void
rdpPolyFillRectOrg(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
xRectangle *prectInit)
{
@@ -50,11 +59,35 @@ rdpPolyFillRectOrg(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
}
/******************************************************************************/
+static void
+rdpPolyFillRectPost(rdpClientCon *clientCon,
+ DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit)
+{
+}
+
+/******************************************************************************/
void
rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
xRectangle *prectInit)
{
+ rdpPtr dev;
+ rdpClientCon *clientCon;
+
LLOGLN(10, ("rdpPolyFillRect:"));
+ dev = rdpGetDevFromScreen(pGC->pScreen);
+ clientCon = dev->clientConHead;
+ while (clientCon != NULL)
+ {
+ rdpPolyFillRectPre(clientCon, pDrawable, pGC, nrectFill, prectInit);
+ clientCon = clientCon->next;
+ }
/* do original call */
rdpPolyFillRectOrg(pDrawable, pGC, nrectFill, prectInit);
+ clientCon = dev->clientConHead;
+ while (clientCon != NULL)
+ {
+ rdpPolyFillRectPost(clientCon, pDrawable, pGC, nrectFill, prectInit);
+ clientCon = clientCon->next;
+ }
}