summaryrefslogtreecommitdiffstats
path: root/xorg/X11R7.6/rdp
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2012-05-17 18:48:28 -0700
committerJay Sorg <jay.sorg@gmail.com>2012-05-17 18:48:28 -0700
commitcc3754a2bdd6801179751d45f1df3b5816e189fc (patch)
tree21403a46563d5d5ea12e099e708c59213510718e /xorg/X11R7.6/rdp
parentda658dc1b4147c3d928ed2e13bef26280d64cd03 (diff)
downloadxrdp-proprietary-cc3754a2bdd6801179751d45f1df3b5816e189fc.tar.gz
xrdp-proprietary-cc3754a2bdd6801179751d45f1df3b5816e189fc.zip
xorg: work on offscreen bitmaps
Diffstat (limited to 'xorg/X11R7.6/rdp')
-rw-r--r--xorg/X11R7.6/rdp/rdp.h8
-rw-r--r--xorg/X11R7.6/rdp/rdpdraw.c173
-rw-r--r--xorg/X11R7.6/rdp/rdpmain.c3
-rw-r--r--xorg/X11R7.6/rdp/rdpup.c105
4 files changed, 217 insertions, 72 deletions
diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h
index 3927e29d..7df24c48 100644
--- a/xorg/X11R7.6/rdp/rdp.h
+++ b/xorg/X11R7.6/rdp/rdp.h
@@ -136,6 +136,7 @@ struct _rdpScreenInfoRec
ClearToBackgroundProcPtr ClearToBackground;
ScreenWakeupHandlerProcPtr WakeupHandler;
CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
/* Backing store procedures */
RestoreAreasProcPtr RestoreAreas;
@@ -292,6 +293,11 @@ void
rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height);
+void
+rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists,
+ GlyphPtr* glyphs);
/* rdpinput.c */
@@ -378,6 +384,8 @@ rdpup_delete_os_surface(int rdpid);
void
rdpup_paint_rect_os(int x, int y, int cx, int cy,
int rdpid, int srcx, int srcy);
+void
+rdpup_set_hints(int hints, int mask);
#if defined(X_BYTE_ORDER)
# if X_BYTE_ORDER == X_LITTLE_ENDIAN
diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c
index e393e88c..6e2846ed 100644
--- a/xorg/X11R7.6/rdp/rdpdraw.c
+++ b/xorg/X11R7.6/rdp/rdpdraw.c
@@ -68,8 +68,15 @@ extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
+extern int g_con_number; /* in rdpup.c */
+extern int g_connected; /* in rdpup.c */
+
ColormapPtr g_rdpInstalledColormap;
+static int g_pixmap_rdpid = 1;
+int g_pixmap_byte_total = 0;
+int g_pixmap_num_used = 0;
+
GCFuncs g_rdpGCFuncs =
{
rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip,
@@ -395,14 +402,29 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
int org_width;
org_width = width;
+ /* width must be a multiple of 4 in rdp */
width = (width + 3) & ~3;
LLOGLN(10, ("rdpCreatePixmap: width %d org_width %d", width, org_width));
pScreen->CreatePixmap = g_rdpScreen.CreatePixmap;
rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
priv = GETPIXPRIV(rv);
- priv->status = 1;
- pScreen->CreatePixmap = rdpCreatePixmap;
+ if ((g_rdpScreen.client_info.offscreen_support_level > 0) &&
+ (rv->drawable.depth == g_rdpScreen.depth) &&
+ (org_width > 1) && (height > 1) && g_connected)
+ {
+ priv->allocBytes = width * height * 4;
+ g_pixmap_byte_total += priv->allocBytes;
+ g_pixmap_num_used++;
+ priv->status = 1;
+ priv->rdpid = g_pixmap_rdpid;
+ g_pixmap_rdpid++;
+ priv->con_number = g_con_number;
+ rdpup_create_os_surface(priv->rdpid, width, height);
+ LLOGLN(0, ("rdpCreatePixmap: g_pixmap_byte_total %d g_pixmap_num_used %d",
+ g_pixmap_byte_total, g_pixmap_num_used));
+ }
pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0);
+ pScreen->CreatePixmap = rdpCreatePixmap;
return rv;
}
@@ -414,9 +436,22 @@ rdpDestroyPixmap(PixmapPtr pPixmap)
ScreenPtr pScreen;
rdpPixmapRec* priv;
- //ErrorF("rdpDestroyPixmap:\n");
+ LLOGLN(10, ("rdpDestroyPixmap:"));
priv = GETPIXPRIV(pPixmap);
- //ErrorF(" refcnt %d\n", pPixmap->refcnt);
+ LLOGLN(10, ("status %d refcnt %d", priv->status, pPixmap->refcnt));
+ if (pPixmap->refcnt < 2)
+ {
+ if (XRDP_IS_OS(priv) && g_connected)
+ {
+ g_pixmap_byte_total -= priv->allocBytes;
+ g_pixmap_num_used--;
+ LLOGLN(0, ("rdpDestroyPixmap: id 0x%x "
+ "rdpid 0x%x g_pixmap_byte_total %d g_pixmap_num_used %d",
+ pPixmap->drawable.id, priv->rdpid,
+ g_pixmap_byte_total, g_pixmap_num_used));
+ rdpup_delete_os_surface(priv->rdpid);
+ }
+ }
pScreen = pPixmap->drawable.pScreen;
pScreen->DestroyPixmap = g_rdpScreen.DestroyPixmap;
rv = pScreen->DestroyPixmap(pPixmap);
@@ -691,51 +726,119 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
DrawablePtr p;
int j;
int num_clips;
+ int got_id;
+ WindowPtr pDstWnd;
+ PixmapPtr pDstPixmap;
+ rdpPixmapRec* pDstPriv;
+ struct image_data id;
- DEBUG_OUT_OPS(("in rdpComposite\n"));
+ LLOGLN(10, ("rdpComposite:"));
ps = GetPictureScreen(g_pScreen);
ps->Composite = g_rdpScreen.Composite;
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
+ ps->Composite = rdpComposite;
+
p = pDst->pDrawable;
- if (p->type == DRAWABLE_WINDOW)
+
+ got_id = 0;
+ if (p->type == DRAWABLE_PIXMAP)
{
- if (pDst->clientClipType == CT_REGION)
+ pDstPixmap = (PixmapPtr)p;
+ pDstPriv = GETPIXPRIV(pDstPixmap);
+ if (XRDP_IS_OS(pDstPriv))
{
- box.x1 = p->x + xDst;
- box.y1 = p->y + yDst;
- box.x2 = box.x1 + width;
- box.y2 = box.y1 + height;
- RegionInit(&reg1, &box, 0);
- RegionInit(&reg2, NullBox, 0);
- RegionCopy(&reg2, pDst->clientClip);
- RegionTranslate(&reg2, p->x + pDst->clipOrigin.x,
- p->y + pDst->clipOrigin.y);
- RegionIntersect(&reg1, &reg1, &reg2);
- num_clips = REGION_NUM_RECTS(&reg1);
- if (num_clips > 0)
+ rdpup_switch_os_surface(pDstPriv->rdpid);
+ rdpup_get_pixmap_image_rect(pDstPixmap, &id);
+ got_id = 1;
+ }
+ }
+ else
+ {
+ if (p->type == DRAWABLE_WINDOW)
+ {
+ pDstWnd = (WindowPtr)p;
+ if (pDstWnd->viewable)
{
- rdpup_begin_update();
- for (j = num_clips - 1; j >= 0; j--)
- {
- box = REGION_RECTS(&reg1)[j];
- rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
- }
- rdpup_end_update();
+ rdpup_get_screen_image_rect(&id);
+ got_id = 1;
}
- RegionUninit(&reg1);
- RegionUninit(&reg2);
}
- else
+ }
+ if (!got_id)
+ {
+ return;
+ }
+
+ if (pDst->clientClipType == CT_REGION)
+ {
+ box.x1 = p->x + xDst;
+ box.y1 = p->y + yDst;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+ RegionInit(&reg1, &box, 0);
+ RegionInit(&reg2, NullBox, 0);
+ RegionCopy(&reg2, pDst->clientClip);
+ RegionTranslate(&reg2, p->x + pDst->clipOrigin.x,
+ p->y + pDst->clipOrigin.y);
+ RegionIntersect(&reg1, &reg1, &reg2);
+ num_clips = REGION_NUM_RECTS(&reg1);
+ if (num_clips > 0)
{
- box.x1 = p->x + xDst;
- box.y1 = p->y + yDst;
- box.x2 = box.x1 + width;
- box.y2 = box.y1 + height;
rdpup_begin_update();
- rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ for (j = num_clips - 1; j >= 0; j--)
+ {
+ box = REGION_RECTS(&reg1)[j];
+ rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ }
rdpup_end_update();
}
+ RegionUninit(&reg1);
+ RegionUninit(&reg2);
}
- ps->Composite = rdpComposite;
+ else
+ {
+ box.x1 = p->x + xDst;
+ box.y1 = p->y + yDst;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+ rdpup_begin_update();
+ rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ rdpup_end_update();
+ }
+ rdpup_switch_os_surface(-1);
+}
+
+/******************************************************************************/
+void
+rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists,
+ GlyphPtr* glyphs)
+{
+ PictureScreenPtr ps;
+ int index;
+
+ LLOGLN(10, ("rdpGlyphs:"));
+ LLOGLN(10, ("rdpGlyphs: nlists %d len %d", nlists, lists->len));
+ if (g_rdpScreen.client_info.jpeg)
+ {
+ rdpup_set_hints(1, 1);
+ }
+ for (index = 0; index < lists->len; index++)
+ {
+ LLOGLN(10, (" index %d size %d refcnt %d width %d height %d",
+ index, glyphs[index]->size, glyphs[index]->refcnt,
+ glyphs[index]->info.width, glyphs[index]->info.height));
+ }
+ ps = GetPictureScreen(g_pScreen);
+ ps->Glyphs = g_rdpScreen.Glyphs;
+ ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc,
+ nlists, lists, glyphs);
+ ps->Glyphs = rdpGlyphs;
+ if (g_rdpScreen.client_info.jpeg)
+ {
+ rdpup_set_hints(0, 1);
+ }
+ LLOGLN(10, ("rdpGlyphs: out"));
}
diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c
index f95a718a..b8b3840f 100644
--- a/xorg/X11R7.6/rdp/rdpmain.c
+++ b/xorg/X11R7.6/rdp/rdpmain.c
@@ -361,6 +361,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
if (ps)
{
g_rdpScreen.Composite = ps->Composite;
+ g_rdpScreen.Glyphs = ps->Glyphs;
+
}
pScreen->blackPixel = g_rdpScreen.blackPixel;
pScreen->whitePixel = g_rdpScreen.whitePixel;
@@ -370,6 +372,7 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
if (ps)
{
ps->Composite = rdpComposite;
+ ps->Glyphs = rdpGlyphs;
}
pScreen->SaveScreen = rdpSaveScreen;
/* GC procedures */
diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c
index 5d0049d3..4a8bf9f8 100644
--- a/xorg/X11R7.6/rdp/rdpup.c
+++ b/xorg/X11R7.6/rdp/rdpup.c
@@ -38,7 +38,8 @@ int g_con_number = 0; /* increments for each connection */
static int g_listen_sck = 0;
static int g_sck = 0;
static int g_sck_closed = 0;
-static int g_connected = 0;
+
+int g_connected = 0;
static int g_dis_listen_sck = 0;
//static int g_dis_sck = 0;
@@ -65,6 +66,9 @@ extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern int g_use_uds; /* in rdpmain.c */
extern char g_uds_data[]; /* in rdpmain.c */
+extern int g_pixmap_byte_total; /* in rdpdraw.c */
+extern int g_pixmap_num_used; /* in rdpdraw.c */
+
/*
0 GXclear, 0
1 GXnor, DPon
@@ -189,6 +193,7 @@ rdpup_send_pending(void)
{
DEBUG_OUT_UP(("end %d\n", g_count));
out_uint16_le(g_out_s, 2);
+ out_uint16_le(g_out_s, 4);
g_count++;
s_mark_end(g_out_s);
rdpup_send_msg(g_out_s);
@@ -202,16 +207,7 @@ rdpup_send_pending(void)
static CARD32
rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
{
- if (g_connected && g_begin)
- {
- DEBUG_OUT_UP(("end %d\n", g_count));
- out_uint16_le(g_out_s, 2);
- g_count++;
- s_mark_end(g_out_s);
- rdpup_send_msg(g_out_s);
- }
- g_count = 0;
- g_begin = 0;
+ rdpup_send_pending();
g_scheduled = 0;
return 0;
}
@@ -254,6 +250,8 @@ rdpup_recv(char* data, int len)
g_tcp_close(g_sck);
g_sck = 0;
g_sck_closed = 1;
+ g_pixmap_byte_total = 0;
+ g_pixmap_num_used = 0;
return 1;
}
}
@@ -264,6 +262,8 @@ rdpup_recv(char* data, int len)
g_tcp_close(g_sck);
g_sck = 0;
g_sck_closed = 1;
+ g_pixmap_byte_total = 0;
+ g_pixmap_num_used = 0;
return 1;
}
else
@@ -568,7 +568,7 @@ rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data* id)
id->height = pPixmap->drawable.height;
id->bpp = g_rdpScreen.rdp_bpp;
id->Bpp = g_rdpScreen.rdp_Bpp;
- id->lineBytes = id->width * id->Bpp;
+ id->lineBytes = pPixmap->devKind;
id->pixels = (char*)(pPixmap->devPrivate.ptr);
}
@@ -1087,11 +1087,13 @@ rdpup_set_cursor(short x, short y, char* cur_data, char* cur_mask)
int
rdpup_create_os_surface(int rdpid, int width, int height)
{
+ LLOGLN(10, ("rdpup_create_os_surface:"));
if (g_connected)
{
DEBUG_OUT_UP((" rdpup_create_os_surface\n"));
- rdpup_pre_check(10);
+ rdpup_pre_check(12);
out_uint16_le(g_out_s, 20);
+ out_uint16_le(g_out_s, 12);
g_count++;
out_uint32_le(g_out_s, rdpid);
out_uint16_le(g_out_s, width);
@@ -1112,15 +1114,19 @@ rdpup_switch_os_surface(int rdpid)
return 0;
}
g_rdpid = rdpid;
- rdpup_send_pending();
- LLOGLN(0, ("rdpup_switch_os_surface: rdpid %d", rdpid));
+ rdpup_send_pending(); // TODO: do we need this ?
+ // the protocol allows switch the surface anytime
+
+ LLOGLN(10, ("rdpup_switch_os_surface: rdpid %d", rdpid));
/* switch surface */
out_uint16_le(g_out_s, 21);
+ out_uint16_le(g_out_s, 8);
out_uint32_le(g_out_s, rdpid);
/* begin update */
out_uint16_le(g_out_s, 1);
+ out_uint16_le(g_out_s, 4);
g_begin = 1;
g_count = 2;
@@ -1132,15 +1138,17 @@ rdpup_switch_os_surface(int rdpid)
int
rdpup_delete_os_surface(int rdpid)
{
+ LLOGLN(10, ("rdpup_delete_os_surface: rdpid %d", rdpid));
if (g_connected)
{
- DEBUG_OUT_UP((" rdpup_delete_os_surface\n"));
+ LLOGLN(10, ("rdpup_delete_os_surface: rdpid %d", rdpid));
//if (g_current_surface == rdpid)
//{
// g_current_surface = -1;
//}
- rdpup_pre_check(6);
+ rdpup_pre_check(8);
out_uint16_le(g_out_s, 22);
+ out_uint16_le(g_out_s, 8);
g_count++;
out_uint32_le(g_out_s, rdpid);
}
@@ -1149,7 +1157,7 @@ rdpup_delete_os_surface(int rdpid)
/******************************************************************************/
static int
-get_single_color(int x, int y, int w, int h)
+get_single_color(struct image_data* id, int x, int y, int w, int h)
{
int rv;
int i;
@@ -1165,8 +1173,8 @@ get_single_color(int x, int y, int w, int h)
{
for (i = 0; i < h; i++)
{
- i8 = (unsigned char*)(g_rdpScreen.pfbMemory +
- ((y + i) * g_rdpScreen.paddedWidthInBytes) + (x * g_Bpp));
+ i8 = (unsigned char*)(id->pixels +
+ ((y + i) * id->lineBytes) + (x * g_Bpp));
if (i == 0)
{
p = *i8;
@@ -1185,8 +1193,8 @@ get_single_color(int x, int y, int w, int h)
{
for (i = 0; i < h; i++)
{
- i16 = (unsigned short*)(g_rdpScreen.pfbMemory +
- ((y + i) * g_rdpScreen.paddedWidthInBytes) + (x * g_Bpp));
+ i16 = (unsigned short*)(id->pixels +
+ ((y + i) * id->lineBytes) + (x * g_Bpp));
if (i == 0)
{
p = *i16;
@@ -1205,8 +1213,8 @@ get_single_color(int x, int y, int w, int h)
{
for (i = 0; i < h; i++)
{
- i32 = (unsigned int*)(g_rdpScreen.pfbMemory +
- ((y + i) * g_rdpScreen.paddedWidthInBytes) + (x * g_Bpp));
+ i32 = (unsigned int*)(id->pixels +
+ ((y + i) * id->lineBytes) + (x * g_Bpp));
if (i == 0)
{
p = *i32;
@@ -1237,12 +1245,20 @@ rdpup_send_area(struct image_data* id, int x, int y, int w, int h)
int lh;
int lw;
int size;
+ struct image_data lid;
+
+ LLOGLN(10, ("rdpup_send_area: id %p x %d y %d w %d h %d", id, x, y, w, h));
+ if (id == 0)
+ {
+ rdpup_get_screen_image_rect(&lid);
+ id = &lid;
+ }
- if (x >= g_rdpScreen.width)
+ if (x >= id->width)
{
return;
}
- if (y >= g_rdpScreen.height)
+ if (y >= id->height)
{
return;
}
@@ -1264,13 +1280,13 @@ rdpup_send_area(struct image_data* id, int x, int y, int w, int h)
{
return;
}
- if (x + w > g_rdpScreen.width)
+ if (x + w > id->width)
{
- w = g_rdpScreen.width - x;
+ w = id->width - x;
}
- if (y + h > g_rdpScreen.height)
+ if (y + h > id->height)
{
- h = g_rdpScreen.height - y;
+ h = id->height - y;
}
DEBUG_OUT_UP(("%d\n", w * h));
if (g_connected && g_begin)
@@ -1284,7 +1300,7 @@ rdpup_send_area(struct image_data* id, int x, int y, int w, int h)
{
lw = MIN(64, (x + w) - lx);
lh = MIN(64, (y + h) - ly);
- single_color = get_single_color(lx, ly, lw, lh);
+ single_color = get_single_color(id, lx, ly, lw, lh);
if (single_color != -1)
{
DEBUG_OUT_UP(("%d sending single color\n", g_count));
@@ -1293,7 +1309,7 @@ rdpup_send_area(struct image_data* id, int x, int y, int w, int h)
}
else
{
- size = lw * lh * g_rdpScreen.rdp_Bpp + 24;
+ size = lw * lh * id->Bpp + 24;
rdpup_pre_check(size);
out_uint16_le(g_out_s, 5);
out_uint16_le(g_out_s, size);
@@ -1302,13 +1318,13 @@ rdpup_send_area(struct image_data* id, int x, int y, int w, int h)
out_uint16_le(g_out_s, ly);
out_uint16_le(g_out_s, lw);
out_uint16_le(g_out_s, lh);
- out_uint32_le(g_out_s, lw * lh * g_rdpScreen.rdp_Bpp);
+ out_uint32_le(g_out_s, lw * lh * id->Bpp);
for (i = 0; i < lh; i++)
{
- s = (g_rdpScreen.pfbMemory +
- ((ly + i) * g_rdpScreen.paddedWidthInBytes) + (lx * g_Bpp));
+ s = (id->pixels +
+ ((ly + i) * id->lineBytes) + (lx * g_Bpp));
convert_pixels(s, g_out_s->p, lw);
- g_out_s->p += lw * g_rdpScreen.rdp_Bpp;
+ g_out_s->p += lw * id->Bpp;
}
out_uint16_le(g_out_s, lw);
out_uint16_le(g_out_s, lh);
@@ -1329,8 +1345,9 @@ rdpup_paint_rect_os(int x, int y, int cx, int cy,
{
if (g_connected)
{
- rdpup_pre_check(18);
+ rdpup_pre_check(20);
out_uint16_le(g_out_s, 23);
+ out_uint16_le(g_out_s, 20);
g_count++;
out_uint16_le(g_out_s, x);
out_uint16_le(g_out_s, y);
@@ -1341,3 +1358,17 @@ rdpup_paint_rect_os(int x, int y, int cx, int cy,
out_uint16_le(g_out_s, srcy);
}
}
+
+/******************************************************************************/
+void
+rdpup_set_hints(int hints, int mask)
+{
+ if (g_connected)
+ {
+ rdpup_pre_check(6);
+ out_uint16_le(g_out_s, 24);
+ g_count++;
+ out_uint32_le(g_out_s, hints);
+ out_uint32_le(g_out_s, mask);
+ }
+}