diff options
Diffstat (limited to 'xorg')
-rw-r--r-- | xorg/X11R7.6/rdp/rdp.h | 10 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpCopyArea.c | 14 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpCopyPlane.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpFillPolygon.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpImageGlyphBlt.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpImageText16.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpImageText8.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyArc.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyFillArc.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyFillRect.c | 34 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyPoint.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyRectangle.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolySegment.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyText16.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolyText8.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPolylines.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPushPixels.c | 4 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpPutImage.c | 6 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpSetSpans.c | 18 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpdraw.c | 217 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpinput.c | 79 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpup.c | 447 |
23 files changed, 668 insertions, 217 deletions
diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 72440af9..63c7436a 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -120,6 +120,10 @@ struct image_data int Bpp; int lineBytes; char* pixels; + char* shmem_pixels; + int shmem_id; + int shmem_offset; + int shmem_lineBytes; }; /* Per-screen (framebuffer) structure. There is only one of these, since we @@ -297,6 +301,10 @@ struct _rdpPixmapRec then we force remote the pixmap */ int use_count; int kind_width; + /* 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; struct rdp_draw_item* draw_item_head; struct rdp_draw_item* draw_item_tail; }; @@ -507,6 +515,8 @@ int rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv); int rdpup_remove_os_bitmap(int rdpindex); +int +rdpup_update_os_use(int rdpindex); void rdpup_get_screen_image_rect(struct image_data* id); void diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.c b/xorg/X11R7.6/rdp/rdpCopyArea.c index beac8b24..4718a89c 100644 --- a/xorg/X11R7.6/rdp/rdpCopyArea.c +++ b/xorg/X11R7.6/rdp/rdpCopyArea.c @@ -429,6 +429,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, pSrcPixmap = (PixmapPtr)pSrc; pSrcPriv = GETPIXPRIV(pSrcPixmap); + LLOGLN(10, ("rdpCopyArea: 3 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch)); + if (xrdp_is_os(pSrcPixmap, pSrcPriv)) { if (pDst->type == DRAWABLE_WINDOW) @@ -468,7 +470,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, } else { - LLOGLN(10, ("rdpCopyArea: 2")); + LLOGLN(10, ("rdpCopyArea: 2 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch)); } } @@ -494,10 +496,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpCopyArea: gettig dirty")); + LLOGLN(10, ("rdpCopyArea: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; - dirty_type = RDI_IMGLL; + dirty_type = RDI_IMGLY; } else { @@ -524,10 +526,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpCopyArea: gettig dirty")); + LLOGLN(10, ("rdpCopyArea: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; - dirty_type = RDI_IMGLL; + dirty_type = RDI_IMGLY; } else { @@ -543,6 +545,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, return rv; } + LLOGLN(10, ("rdpCopyArea: post_process")); + RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDst, pGC); diff --git a/xorg/X11R7.6/rdp/rdpCopyPlane.c b/xorg/X11R7.6/rdp/rdpCopyPlane.c index bc581789..063766ee 100644 --- a/xorg/X11R7.6/rdp/rdpCopyPlane.c +++ b/xorg/X11R7.6/rdp/rdpCopyPlane.c @@ -111,7 +111,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, if (g_do_dirty_os) { - LLOGLN(10, ("rdpCopyPlane: gettig dirty")); + LLOGLN(10, ("rdpCopyPlane: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -137,7 +137,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpCopyPlane: gettig dirty")); + LLOGLN(10, ("rdpCopyPlane: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpFillPolygon.c b/xorg/X11R7.6/rdp/rdpFillPolygon.c index fceab93e..960f619e 100644 --- a/xorg/X11R7.6/rdp/rdpFillPolygon.c +++ b/xorg/X11R7.6/rdp/rdpFillPolygon.c @@ -150,7 +150,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpFillPolygon: gettig dirty")); + LLOGLN(10, ("rdpFillPolygon: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -176,7 +176,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpFillPolygon: gettig dirty")); + LLOGLN(10, ("rdpFillPolygon: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c index 2b69432d..d425a30b 100644 --- a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c @@ -108,7 +108,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpImageGlyphBlt: gettig dirty")); + LLOGLN(10, ("rdpImageGlyphBlt: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -134,7 +134,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpImageGlyphBlt: gettig dirty")); + LLOGLN(10, ("rdpImageGlyphBlt: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpImageText16.c b/xorg/X11R7.6/rdp/rdpImageText16.c index 5a77224b..604d85e3 100644 --- a/xorg/X11R7.6/rdp/rdpImageText16.c +++ b/xorg/X11R7.6/rdp/rdpImageText16.c @@ -106,7 +106,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpImageText16: gettig dirty")); + LLOGLN(10, ("rdpImageText16: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -132,7 +132,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpImageText16: gettig dirty")); + LLOGLN(10, ("rdpImageText16: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpImageText8.c b/xorg/X11R7.6/rdp/rdpImageText8.c index c191bd75..08dead18 100644 --- a/xorg/X11R7.6/rdp/rdpImageText8.c +++ b/xorg/X11R7.6/rdp/rdpImageText8.c @@ -106,7 +106,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpImageText8: gettig dirty")); + LLOGLN(10, ("rdpImageText8: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -132,7 +132,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpImageText8: gettig dirty")); + LLOGLN(10, ("rdpImageText8: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyArc.c b/xorg/X11R7.6/rdp/rdpPolyArc.c index 2d1f153e..84a85587 100644 --- a/xorg/X11R7.6/rdp/rdpPolyArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyArc.c @@ -125,7 +125,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyArc: gettig dirty")); + LLOGLN(10, ("rdpPolyArc: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -151,7 +151,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyArc: gettig dirty")); + LLOGLN(10, ("rdpPolyArc: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyFillArc.c b/xorg/X11R7.6/rdp/rdpPolyFillArc.c index bcbb2643..e3822215 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillArc.c @@ -125,7 +125,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyFillArc: gettig dirty")); + LLOGLN(10, ("rdpPolyFillArc: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -151,7 +151,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyFillArc: gettig dirty")); + LLOGLN(10, ("rdpPolyFillArc: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.c b/xorg/X11R7.6/rdp/rdpPolyFillRect.c index f9926fc8..7db4be69 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillRect.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.c @@ -105,10 +105,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPolyFillRect: gettig dirty")); + LLOGLN(10, ("rdpPolyFillRect: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; - dirty_type = RDI_IMGLL; + dirty_type = (FillTiled == pGC->fillStyle) ? + RDI_IMGLY : RDI_IMGLL; } else { @@ -122,10 +123,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyFillRect: gettig dirty")); + LLOGLN(10, ("rdpPolyFillRect: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; - dirty_type = RDI_FILL; + dirty_type = (FillTiled == pGC->fillStyle) ? + RDI_IMGLY : RDI_IMGLL; } else { @@ -148,10 +150,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPolyFillRect: gettig dirty")); + LLOGLN(10, ("rdpPolyFillRect: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; - dirty_type = RDI_IMGLL; + dirty_type = (FillTiled == pGC->fillStyle) ? + RDI_IMGLY : RDI_IMGLL; } else { @@ -192,7 +195,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, } else { - draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT); + draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, + dirty_type, TAG_POLYFILLRECT); } } else if (got_id) @@ -214,7 +218,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--) { box = REGION_RECTS(fill_reg)[j]; - rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_fill_rect(box.x1, box.y1, + box.x2 - box.x1, box.y2 - box.y1); } rdpup_set_opcode(GXcopy); @@ -251,12 +256,15 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ { LLOGLN(10, ("rdpPolyFillRect: 3")); - draw_item_add_fill_region(pDirtyPriv, &clip_reg, pGC->fgPixel, + draw_item_add_fill_region(pDirtyPriv, &clip_reg, + pGC->fgPixel, pGC->alu); } else { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT); + LLOGLN(10, ("rdpPolyFillRect: 4")); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, + dirty_type, TAG_POLYFILLRECT); } } else if (got_id) @@ -280,7 +288,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_fill_rect(box.x1, box.y1, + box.x2 - box.x1, box.y2 - box.y1); } rdpup_set_opcode(GXcopy); @@ -290,7 +299,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(&id, box.x1, box.y1, + box.x2 - box.x1, box.y2 - box.y1); } } diff --git a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c index 97c8562e..8ce1db08 100644 --- a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c @@ -108,7 +108,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyGlyphBlt: gettig dirty")); + LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -134,7 +134,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyGlyphBlt: gettig dirty")); + LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyPoint.c b/xorg/X11R7.6/rdp/rdpPolyPoint.c index 28db831a..e2eadafd 100644 --- a/xorg/X11R7.6/rdp/rdpPolyPoint.c +++ b/xorg/X11R7.6/rdp/rdpPolyPoint.c @@ -156,7 +156,7 @@ rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyPoint: gettig dirty")); + LLOGLN(10, ("rdpPolyPoint: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -182,7 +182,7 @@ rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyPoint: gettig dirty")); + LLOGLN(10, ("rdpPolyPoint: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.c b/xorg/X11R7.6/rdp/rdpPolyRectangle.c index 3f89000a..c1a5c971 100644 --- a/xorg/X11R7.6/rdp/rdpPolyRectangle.c +++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.c @@ -118,7 +118,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyRectangle: gettig dirty")); + LLOGLN(10, ("rdpPolyRectangle: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -144,7 +144,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPolyRectangle: gettig dirty")); + LLOGLN(10, ("rdpPolyRectangle: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolySegment.c b/xorg/X11R7.6/rdp/rdpPolySegment.c index 623ec748..f4bcfe31 100644 --- a/xorg/X11R7.6/rdp/rdpPolySegment.c +++ b/xorg/X11R7.6/rdp/rdpPolySegment.c @@ -115,7 +115,7 @@ rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs) if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolySegment: gettig dirty")); + LLOGLN(10, ("rdpPolySegment: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -141,7 +141,7 @@ rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs) if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPolySegment: gettig dirty")); + LLOGLN(10, ("rdpPolySegment: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyText16.c b/xorg/X11R7.6/rdp/rdpPolyText16.c index cf8b04c4..a28030f0 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText16.c +++ b/xorg/X11R7.6/rdp/rdpPolyText16.c @@ -109,7 +109,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyText16: gettig dirty")); + LLOGLN(10, ("rdpPolyText16: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -135,7 +135,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyText16: gettig dirty")); + LLOGLN(10, ("rdpPolyText16: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolyText8.c b/xorg/X11R7.6/rdp/rdpPolyText8.c index e92f8bc8..3157a538 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText8.c +++ b/xorg/X11R7.6/rdp/rdpPolyText8.c @@ -109,7 +109,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolyText8: gettig dirty")); + LLOGLN(10, ("rdpPolyText8: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -135,7 +135,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPolyText8: gettig dirty")); + LLOGLN(10, ("rdpPolyText8: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPolylines.c b/xorg/X11R7.6/rdp/rdpPolylines.c index 759d1ff9..ba6381b8 100644 --- a/xorg/X11R7.6/rdp/rdpPolylines.c +++ b/xorg/X11R7.6/rdp/rdpPolylines.c @@ -166,7 +166,7 @@ rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPolylines: gettig dirty")); + LLOGLN(10, ("rdpPolylines: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLL; @@ -192,7 +192,7 @@ rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPolylines: gettig dirty")); + LLOGLN(10, ("rdpPolylines: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPushPixels.c b/xorg/X11R7.6/rdp/rdpPushPixels.c index a07ec5eb..e7d330d1 100644 --- a/xorg/X11R7.6/rdp/rdpPushPixels.c +++ b/xorg/X11R7.6/rdp/rdpPushPixels.c @@ -102,7 +102,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPushPixels: gettig dirty")); + LLOGLN(10, ("rdpPushPixels: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -128,7 +128,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, if (g_do_dirty_ons) { - LLOGLN(0, ("rdpPushPixels: gettig dirty")); + LLOGLN(10, ("rdpPushPixels: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; dirty_type = RDI_IMGLL; diff --git a/xorg/X11R7.6/rdp/rdpPutImage.c b/xorg/X11R7.6/rdp/rdpPutImage.c index 33fedb8a..d244d895 100644 --- a/xorg/X11R7.6/rdp/rdpPutImage.c +++ b/xorg/X11R7.6/rdp/rdpPutImage.c @@ -106,7 +106,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, if (g_do_dirty_os) { - LLOGLN(10, ("rdpPutImage: gettig dirty")); + LLOGLN(10, ("rdpPutImage: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -132,10 +132,10 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, if (g_do_dirty_ons) { - LLOGLN(10, ("rdpPutImage: gettig dirty")); + LLOGLN(10, ("rdpPutImage: getting dirty")); g_screenPriv.is_dirty = 1; pDirtyPriv = &g_screenPriv; - dirty_type = RDI_IMGLL; + dirty_type = RDI_IMGLY; } else { diff --git a/xorg/X11R7.6/rdp/rdpSetSpans.c b/xorg/X11R7.6/rdp/rdpSetSpans.c index 2b650e94..62dd8c5c 100644 --- a/xorg/X11R7.6/rdp/rdpSetSpans.c +++ b/xorg/X11R7.6/rdp/rdpSetSpans.c @@ -38,6 +38,8 @@ extern int g_Bpp; /* from rdpmain.c */ extern ScreenPtr g_pScreen; /* from rdpmain.c */ extern Bool g_wrapPixmap; /* from rdpmain.c */ extern int g_do_dirty_os; /* in rdpmain.c */ +extern int g_do_dirty_ons; /* in rdpmain.c */ +extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */ extern GCOps g_rdpGCOps; /* from rdpdraw.c */ @@ -95,7 +97,7 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc, if (g_do_dirty_os) { - LLOGLN(10, ("rdpSetSpans: gettig dirty")); + LLOGLN(10, ("rdpSetSpans: getting dirty")); pDstPriv->is_dirty = 1; pDirtyPriv = pDstPriv; dirty_type = RDI_IMGLY; @@ -118,8 +120,18 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc, if (pDstWnd->viewable) { post_process = 1; - rdpup_get_screen_image_rect(&id); - got_id = 1; + if (g_do_dirty_ons) + { + LLOGLN(10, ("rdpSetSpans: getting dirty")); + g_screenPriv.is_dirty = 1; + pDirtyPriv = &g_screenPriv; + dirty_type = RDI_IMGLL; + } + else + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } } } } diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 9868cc62..0f31862e 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -489,6 +489,36 @@ draw_item_remove_all(rdpPixmapRec *priv) } /******************************************************************************/ +static int +remove_empties(rdpPixmapRec* priv) +{ + struct rdp_draw_item* di; + struct rdp_draw_item* di_prev; + int rv; + + rv = 0; + /* remove draw items with empty regions */ + di = priv->draw_item_head; + di_prev = 0; + while (di != 0) + { + if (!RegionNotEmpty(di->reg)) + { + LLOGLN(10, ("remove_empties: removing empty item type %d", di->type)); + draw_item_remove(priv, di); + di = di_prev == 0 ? priv->draw_item_head : di_prev->next; + rv++; + } + else + { + di_prev = di; + di = di->next; + } + } + return rv; +} + +/******************************************************************************/ int region_get_pixel_count(RegionPtr reg) { @@ -634,29 +664,31 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) { struct rdp_draw_item *di; struct rdp_draw_item *di_prev; - RegionRec treg; BoxRec box; + RegionRec treg; #if 1 - box.x1 = 0; - box.x2 = pix->drawable.width; - box.y1 = 0; - box.y2 = pix->drawable.height; - RegionInit(&treg, &box, 0); - di = priv->draw_item_head; - di_prev = 0; - while (di != 0) + if (pix != 0) { - RegionIntersect(di->reg, di->reg, &treg); - di_prev = di; - di = di->next; + box.x1 = 0; + box.x2 = pix->drawable.width; + box.y1 = 0; + box.y2 = pix->drawable.height; + RegionInit(&treg, &box, 0); + di = priv->draw_item_head; + di_prev = 0; + while (di != 0) + { + RegionIntersect(di->reg, di->reg, &treg); + di_prev = di; + di = di->next; + } + RegionUninit(&treg); + remove_empties(priv); } - RegionUninit(&treg); - remove_empties(priv); #endif - -#if 1 +#if 1 /* look for repeating draw types */ if (priv->draw_item_head != 0) { @@ -767,78 +799,6 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) } remove_empties(priv); #endif - -#if 0 - if (priv->draw_item_tail != 0) - { - if (priv->draw_item_tail->prev != 0) - { - di = priv->draw_item_tail; - while (di->prev != 0) - { - di_prev = di->prev; - while (di_prev != 0) - { - if ((di_prev->flags & 1) == 0) - { - if ((di_prev->type == RDI_IMGLY) || (di_prev->type == RDI_IMGLL)) - { - if ((di->type == RDI_TEXT) && - region_interect_at_all(di->reg, di_prev->reg)) - { - RegionSubtract(di->reg, di->reg, di_prev->reg); - di_prev->type = RDI_IMGLL; - } - } - else - { - if ((di->type == RDI_TEXT) && - region_interect_at_all(di->reg, di_prev->reg)) - { - break; - } - } - } - di_prev = di_prev->prev; - } - di = di->prev; - } - } - } - remove_empties(priv); -#endif - -#if 0 - /* subtract regions */ - if (priv->draw_item_tail != 0) - { - if (priv->draw_item_tail->prev != 0) - { - di = priv->draw_item_tail; - while (di->prev != 0) - { - /* skip subtract flag - * draw items like line can't be used to clear(subtract) previous - * draw items since they are not opaque - * eg they can not be the 'S' in 'D = M - S' - * the region for line draw items is the clip region */ - if ((di->flags & 1) == 0) - { - di_prev = di->prev; - while (di_prev != 0) - { - /* D = M - S */ - RegionSubtract(di_prev->reg, di_prev->reg, di->reg); - di_prev = di_prev->prev; - } - } - - di = di->prev; - } - } - } - remove_empties(priv); -#endif return 0; } @@ -990,11 +950,9 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, pScreen->CreatePixmap = rdpCreatePixmap; priv = GETPIXPRIV(rv); priv->rdpindex = -1; - priv->con_number = g_con_number; priv->kind_width = width; pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0); - pScreen->CreatePixmap = rdpCreatePixmap; - if (org_width == 0 && height == 0) + if ((org_width == 0) && (height == 0)) { LLOGLN(10, ("rdpCreatePixmap: setting is_scratch")); priv->is_scratch = 1; @@ -1020,9 +978,11 @@ rdpDestroyPixmap(PixmapPtr pPixmap) { if (XRDP_IS_OS(priv)) { - rdpup_remove_os_bitmap(priv->rdpindex); - rdpup_delete_os_surface(priv->rdpindex); - draw_item_remove_all(priv); + if (priv->rdpindex >= 0) + { + rdpup_remove_os_bitmap(priv->rdpindex); + rdpup_delete_os_surface(priv->rdpindex); + } } } @@ -1042,20 +1002,20 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) int width; int height; struct image_data id; - - if (g_wrapPixmap == 0) + + if (XRDP_IS_OS(priv)) { - return 0; + /* update time stamp */ + rdpup_update_os_use(priv->rdpindex); } - if (priv->status == 0) + else { width = pix->drawable.width; height = pix->drawable.height; if ((pix->usage_hint == 0) && (pix->drawable.depth >= g_rdpScreen.depth) && - (width > 0) && (height > 0) && - (priv->use_count > XRDP_USE_COUNT_THRESHOLD) && - (priv->is_scratch == 0)) + (width > 0) && (height > 0) && (priv->kind_width > 0) && + (priv->is_scratch == 0) && (priv->use_count >= 0)) { width = (width + 3) & ~3; priv->rdpindex = rdpup_add_os_bitmap(pix, priv); @@ -1069,11 +1029,19 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) box.y2 = height; if (g_do_dirty_os) { - draw_item_remove_all(priv); - RegionInit(®1, &box, 0); - draw_item_add_img_region(priv, ®1, GXcopy, RDI_IMGLY, 16); - RegionUninit(®1); - priv->is_dirty = 1; + LLOGLN(10, ("xrdp_is_os: priv->con_number %d g_con_number %d", + priv->con_number, g_con_number)); + LLOGLN(10, ("xrdp_is_os: priv->use_count %d", priv->use_count)); + if (priv->con_number != g_con_number) + { + LLOGLN(10, ("xrdp_is_os: queuing invalidating all")); + draw_item_remove_all(priv); + RegionInit(®1, &box, 0); + draw_item_add_img_region(priv, ®1, GXcopy, RDI_IMGLY, 16); + RegionUninit(®1); + priv->is_dirty = 1; + priv->con_number = g_con_number; + } } else { @@ -1096,10 +1064,6 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) priv->use_count++; return 0; } - else - { - LLOGLN(10, ("xrdp_is_os: ok")); - } priv->use_count++; return 1; } @@ -1344,7 +1308,9 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) BoxRec box2; BoxPtr box3; - LLOGLN(10, ("in rdpCopyWindow")); + LLOGLN(10, ("rdpCopyWindow:")); + LLOGLN(10, ("rdpCopyWindow: new x %d new y %d old x %d old y %d", + pWin->drawable.x, pWin->drawable.y, ptOldOrg.x, ptOldOrg.y)); RegionInit(®, NullBox, 0); RegionCopy(®, pOldRegion); RegionInit(&clip, NullBox, 0); @@ -1356,18 +1322,28 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) { rdpup_check_dirty_screen(&g_screenPriv); } - rdpup_begin_update(); + + g_pScreen->CopyWindow = g_rdpScreen.CopyWindow; + g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); + g_pScreen->CopyWindow = rdpCopyWindow; + num_clip_rects = REGION_NUM_RECTS(&clip); num_reg_rects = REGION_NUM_RECTS(®); LLOGLN(10, ("rdpCopyWindow: num_clip_rects %d num_reg_rects %d", num_clip_rects, num_reg_rects)); + if ((num_clip_rects == 0) || (num_reg_rects == 0)) + { + return; + } + rdpup_begin_update(); + /* when there is a huge list of screen copies, just send as bitmap firefox dragging test does this */ if ((num_clip_rects > 16) && (num_reg_rects > 16)) { box3 = RegionExtents(®); - rdpup_send_area(0, box3->x1, box3->y1, + rdpup_send_area(0, box3->x1 + dx, box3->y1 + dy, box3->x2 - box3->x1, box3->y2 - box3->y1); } @@ -1382,6 +1358,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (j = 0; j < num_clip_rects; j++) { box1 = REGION_RECTS(&clip)[j]; + LLOGLN(10, ("clip x %d y %d w %d h %d", box1.x1, box1.y1, + box1.x2 - box1.x1, box1.y2 - box1.y1)); rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1); @@ -1389,6 +1367,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (i = 0; i < num_reg_rects; i++) { box2 = REGION_RECTS(®)[i]; + LLOGLN(10, ("reg x %d y %d w %d h %d", box2.x1, box2.y1, + box2.x2 - box2.x1, box2.y2 - box2.y1)); rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1, box2.y2 - box2.y1, @@ -1401,6 +1381,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (j = num_clip_rects - 1; j >= 0; j--) { box1 = REGION_RECTS(&clip)[j]; + LLOGLN(10, ("clip x %d y %d w %d h %d", box1.x1, box1.y1, + box1.x2 - box1.x1, box1.y2 - box1.y1)); rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1); @@ -1408,6 +1390,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (i = num_reg_rects - 1; i >= 0; i--) { box2 = REGION_RECTS(®)[i]; + LLOGLN(10, ("reg x %d y %d w %d h %d", box2.x1, box2.y1, + box2.x2 - box2.x1, box2.y2 - box2.y1)); rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1, box2.y2 - box2.y1, @@ -1422,9 +1406,6 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) RegionUninit(®); RegionUninit(&clip); - g_pScreen->CopyWindow = g_rdpScreen.CopyWindow; - g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); - g_pScreen->CopyWindow = rdpCopyWindow; } /******************************************************************************/ @@ -1462,7 +1443,7 @@ rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h, if (g_do_dirty_ons) { - draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL, 16); + draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLY, 16); } else { @@ -1500,7 +1481,7 @@ rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed) if (g_do_dirty_ons) { - draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL, 16); + draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLY, 16); } else { diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index d1e4949a..c8739ba0 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -44,6 +44,12 @@ keyboard and mouse stuff #define DEBUG_OUT_INPUT(arg) ErrorF arg #endif +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + extern ScreenPtr g_pScreen; /* in rdpmain.c */ extern DeviceIntPtr g_pointer; /* in rdpmain.c */ extern DeviceIntPtr g_keyboard; /* in rdpmain.c */ @@ -60,6 +66,12 @@ static int g_tab_down = 0; static int g_scroll_lock_down = 0; static OsTimerPtr g_kbtimer = 0; +static OsTimerPtr g_timer = 0; +static int g_x = 0; +static int g_y = 0; +static int g_timer_schedualed = 0; +static int g_delay_motion = 1; /* turn on or off */ + #define MIN_KEY_CODE 8 #define MAX_KEY_CODE 255 #define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1) @@ -796,12 +808,13 @@ rdpEnqueueMotion(int x, int y) EventListPtr rdp_events; xEvent *pev; + LLOGLN(10, ("rdpEnqueueMotion: x %d y %d", x, y)); # if 0 if (x < 128) { rdpup_begin_update(); - rdpup_send_area(0, 0, 1024, 768); + rdpup_send_area(0, 0, 0, 1024, 768); rdpup_end_update(); } @@ -831,6 +844,7 @@ rdpEnqueueButton(int type, int buttons) EventListPtr rdp_events; xEvent *pev; + LLOGLN(10, ("rdpEnqueueButton:")); i = GetEventList(&rdp_events); n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0); @@ -861,35 +875,66 @@ rdpEnqueueKey(int type, int scancode) } /******************************************************************************/ +static CARD32 +rdpDeferredInputCallback(OsTimerPtr timer, CARD32 now, pointer arg) +{ + LLOGLN(10, ("rdpDeferredInputCallback:")); + g_timer_schedualed = 0; + rdpEnqueueMotion(g_x, g_y); + return 0; +} + +/******************************************************************************/ void PtrAddEvent(int buttonMask, int x, int y) { int i; int type; int buttons; + int send_now; - rdpEnqueueMotion(x, y); - - for (i = 0; i < 7; i++) + LLOGLN(10, ("PtrAddEvent: x %d y %d", x, y)); + send_now = (buttonMask ^ g_old_button_mask) || (g_delay_motion == 0); + LLOGLN(10, ("PtrAddEvent: send_now %d g_timer_schedualed %d", + send_now, g_timer_schedualed)); + if (send_now) { - if ((buttonMask ^ g_old_button_mask) & (1 << i)) + if (g_timer_schedualed) { - if (buttonMask & (1 << i)) - { - type = ButtonPress; - buttons = i + 1; - rdpEnqueueButton(type, buttons); - } - else + g_timer_schedualed = 0; + TimerCancel(g_timer); + } + rdpEnqueueMotion(x, y); + for (i = 0; i < 5; i++) + { + if ((buttonMask ^ g_old_button_mask) & (1 << i)) { - type = ButtonRelease; - buttons = i + 1; - rdpEnqueueButton(type, buttons); + if (buttonMask & (1 << i)) + { + type = ButtonPress; + buttons = i + 1; + rdpEnqueueButton(type, buttons); + } + else + { + type = ButtonRelease; + buttons = i + 1; + rdpEnqueueButton(type, buttons); + } } } + g_old_button_mask = buttonMask; + } + else + { + g_x = x; + g_y = y; + if (!g_timer_schedualed) + { + g_timer_schedualed = 1; + g_timer = TimerSet(g_timer, 0, 60, rdpDeferredInputCallback, 0); + } } - - g_old_button_mask = buttonMask; } /******************************************************************************/ diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index b4095772..28919799 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -23,12 +23,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xrdp_rail.h" #include "rdpglyph.h" +#include <signal.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <sys/types.h> + #define LOG_LEVEL 1 #define LLOG(_level, _args) \ do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0) #define LLOGLN(_level, _args) \ do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) +static int g_use_shmem = 1; /* turns on or off */ +static int g_shmemid = 0; +static char *g_shmemptr = 0; +static int g_shmem_lineBytes = 0; +static RegionPtr g_shm_reg = 0; + +static int g_rect_id_ack = 0; +static int g_rect_id = 0; + static int g_listen_sck = 0; static int g_sck = 0; static int g_sck_closed = 0; @@ -74,9 +88,12 @@ struct rdpup_os_bitmap int stamp; }; +#define USE_MAX_OS_BYTES 1 +#define MAX_OS_BYTES (16 * 1024 * 1024) static struct rdpup_os_bitmap *g_os_bitmaps = 0; static int g_max_os_bitmaps = 0; static int g_os_bitmap_stamp = 0; +static int g_os_bitmap_alloc_size = 0; static int g_pixmap_byte_total = 0; static int g_pixmap_num_used = 0; @@ -126,6 +143,49 @@ static int g_rdp_opcodes[16] = 0xff /* GXset 0xf 1 */ }; +static int g_do_kill_disconnected = 0; /* turn on or off */ +static OsTimerPtr g_dis_timer = 0; +static int g_disconnect_scheduled = 0; +static CARD32 g_disconnect_timeout_s = 60; /* 60 seconds */ +static CARD32 g_disconnect_time_ms = 0; /* time of disconnect in milliseconds */ + +/******************************************************************************/ +static CARD32 +rdpDeferredDisconnectCallback(OsTimerPtr timer, CARD32 now, pointer arg) +{ + CARD32 lnow_ms; + + LLOGLN(10, ("rdpDeferredDisconnectCallback")); + if (g_connected) + { + /* this should not happen */ + LLOGLN(0, ("rdpDeferredDisconnectCallback: connected")); + if (g_dis_timer != 0) + { + LLOGLN(0, ("rdpDeferredDisconnectCallback: canceling g_dis_timer")); + TimerCancel(g_dis_timer); + TimerFree(g_dis_timer); + g_dis_timer = 0; + } + g_disconnect_scheduled = 0; + return 0; + } + else + { + LLOGLN(10, ("rdpDeferredDisconnectCallback: not connected")); + } + lnow_ms = GetTimeInMillis(); + if (lnow_ms - g_disconnect_time_ms > g_disconnect_timeout_s * 1000) + { + LLOGLN(0, ("rdpDeferredDisconnectCallback: exit X11rdp")); + kill(getpid(), SIGTERM); + return 0; + } + g_dis_timer = TimerSet(g_dis_timer, 0, 1000 * 10, + rdpDeferredDisconnectCallback, 0); + return 0; +} + /*****************************************************************************/ static int rdpup_disconnect(void) @@ -133,6 +193,18 @@ rdpup_disconnect(void) int index; LLOGLN(0, ("rdpup_disconnect:")); + if (g_do_kill_disconnected) + { + if (!g_disconnect_scheduled) + { + LLOGLN(0, ("rdpup_disconnect: starting g_dis_timer")); + g_dis_timer = TimerSet(g_dis_timer, 0, 1000 * 10, + rdpDeferredDisconnectCallback, 0); + g_disconnect_scheduled = 1; + } + g_disconnect_time_ms = GetTimeInMillis(); + } + RemoveEnabledDevice(g_sck); g_connected = 0; g_tcp_close(g_sck); @@ -155,6 +227,7 @@ rdpup_disconnect(void) } } } + g_os_bitmap_alloc_size = 0; g_max_os_bitmaps = 0; g_free(g_os_bitmaps); @@ -166,6 +239,7 @@ rdpup_disconnect(void) } /*****************************************************************************/ +/* returns -1 on error */ int rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv) { @@ -173,17 +247,32 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv) int rv; int oldest; int oldest_index; + int this_bytes; + LLOGLN(10, ("rdpup_add_os_bitmap:")); if (!g_connected) { + LLOGLN(10, ("rdpup_add_os_bitmap: test error 1")); return -1; } if (g_os_bitmaps == 0) { + LLOGLN(10, ("rdpup_add_os_bitmap: test error 2")); return -1; } + this_bytes = pixmap->devKind * pixmap->drawable.height; + if (this_bytes > MAX_OS_BYTES) + { + LLOGLN(10, ("rdpup_add_os_bitmap: 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; @@ -200,42 +289,83 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv) rv = index; break; } - + else + { + if (g_os_bitmaps[index].stamp < oldest) + { + oldest = g_os_bitmaps[index].stamp; + oldest_index = index; + } + } index++; } if (rv == -1) { + if (oldest_index == -1) + { + LLOGLN(0, ("rdpup_add_os_bitmap: error")); + } + else + { + LLOGLN(10, ("rdpup_add_os_bitmap: too many pixmaps removing " + "oldest_index %d", oldest_index)); + rdpup_remove_os_bitmap(oldest_index); + rdpup_delete_os_surface(oldest_index); + g_os_bitmaps[oldest_index].used = 1; + g_os_bitmaps[oldest_index].pixmap = pixmap; + g_os_bitmaps[oldest_index].priv = priv; + g_os_bitmaps[oldest_index].stamp = g_os_bitmap_stamp; + g_os_bitmap_stamp++; + g_pixmap_num_used++; + rv = oldest_index; + } + } + + if (rv < 0) + { + LLOGLN(10, ("rdpup_add_os_bitmap: test error 3")); + return rv; + } + + g_os_bitmap_alloc_size += this_bytes; + LLOGLN(10, ("rdpup_add_os_bitmap: this_bytes %d g_os_bitmap_alloc_size %d", + this_bytes, g_os_bitmap_alloc_size)); +#if USE_MAX_OS_BYTES + while (g_os_bitmap_alloc_size > MAX_OS_BYTES) + { + LLOGLN(10, ("rdpup_add_os_bitmap: must delete g_pixmap_num_used %d", + g_pixmap_num_used)); /* find oldest */ oldest = 0x7fffffff; - oldest_index = 0; + oldest_index = -1; index = 0; - while (index < g_max_os_bitmaps) { - if (g_os_bitmaps[index].stamp < oldest) + if (g_os_bitmaps[index].used && (g_os_bitmaps[index].stamp < oldest)) { oldest = g_os_bitmaps[index].stamp; oldest_index = index; } - index++; } - - LLOGLN(10, ("rdpup_add_os_bitmap: evicting old, oldest_index %d", oldest_index)); - /* evict old */ - g_os_bitmaps[oldest_index].priv->status = 0; - g_os_bitmaps[oldest_index].priv->con_number = 0; - /* set new */ - g_os_bitmaps[oldest_index].pixmap = pixmap; - g_os_bitmaps[oldest_index].priv = priv; - g_os_bitmaps[oldest_index].stamp = g_os_bitmap_stamp; - g_os_bitmap_stamp++; - rv = oldest_index; + if (oldest_index == -1) + { + LLOGLN(0, ("rdpup_add_os_bitmap: error 1")); + break; + } + if (oldest_index == rv) + { + LLOGLN(0, ("rdpup_add_os_bitmap: error 2")); + break; + } + rdpup_remove_os_bitmap(oldest_index); + rdpup_delete_os_surface(oldest_index); } - +#endif LLOGLN(10, ("rdpup_add_os_bitmap: new bitmap index %d", rv)); - LLOGLN(10, (" g_pixmap_num_used %d", g_pixmap_num_used)); + LLOGLN(10, ("rdpup_add_os_bitmap: g_pixmap_num_used %d " + "g_os_bitmap_stamp 0x%8.8x", g_pixmap_num_used, g_os_bitmap_stamp)); return rv; } @@ -243,31 +373,84 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv) int rdpup_remove_os_bitmap(int rdpindex) { + PixmapPtr pixmap; + rdpPixmapPtr priv; + int this_bytes; + LLOGLN(10, ("rdpup_remove_os_bitmap: index %d stamp %d", - rdpindex, g_os_bitmaps[rdpindex].stamp)); + rdpindex, g_os_bitmaps[rdpindex].stamp)); if (g_os_bitmaps == 0) { + LLOGLN(10, ("rdpup_remove_os_bitmap: test error 1")); return 1; } if ((rdpindex < 0) && (rdpindex >= g_max_os_bitmaps)) { + LLOGLN(10, ("rdpup_remove_os_bitmap: test error 2")); return 1; } if (g_os_bitmaps[rdpindex].used) { + pixmap = g_os_bitmaps[rdpindex].pixmap; + priv = g_os_bitmaps[rdpindex].priv; + draw_item_remove_all(priv); + this_bytes = pixmap->devKind * pixmap->drawable.height; + g_os_bitmap_alloc_size -= this_bytes; + LLOGLN(10, ("rdpup_remove_os_bitmap: this_bytes %d " + "g_os_bitmap_alloc_size %d", this_bytes, + g_os_bitmap_alloc_size)); g_os_bitmaps[rdpindex].used = 0; g_os_bitmaps[rdpindex].pixmap = 0; g_os_bitmaps[rdpindex].priv = 0; g_pixmap_num_used--; + 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: g_pixmap_num_used %d", + g_pixmap_num_used)); + return 0; +} + +/*****************************************************************************/ +int +rdpup_update_os_use(int rdpindex) +{ + LLOGLN(10, ("rdpup_update_use: index %d stamp %d", + rdpindex, g_os_bitmaps[rdpindex].stamp)); + + if (g_os_bitmaps == 0) + { + return 1; + } + + if ((rdpindex < 0) && (rdpindex >= g_max_os_bitmaps)) + { + return 1; + } + + if (g_os_bitmaps[rdpindex].used) + { + g_os_bitmaps[rdpindex].stamp = g_os_bitmap_stamp; + g_os_bitmap_stamp++; + } + else + { + LLOGLN(0, ("rdpup_update_use: error rdpindex %d", rdpindex)); } - LLOGLN(10, (" g_pixmap_num_used %d", g_pixmap_num_used)); return 0; } + /*****************************************************************************/ /* returns error */ static int @@ -382,7 +565,14 @@ rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) if (g_do_dirty_ons) { - rdpup_check_dirty_screen(&g_screenPriv); + if (g_rect_id == g_rect_id_ack) + { + rdpup_check_dirty_screen(&g_screenPriv); + } + else + { + LLOGLN(0, ("rdpDeferredUpdateCallback: skipping")); + } } else { @@ -483,6 +673,34 @@ rdpup_recv_msg(struct stream *s) return rv; } +/*****************************************************************************/ +/* wait 'millis' milliseconds for the socket to be able to receive */ +/* returns boolean */ +static int +sck_can_recv(int sck, int millis) +{ + fd_set rfds; + struct timeval time; + int rv; + + time.tv_sec = millis / 1000; + time.tv_usec = (millis * 1000) % 1000000; + FD_ZERO(&rfds); + + if (sck > 0) + { + FD_SET(((unsigned int)sck), &rfds); + rv = select(sck + 1, &rfds, 0, 0, &time); + + if (rv > 0) + { + return 1; + } + } + + return 0; +} + /******************************************************************************/ /* this from miScreenInit @@ -495,6 +713,7 @@ process_screen_size_msg(int width, int height, int bpp) RRScreenSizePtr pSize; int mmwidth; int mmheight; + int bytes; Bool ok; LLOGLN(0, ("process_screen_size_msg: set width %d height %d bpp %d", @@ -524,6 +743,28 @@ process_screen_size_msg(int width, int height, int bpp) g_rdpScreen.rdp_Bpp_mask = 0xffffff; } + if (g_use_shmem) + { + if (g_shmemptr != 0) + { + shmdt(g_shmemptr); + } + bytes = g_rdpScreen.rdp_width * g_rdpScreen.rdp_height * + g_rdpScreen.rdp_Bpp; + g_shmemid = shmget(IPC_PRIVATE, bytes, IPC_CREAT | 0777); + g_shmemptr = shmat(g_shmemid, 0, 0); + shmctl(g_shmemid, IPC_RMID, NULL); + LLOGLN(0, ("process_screen_size_msg: g_shmemid %d g_shmemptr %p", + g_shmemid, g_shmemptr)); + g_shmem_lineBytes = g_rdpScreen.rdp_Bpp * g_rdpScreen.rdp_width; + + if (g_shm_reg != 0) + { + RegionDestroy(g_shm_reg); + } + g_shm_reg = RegionCreate(NullBox, 0); + } + mmwidth = PixelToMM(width); mmheight = PixelToMM(height); @@ -668,6 +909,13 @@ rdpup_process_msg(struct stream *s) int param4; int bytes; int i1; + int flags; + int x; + int y; + int cx; + int cy; + RegionRec reg; + BoxRec box; in_uint16_le(s, msg_type); @@ -855,6 +1103,31 @@ rdpup_process_msg(struct stream *s) LLOGLN(0, (" client can not do new(color) cursor")); } } + else if (msg_type == 105) + { + LLOGLN(10, ("rdpup_process_msg: got msg 105")); + in_uint32_le(s, flags); + in_uint32_le(s, g_rect_id_ack); + in_uint32_le(s, x); + in_uint32_le(s, y); + in_uint32_le(s, cx); + in_uint32_le(s, cy); + LLOGLN(10, (" %d %d %d %d", x, y, cx ,cy)); + LLOGLN(10, (" rect_id %d rect_id_ack %d", g_rect_id, g_rect_id_ack)); + + box.x1 = x; + box.y1 = y; + box.x2 = box.x1 + cx; + box.y2 = box.y1 + cy; + + RegionInit(®, &box, 0); + LLOGLN(10, ("< %d %d %d %d", box.x1, box.y1, box.x2, box.y2)); + RegionSubtract(g_shm_reg, g_shm_reg, ®); + RegionUninit(®); + + } + + else { rdpLog("unknown message type in rdpup_process_msg %d\n", msg_type); @@ -873,6 +1146,10 @@ rdpup_get_screen_image_rect(struct image_data *id) id->Bpp = g_rdpScreen.rdp_Bpp; id->lineBytes = g_rdpScreen.paddedWidthInBytes; id->pixels = g_rdpScreen.pfbMemory; + id->shmem_pixels = g_shmemptr; + id->shmem_id = g_shmemid; + id->shmem_offset = 0; + id->shmem_lineBytes = g_shmem_lineBytes; } /******************************************************************************/ @@ -885,6 +1162,10 @@ rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data *id) id->Bpp = g_rdpScreen.rdp_Bpp; id->lineBytes = pPixmap->devKind; id->pixels = (char *)(pPixmap->devPrivate.ptr); + id->shmem_pixels = 0; + id->shmem_id = 0; + id->shmem_offset = 0; + id->shmem_lineBytes = 0; } /******************************************************************************/ @@ -892,6 +1173,7 @@ int rdpup_init(void) { char text[256]; + char *ptext; int i; if (!g_directory_exist("/tmp/.xrdp")) @@ -976,6 +1258,39 @@ rdpup_init(void) } } + ptext = getenv("XRDP_SESMAN_MAX_IDLE_TIME"); + if (ptext != 0) + { + } + ptext = getenv("XRDP_SESMAN_MAX_DISC_TIME"); + if (ptext != 0) + { + i = atoi(ptext); + if (i > 0) + { + g_do_kill_disconnected = 1; + g_disconnect_timeout_s = atoi(ptext); + } + } + ptext = getenv("XRDP_SESMAN_KILL_DISCONNECTED"); + if (ptext != 0) + { + i = atoi(ptext); + if (i != 0) + { + g_do_kill_disconnected = 1; + g_disconnect_timeout_s = 0; + } + } + + if (g_do_kill_disconnected && (g_disconnect_timeout_s < 60)) + { + g_disconnect_timeout_s = 60; + } + + rdpLog("kill disconencted [%d] timeout [%d] sec\n", g_do_kill_disconnected, + g_disconnect_timeout_s); + return 1; } @@ -1015,6 +1330,16 @@ rdpup_check(void) g_con_number++; rdpGlyphInit(); AddEnabledDevice(g_sck); + + if (g_dis_timer != 0) + { + LLOGLN(0, ("rdpup_check: canceling g_dis_timer")); + TimerCancel(g_dis_timer); + TimerFree(g_dis_timer); + g_dis_timer = 0; + } + g_disconnect_scheduled = 0; + } } @@ -1680,11 +2005,13 @@ get_single_color(struct image_data *id, int x, int y, int w, int h) } /******************************************************************************/ -/* split the bitmap up into 64 x 64 pixel areas */ +/* split the bitmap up into 64 x 64 pixel areas + or send using shared memory */ void rdpup_send_area(struct image_data *id, int x, int y, int w, int h) { char *s; + char *d; int i; int single_color; int lx; @@ -1692,7 +2019,10 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) int lh; int lw; int size; + int safety; struct image_data lid; + BoxRec box; + RegionRec reg; LLOGLN(10, ("rdpup_send_area: id %p x %d y %d w %d h %d", id, x, y, w, h)); @@ -1749,8 +2079,71 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) if (g_connected && g_begin) { LLOGLN(10, (" rdpup_send_area")); - ly = y; + if (id->shmem_pixels != 0) + { + LLOGLN(10, ("rdpup_send_area: using shmem")); + box.x1 = x; + box.y1 = y; + box.x2 = box.x1 + w; + box.y2 = box.y1 + h; + safety = 0; + while (RegionContainsRect(g_shm_reg, &box)) + { + rdpup_end_update(); + rdpup_begin_update(); + safety++; + if (safety > 100) + { + break; + } + if (sck_can_recv(g_sck, 100)) + { + if (rdpup_recv_msg(g_in_s) == 0) + { + rdpup_process_msg(g_in_s); + } + } + } + s = id->pixels; + s += y * id->lineBytes; + s += x * g_Bpp; + d = id->shmem_pixels + id->shmem_offset; + d += y * id->shmem_lineBytes; + d += x * g_rdpScreen.rdp_Bpp; + ly = y; + while (ly < y + h) + { + convert_pixels(s, d, w); + s += id->lineBytes; + d += id->shmem_lineBytes; + ly += 1; + } + size = 36; + rdpup_pre_check(size); + out_uint16_le(g_out_s, 60); + out_uint16_le(g_out_s, size); + g_count++; + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, w); + out_uint16_le(g_out_s, h); + out_uint32_le(g_out_s, 0); + g_rect_id++; + out_uint32_le(g_out_s, g_rect_id); + out_uint32_le(g_out_s, id->shmem_id); + out_uint32_le(g_out_s, id->shmem_offset); + out_uint16_le(g_out_s, id->width); + out_uint16_le(g_out_s, id->height); + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + RegionInit(®, &box, 0); + RegionUnion(g_shm_reg, g_shm_reg, ®); + RegionUninit(®); + return; + } + + ly = y; while ((ly < y + h) && g_connected) { lx = x; @@ -2106,10 +2499,6 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) return 0; } - /* update use time / count */ - g_os_bitmaps[pDirtyPriv->rdpindex].stamp = g_os_bitmap_stamp; - g_os_bitmap_stamp++; - LLOGLN(10, ("rdpup_check_dirty: got dirty")); rdpup_switch_os_surface(pDirtyPriv->rdpindex); rdpup_get_pixmap_image_rect(pDirtyPixmap, &id); @@ -2302,8 +2691,8 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv) for (index = 0; index < count; index++) { box = REGION_RECTS(di->reg)[index]; - LLOGLN(10, (" RDI_IMGLL %d %d %d %d", box.x1, box.y1, - box.x2, box.y2)); + LLOGLN(10, (" RDI_IMGLL x %d y %d w %d h %d", box.x1, box.y1, + box.x2 - box.x1, box.y2 - box.y1)); rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } |