From 2e7d413693195e469103284e956d0c5d91f6ed25 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 15 May 2012 16:48:25 -0700 Subject: [PATCH] xorg: work on offscreen bitmaps --- xorg/X11R7.6/rdp/Makefile | 2 + xorg/X11R7.6/rdp/gcops.h | 17 - xorg/X11R7.6/rdp/rdp.h | 32 +- xorg/X11R7.6/rdp/rdpCopyArea.c | 482 +++++++++++++++++++++ xorg/X11R7.6/rdp/rdpCopyArea.h | 29 ++ xorg/X11R7.6/rdp/rdpPolyFillRect.c | 186 ++++++++ xorg/X11R7.6/rdp/rdpPolyFillRect.h | 29 ++ xorg/X11R7.6/rdp/rdpPolyRectangle.c | 228 ++++++++++ xorg/X11R7.6/rdp/rdpPolyRectangle.h | 29 ++ xorg/X11R7.6/rdp/rdpPolySegment.c | 164 +++++++ xorg/X11R7.6/rdp/rdpPolySegment.h | 28 ++ xorg/X11R7.6/rdp/rdpPolylines.c | 197 +++++++++ xorg/X11R7.6/rdp/rdpPolylines.h | 29 ++ xorg/X11R7.6/rdp/rdpPutImage.c | 130 ++++++ xorg/X11R7.6/rdp/rdpPutImage.h | 29 ++ xorg/X11R7.6/rdp/rdpdraw.c | 637 ++-------------------------- xorg/X11R7.6/rdp/rdpdraw.h | 45 ++ xorg/X11R7.6/rdp/rdpup.c | 140 +++++- 18 files changed, 1818 insertions(+), 615 deletions(-) create mode 100644 xorg/X11R7.6/rdp/rdpCopyArea.c create mode 100644 xorg/X11R7.6/rdp/rdpCopyArea.h create mode 100644 xorg/X11R7.6/rdp/rdpPolyFillRect.c create mode 100644 xorg/X11R7.6/rdp/rdpPolyFillRect.h create mode 100644 xorg/X11R7.6/rdp/rdpPolyRectangle.c create mode 100644 xorg/X11R7.6/rdp/rdpPolyRectangle.h create mode 100644 xorg/X11R7.6/rdp/rdpPolySegment.c create mode 100644 xorg/X11R7.6/rdp/rdpPolySegment.h create mode 100644 xorg/X11R7.6/rdp/rdpPolylines.c create mode 100644 xorg/X11R7.6/rdp/rdpPolylines.h create mode 100644 xorg/X11R7.6/rdp/rdpPutImage.c create mode 100644 xorg/X11R7.6/rdp/rdpPutImage.h create mode 100644 xorg/X11R7.6/rdp/rdpdraw.h diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index 91961151..c293664d 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -7,6 +7,8 @@ LIBBASE = $(X11RDPBASE)/lib XSRCBASE = ../build_dir/xorg-server-1.9.3 OBJS = rdpmain.o rdpdraw.o rdpinput.o rdpmisc.o rdpup.o rdprandr.o \ +rdpCopyArea.o rdpPolyFillRect.o rdpPutImage.o rdpPolyRectangle.o \ +rdpPolylines.o rdpPolySegment.o \ miinitext.o \ fbcmap_mi.o diff --git a/xorg/X11R7.6/rdp/gcops.h b/xorg/X11R7.6/rdp/gcops.h index 52889b82..20ed0a1b 100644 --- a/xorg/X11R7.6/rdp/gcops.h +++ b/xorg/X11R7.6/rdp/gcops.h @@ -39,12 +39,6 @@ rdpFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, static void rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char * psrc, DDXPointPtr ppt, int * pwidth, int nspans, int fSorted); -static void -rdpPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, - int w, int h, int leftPad, int format, char * pBits); -static RegionPtr -rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty); static RegionPtr rdpCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, int srcx, int srcy, int width, int height, @@ -53,23 +47,12 @@ static void rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit); static void -rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, - int npt, DDXPointPtr pptInit); -static void -rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs); -static void -rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, - xRectangle * pRects); -static void rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * parcs); static void rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr pPts); static void -rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, - xRectangle * prectInit); -static void rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * parcs); static int rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 98c0c067..3927e29d 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -93,6 +93,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PixelDPI 100 #define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) +struct image_data +{ + int width; + int height; + int bpp; + int Bpp; + int lineBytes; + char* pixels; +}; + /* Per-screen (framebuffer) structure. There is only one of these, since we don't allow the X server to have multiple screens. */ struct _rdpScreenInfoRec @@ -162,12 +172,18 @@ typedef rdpWindowRec* rdpWindowPtr; struct _rdpPixmapRec { int status; + int rdpid; /* unique id for xrdp */ + int allocBytes; + int con_number; }; typedef struct _rdpPixmapRec rdpPixmapRec; typedef rdpPixmapRec* rdpPixmapPtr; #define GETPIXPRIV(_pPixmap) \ (rdpPixmapPtr)dixGetPrivateAddr(&(_pPixmap->devPrivates), &g_rdpPixmapIndex) +#define XRDP_IS_OS(_priv) ((_priv->status != 0) && \ + (_priv->con_number == g_con_number)) + /* rdpmisc.c */ void rdpLog(char *format, ...); @@ -314,6 +330,10 @@ void KbdSync(int param1); /* rdpup.c */ +void +rdpup_get_screen_image_rect(struct image_data* id); +void +rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data* id); int rdpup_init(void); int @@ -345,9 +365,19 @@ rdpup_set_pen(int style, int width); int rdpup_draw_line(short x1, short y1, short x2, short y2); void -rdpup_send_area(int x, int y, int w, int h); +rdpup_send_area(struct image_data* id, int x, int y, int w, int h); int rdpup_set_cursor(short x, short y, char* cur_data, char* cur_mask); +int +rdpup_create_os_surface(int rdpid, int width, int height); +int +rdpup_switch_os_surface(int rdpid); +int +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); #if defined(X_BYTE_ORDER) # if X_BYTE_ORDER == X_LITTLE_ENDIAN diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.c b/xorg/X11R7.6/rdp/rdpCopyArea.c new file mode 100644 index 00000000..3c3d371b --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpCopyArea.c @@ -0,0 +1,482 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +static RegionPtr +rdpCopyAreaOrg(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + RegionPtr rv; + + GC_OP_PROLOGUE(pGC); + rv = pGC->ops->CopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); + GC_OP_EPILOGUE(pGC); + return rv; +} + +/******************************************************************************/ +static RegionPtr +rdpCopyAreaWndToWnd(WindowPtr pSrcWnd, WindowPtr pDstWnd, GCPtr pGC, + int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + int cd; + int lsrcx; + int lsrcy; + int ldstx; + int ldsty; + int num_clips; + int dx; + int dy; + int j; + BoxRec box; + RegionPtr rv; + RegionRec clip_reg; + + LLOGLN(10, ("rdpCopyAreaWndToWnd:")); + + rv = rdpCopyAreaOrg(&(pSrcWnd->drawable), &(pDstWnd->drawable), + pGC, srcx, srcy, w, h, dstx, dsty); + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, &(pDstWnd->drawable), pGC); + lsrcx = pSrcWnd->drawable.x + srcx; + lsrcy = pSrcWnd->drawable.y + srcy; + ldstx = pDstWnd->drawable.x + dstx; + ldsty = pDstWnd->drawable.y + dsty; + if (cd == 1) + { + rdpup_begin_update(); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + rdpup_end_update(); + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_begin_update(); + dx = dstx - srcx; + dy = dsty - srcy; + if ((dy < 0) || ((dy == 0) && (dx < 0))) + { + for (j = 0; j < num_clips; j++) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + } + } + else + { + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + } + } + rdpup_reset_clip(); + rdpup_end_update(); + } + } + RegionUninit(&clip_reg); + return rv; +} + +/******************************************************************************/ +static RegionPtr +rdpCopyAreaWndToPixmap(WindowPtr pSrcWnd, + PixmapPtr pDstPixmap, rdpPixmapRec* pDstPriv, + GCPtr pGC, int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + int cd; + int lsrcx; + int lsrcy; + int ldstx; + int ldsty; + int num_clips; + int dx; + int dy; + int j; + BoxRec box; + RegionPtr rv; + RegionRec clip_reg; + + LLOGLN(10, ("rdpCopyAreaWndToPixmap:")); + + rv = rdpCopyAreaOrg(&(pSrcWnd->drawable), &(pDstPixmap->drawable), + pGC, srcx, srcy, w, h, dstx, dsty); + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, &(pDstPixmap->drawable), pGC); + lsrcx = pSrcWnd->drawable.x + srcx; + lsrcy = pSrcWnd->drawable.y + srcy; + ldstx = pDstPixmap->drawable.x + dstx; + ldsty = pDstPixmap->drawable.y + dsty; + if (cd == 1) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_begin_update(); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_begin_update(); + dx = dstx - srcx; + dy = dsty - srcy; + if ((dy < 0) || ((dy == 0) && (dx < 0))) + { + for (j = 0; j < num_clips; j++) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + } + } + else + { + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy); + } + } + rdpup_reset_clip(); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + } + } + RegionUninit(&clip_reg); + return rv; +} + +/******************************************************************************/ +/* draw from an off screen pixmap to a visible window */ +static RegionPtr +rdpCopyAreaPixmapToWnd(PixmapPtr pSrcPixmap, rdpPixmapRec* pSrcPriv, + WindowPtr pDstWnd, GCPtr pGC, + int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + int lsrcx; + int lsrcy; + int ldstx; + int ldsty; + int cd; + int j; + int num_clips; + RegionPtr rv; + RegionRec clip_reg; + BoxRec box; + + LLOGLN(10, ("rdpCopyAreaPixmapToWnd:")); + + rv = rdpCopyAreaOrg(&(pSrcPixmap->drawable), &(pDstWnd->drawable), + pGC, srcx, srcy, w, h, dstx, dsty); + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, &(pDstWnd->drawable), pGC); + ldstx = pDstWnd->drawable.x + dstx; + ldsty = pDstWnd->drawable.y + dsty; + lsrcx = pSrcPixmap->drawable.x + srcx; + lsrcy = pSrcPixmap->drawable.y + srcy; + if (cd == 1) + { + rdpup_begin_update(); + rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpid, lsrcx, lsrcy); + rdpup_end_update(); + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_begin_update(); + for (j = 0; j < num_clips; j++) + { + box = REGION_RECTS(&clip_reg)[j]; + LLOGLN(10, ("rdpCopyAreaPixmapToWnd: %d %d %d %d", box.x1, box.y1, box.x2, box.y2)); + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpid, lsrcx, lsrcy); + } + rdpup_reset_clip(); + rdpup_end_update(); + } + } + RegionUninit(&clip_reg); + return rv; +} + +/******************************************************************************/ +/* draw from an off screen pixmap to an off screen pixmap */ +static RegionPtr +rdpCopyAreaPixmapToPixmap(PixmapPtr pSrcPixmap, rdpPixmapRec* pSrcPriv, + PixmapPtr pDstPixmap, rdpPixmapRec* pDstPriv, + GCPtr pGC, int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + int lsrcx; + int lsrcy; + int ldstx; + int ldsty; + int cd; + int j; + int num_clips; + RegionPtr rv; + RegionRec clip_reg; + BoxRec box; + + LLOGLN(10, ("rdpCopyAreaPixmapToPixmap:")); + + rv = rdpCopyAreaOrg(&(pSrcPixmap->drawable), &(pDstPixmap->drawable), + pGC, srcx, srcy, w, h, dstx, dsty); + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, &(pDstPixmap->drawable), pGC); + ldstx = pDstPixmap->drawable.x + dstx; + ldsty = pDstPixmap->drawable.y + dsty; + lsrcx = pSrcPixmap->drawable.x + srcx; + lsrcy = pSrcPixmap->drawable.y + srcy; + if (cd == 1) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_begin_update(); + rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpid, lsrcx, lsrcy); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_begin_update(); + for (j = 0; j < num_clips; j++) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpid, lsrcx, lsrcy); + } + rdpup_reset_clip(); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + } + } + RegionUninit(&clip_reg); + return rv; +} + +/******************************************************************************/ +RegionPtr +rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + RegionPtr rv; + RegionRec clip_reg; + RegionRec box_reg; + int num_clips; + int cd; + int j; + int can_do_screen_blt; + int got_id; + struct image_data id; + BoxRec box; + BoxPtr pbox; + PixmapPtr pSrcPixmap; + PixmapPtr pDstPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pDstPriv; + WindowPtr pDstWnd; + WindowPtr pSrcWnd; + + LLOGLN(10, ("rdpCopyArea:")); + + if (pSrc->type == DRAWABLE_WINDOW) + { + pSrcWnd = (WindowPtr)pSrc; + if (pSrcWnd->viewable) + { + if (pDst->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDst; + if (pDstWnd->viewable) + { + can_do_screen_blt = pGC->alu == GXcopy; + if (can_do_screen_blt) + { + return rdpCopyAreaWndToWnd(pSrcWnd, pDstWnd, pGC, + srcx, srcy, w, h, dstx, dsty); + } + } + } + else if (pDst->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDst; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + can_do_screen_blt = pGC->alu == GXcopy; + if (can_do_screen_blt) + { + return rdpCopyAreaWndToPixmap(pSrcWnd, pDstPixmap, pDstPriv, pGC, + srcx, srcy, w, h, dstx, dsty); + } + } + } + } + } + if (pSrc->type == DRAWABLE_PIXMAP) + { + pSrcPixmap = (PixmapPtr)pSrc; + pSrcPriv = GETPIXPRIV(pSrcPixmap); + if (XRDP_IS_OS(pSrcPriv)) + { + if (pDst->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDst; + if (pDstWnd->viewable) + { + return rdpCopyAreaPixmapToWnd(pSrcPixmap, pSrcPriv, pDstWnd, pGC, + srcx, srcy, w, h, dstx, dsty); + } + } + else if (pDst->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDst; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + return rdpCopyAreaPixmapToPixmap(pSrcPixmap, pSrcPriv, + pDstPixmap, pDstPriv, + pGC, srcx, srcy, w, h, + dstx, dsty); + } + } + } + } + + /* do original call */ + rv = rdpCopyAreaOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); + + got_id = 0; + if (pDst->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDst; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDst->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDst; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + return rv; + } + + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDst, pGC); + if (cd == 1) + { + rdpup_begin_update(); + rdpup_send_area(&id, pDst->x + dstx, pDst->y + dsty, w, h); + rdpup_end_update(); + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_begin_update(); + box.x1 = pDst->x + dstx; + box.y1 = pDst->y + dsty; + box.x2 = box.x1 + w; + box.y2 = box.y1 + h; + RegionInit(&box_reg, &box, 0); + RegionIntersect(&clip_reg, &clip_reg, &box_reg); + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips < 10) + { + 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); + } + } + else + { + pbox = RegionExtents(&clip_reg); + rdpup_send_area(&id, pbox->x1, pbox->y1, pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + } + RegionUninit(&box_reg); + rdpup_end_update(); + } + } + RegionUninit(&clip_reg); + rdpup_switch_os_surface(-1); + return rv; +} diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.h b/xorg/X11R7.6/rdp/rdpCopyArea.h new file mode 100644 index 00000000..d5d7c27b --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpCopyArea.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPCOPYAREA_H +#define __RDPCOPYAREA_H + +RegionPtr +rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.c b/xorg/X11R7.6/rdp/rdpPolyFillRect.c new file mode 100644 index 00000000..66eb50fe --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.c @@ -0,0 +1,186 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +static void +rdpPolyFillRectOrg(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle* prectInit) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyFillRect(pDrawable, pGC, nrectFill, prectInit); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle* prectInit) +{ + int j; + int cd; + int num_clips; + RegionRec clip_reg; + RegionPtr fill_reg; + BoxRec box; + + int got_id; + struct image_data id; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + + LLOGLN(10, ("rdpPolyFillRect:")); + + /* make a copy of rects */ + fill_reg = RegionFromRects(nrectFill, prectInit, CT_NONE); + + /* do original call */ + rdpPolyFillRectOrg(pDrawable, pGC, nrectFill, prectInit); + + got_id = 0; + if (pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDrawable; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDrawable->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDrawable; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + RegionDestroy(fill_reg); + return; + } + RegionTranslate(fill_reg, pDrawable->x, pDrawable->y); + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDrawable, pGC); + if (cd == 1) /* no clip */ + { + rdpup_begin_update(); + if (pGC->fillStyle == 0 && /* solid fill */ + (pGC->alu == GXclear || + pGC->alu == GXset || + pGC->alu == GXinvert || + pGC->alu == GXnoop || + pGC->alu == GXand || + pGC->alu == GXcopy /*|| + pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ + { + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + 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_set_opcode(GXcopy); + } + else /* non solid fill */ + { + for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--) + { + box = REGION_RECTS(fill_reg)[j]; + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + } + } + rdpup_end_update(); + } + else if (cd == 2) /* clip */ + { + RegionIntersect(&clip_reg, &clip_reg, fill_reg); + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_begin_update(); + if (pGC->fillStyle == 0 && /* solid fill */ + (pGC->alu == GXclear || + pGC->alu == GXset || + pGC->alu == GXinvert || + pGC->alu == GXnoop || + pGC->alu == GXand || + pGC->alu == GXcopy /*|| + pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ + { + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + 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_set_opcode(GXcopy); + } + else /* non solid fill */ + { + 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_end_update(); + } + } + RegionUninit(&clip_reg); + RegionDestroy(fill_reg); + rdpup_switch_os_surface(-1); +} diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.h b/xorg/X11R7.6/rdp/rdpPolyFillRect.h new file mode 100644 index 00000000..cca9efa2 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYFILLRECT_H +#define __RDPPOLYFILLRECT_H + +void +rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle* prectInit); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.c b/xorg/X11R7.6/rdp/rdpPolyRectangle.c new file mode 100644 index 00000000..0d2e7afa --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.c @@ -0,0 +1,228 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +static void +rdpPolyRectangleOrg(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle* rects) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyRectangle(pDrawable, pGC, nrects, rects); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +/* tested with pGC->lineWidth = 0, 1, 2, 4 and opcodes 3 and 6 */ +void +rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle* rects) +{ + RegionRec clip_reg; + RegionPtr fill_reg; + int num_clips; + int cd; + int lw; + int i; + int j; + int up; + int down; + int got_id; + xRectangle* regRects; + xRectangle* r; + xRectangle* rect1; + BoxRec box; + struct image_data id; + + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + + LLOGLN(10, ("rdpPolyRectangle:")); + + /* make a copy of rects */ + rect1 = (xRectangle*)g_malloc(sizeof(xRectangle) * nrects, 0); + for (i = 0; i < nrects; i++) + { + rect1[i] = rects[i]; + } + + /* do original call */ + rdpPolyRectangleOrg(pDrawable, pGC, nrects, rects); + + got_id = 0; + if (pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDrawable; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDrawable->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDrawable; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + g_free(rect1); + return; + } + + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDrawable, pGC); + regRects = 0; + if ((cd != 0) && (nrects > 0)) + { + regRects = (xRectangle*)g_malloc(nrects * 4 * sizeof(xRectangle), 0); + lw = pGC->lineWidth; + if (lw < 1) + { + lw = 1; + } + up = lw / 2; + down = 1 + (lw - 1) / 2; + for (i = 0; i < nrects; i++) + { + r = regRects + i * 4; + r->x = (rect1[i].x + pDrawable->x) - up; + r->y = (rect1[i].y + pDrawable->y) - up; + r->width = rect1[i].width + up + down; + r->height = lw; + r++; + r->x = (rect1[i].x + pDrawable->x) - up; + r->y = (rect1[i].y + pDrawable->y) + down; + r->width = lw; + r->height = MAX(rect1[i].height - (up + down), 0); + r++; + r->x = ((rect1[i].x + rect1[i].width) + pDrawable->x) - up; + r->y = (rect1[i].y + pDrawable->y) + down; + r->width = lw; + r->height = MAX(rect1[i].height - (up + down), 0); + r++; + r->x = (rect1[i].x + pDrawable->x) - up; + r->y = ((rect1[i].y + rect1[i].height) + pDrawable->y) - up; + r->width = rect1[i].width + up + down; + r->height = lw; + } + } + if (cd == 1) + { + if (regRects != 0) + { + rdpup_begin_update(); + if (pGC->lineStyle == LineSolid) + { + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + for (i = 0; i < nrects * 4; i++) + { + r = regRects + i; + rdpup_fill_rect(r->x, r->y, r->width, r->height); + } + rdpup_set_opcode(GXcopy); + } + else + { + for (i = 0; i < nrects * 4; i++) + { + r = regRects + i; + rdpup_send_area(&id, r->x, r->y, r->width, r->height); + } + } + rdpup_end_update(); + } + } + else if (cd == 2) + { + if (regRects != 0) + { + fill_reg = RegionFromRects(nrects * 4, regRects, CT_NONE); + RegionIntersect(&clip_reg, &clip_reg, fill_reg); + num_clips = REGION_NUM_RECTS(&clip_reg); + if (num_clips > 0) + { + rdpup_begin_update(); + if (pGC->lineStyle == LineSolid) + { + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + 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_set_opcode(GXcopy); + } + else + { + 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_end_update(); + } + RegionDestroy(fill_reg); + } + } + RegionUninit(&clip_reg); + g_free(regRects); + g_free(rect1); + rdpup_switch_os_surface(-1); +} diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.h b/xorg/X11R7.6/rdp/rdpPolyRectangle.h new file mode 100644 index 00000000..4bc6600e --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYRECTANGLE_H +#define __RDPPOLYRECTANGLE_H + +void +rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle* rects); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpPolySegment.c b/xorg/X11R7.6/rdp/rdpPolySegment.c new file mode 100644 index 00000000..223a5327 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolySegment.c @@ -0,0 +1,164 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +void +rdpPolySegmentOrg(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolySegment(pDrawable, pGC, nseg, pSegs); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs) +{ + RegionRec clip_reg; + int cd; + int i; + int j; + int got_id; + xSegment* segs; + BoxRec box; + struct image_data id; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + + LLOGLN(10, ("rdpPolySegment:")); + + segs = 0; + if (nseg) /* get the rects */ + { + segs = (xSegment*)g_malloc(nseg * sizeof(xSegment), 0); + for (i = 0; i < nseg; i++) + { + segs[i].x1 = pSegs[i].x1 + pDrawable->x; + segs[i].y1 = pSegs[i].y1 + pDrawable->y; + segs[i].x2 = pSegs[i].x2 + pDrawable->x; + segs[i].y2 = pSegs[i].y2 + pDrawable->y; + } + } + + /* do original call */ + rdpPolySegmentOrg(pDrawable, pGC, nseg, pSegs); + + got_id = 0; + if (pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDrawable; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDrawable->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDrawable; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + g_free(segs); + return; + } + + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDrawable, pGC); + if (cd == 1) /* no clip */ + { + if (segs != 0) + { + rdpup_begin_update(); + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + rdpup_set_pen(0, pGC->lineWidth); + for (i = 0; i < nseg; i++) + { + rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); + } + rdpup_set_opcode(GXcopy); + rdpup_end_update(); + } + } + else if (cd == 2) /* clip */ + { + if (segs != 0) + { + rdpup_begin_update(); + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + rdpup_set_pen(0, pGC->lineWidth); + for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + for (i = 0; i < nseg; i++) + { + rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); + } + } + rdpup_reset_clip(); + rdpup_set_opcode(GXcopy); + rdpup_end_update(); + } + } + g_free(segs); + RegionUninit(&clip_reg); + rdpup_switch_os_surface(-1); +} diff --git a/xorg/X11R7.6/rdp/rdpPolySegment.h b/xorg/X11R7.6/rdp/rdpPolySegment.h new file mode 100644 index 00000000..17bf0547 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolySegment.h @@ -0,0 +1,28 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYSEGMENT_H +#define __RDPPOLYSEGMENT_H + +void +rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpPolylines.c b/xorg/X11R7.6/rdp/rdpPolylines.c new file mode 100644 index 00000000..9f5ca7c3 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolylines.c @@ -0,0 +1,197 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +static void +rdpPolylinesOrg(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->Polylines(pDrawable, pGC, mode, npt, pptInit); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit) +{ + RegionRec clip_reg; + int num_clips; + int cd; + int i; + int j; + int x1; + int y1; + int x2; + int y2; + int got_id; + BoxRec box; + DDXPointPtr ppts; + struct image_data id; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + + LLOGLN(10, ("rdpPolylines:")); + + ppts = 0; + if (npt > 0) + { + ppts = (DDXPointPtr)g_malloc(sizeof(DDXPointRec) * npt, 0); + for (i = 0; i < npt; i++) + { + ppts[i] = pptInit[i]; + } + } + + /* do original call */ + rdpPolylinesOrg(pDrawable, pGC, mode, npt, pptInit); + + got_id = 0; + if (pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDrawable; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDrawable->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDrawable; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + g_free(ppts); + return; + } + + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDrawable, pGC); + if (cd == 1) + { + if (ppts != 0) + { + rdpup_begin_update(); + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + rdpup_set_pen(0, pGC->lineWidth); + x1 = ppts[0].x + pDrawable->x; + y1 = ppts[0].y + pDrawable->y; + for (i = 1; i < npt; i++) + { + if (mode == CoordModeOrigin) + { + x2 = pDrawable->x + ppts[i].x; + y2 = pDrawable->y + ppts[i].y; + } + else + { + x2 = x1 + ppts[i].x; + y2 = y1 + ppts[i].y; + } + rdpup_draw_line(x1, y1, x2, y2); + x1 = x2; + y1 = y2; + } + rdpup_set_opcode(GXcopy); + rdpup_end_update(); + } + } + else if (cd == 2) + { + num_clips = REGION_NUM_RECTS(&clip_reg); + if (ppts != 0 && num_clips > 0) + { + rdpup_begin_update(); + rdpup_set_fgcolor(pGC->fgPixel); + rdpup_set_opcode(pGC->alu); + rdpup_set_pen(0, pGC->lineWidth); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + x1 = ppts[0].x + pDrawable->x; + y1 = ppts[0].y + pDrawable->y; + for (i = 1; i < npt; i++) + { + if (mode == CoordModeOrigin) + { + x2 = pDrawable->x + ppts[i].x; + y2 = pDrawable->y + ppts[i].y; + } + else + { + x2 = x1 + ppts[i].x; + y2 = y1 + ppts[i].y; + } + rdpup_draw_line(x1, y1, x2, y2); + x1 = x2; + y1 = y2; + } + } + rdpup_reset_clip(); + rdpup_set_opcode(GXcopy); + rdpup_end_update(); + } + } + RegionUninit(&clip_reg); + g_free(ppts); + rdpup_switch_os_surface(-1); +} diff --git a/xorg/X11R7.6/rdp/rdpPolylines.h b/xorg/X11R7.6/rdp/rdpPolylines.h new file mode 100644 index 00000000..fd98439a --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPolylines.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYLINES_H +#define __RDPPOLYLINES_H + +void +rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpPutImage.c b/xorg/X11R7.6/rdp/rdpPutImage.c new file mode 100644 index 00000000..7a132f8c --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPutImage.c @@ -0,0 +1,130 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#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 rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +/******************************************************************************/ +static void +rdpPutImageOrg(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char* pBits) +{ + rdpGCPtr priv; + GCFuncs* oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PutImage(pDst, pGC, depth, x, y, w, h, leftPad, + format, pBits); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char* pBits) +{ + RegionRec clip_reg; + int cd; + int j; + int got_id; + BoxRec box; + struct image_data id; + + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + + LLOGLN(10, ("rdpPutImage:")); + LLOGLN(10, ("rdpPutImage: drawable id 0x%x", pDst->id)); + + /* do original call */ + rdpPutImageOrg(pDst, pGC, depth, x, y, w, h, leftPad, format, pBits); + got_id = 0; + if (pDst->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)pDst; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_switch_os_surface(pDstPriv->rdpid); + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + } + } + else + { + if (pDst->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)pDst; + if (pDstWnd->viewable) + { + rdpup_get_screen_image_rect(&id); + got_id = 1; + } + } + } + if (!got_id) + { + return; + } + RegionInit(&clip_reg, NullBox, 0); + cd = rdp_get_clip(&clip_reg, pDst, pGC); + if (cd == 1) + { + rdpup_begin_update(); + rdpup_send_area(&id, pDst->x + x, pDst->y + y, w, h); + rdpup_end_update(); + } + else if (cd == 2) + { + rdpup_begin_update(); + for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) + { + box = REGION_RECTS(&clip_reg)[j]; + rdpup_set_clip(box.x1, box.y1, (box.x2 - box.x1), (box.y2 - box.y1)); + rdpup_send_area(&id, pDst->x + x, pDst->y + y, w, h); + } + rdpup_reset_clip(); + rdpup_end_update(); + } + RegionUninit(&clip_reg); + rdpup_switch_os_surface(-1); +} diff --git a/xorg/X11R7.6/rdp/rdpPutImage.h b/xorg/X11R7.6/rdp/rdpPutImage.h new file mode 100644 index 00000000..94119a81 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpPutImage.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPUTIMAGE_H +#define __RDPPUTIMAGE_H + +void +rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char* pBits); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 9dba7c02..a0c83cd8 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -23,6 +23,14 @@ Xserver drawing ops and funcs #include "rdp.h" #include "gcops.h" +#include "rdpdraw.h" + +#include "rdpCopyArea.h" +#include "rdpPolyFillRect.h" +#include "rdpPutImage.h" +#include "rdpPolyRectangle.h" +#include "rdpPolylines.h" +#include "rdpPolySegment.h" #if 1 #define DEBUG_OUT_FUNCS(arg) @@ -41,13 +49,13 @@ extern ScreenPtr g_pScreen; /* from rdpmain.c */ ColormapPtr g_rdpInstalledColormap; -static GCFuncs g_rdpGCFuncs = +GCFuncs g_rdpGCFuncs = { rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip, rdpDestroyClip, rdpCopyClip }; -static GCOps g_rdpGCOps = +GCOps g_rdpGCOps = { rdpFillSpans, rdpSetSpans, rdpPutImage, rdpCopyArea, rdpCopyPlane, rdpPolyPoint, rdpPolylines, rdpPolySegment, rdpPolyRectangle, @@ -60,7 +68,7 @@ static GCOps g_rdpGCOps = /* return 0, draw nothing */ /* return 1, draw with no clip */ /* return 2, draw using clip */ -static int +int rdp_get_clip(RegionPtr pRegion, DrawablePtr pDrawable, GCPtr pGC) { WindowPtr pWindow; @@ -331,7 +339,7 @@ rdpFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -343,7 +351,7 @@ rdpFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -375,7 +383,7 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char* psrc, for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -387,160 +395,14 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char* psrc, for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - rdpup_end_update(); - } - RegionUninit(&clip_reg); - GC_OP_EPILOGUE(pGC); -} - -/******************************************************************************/ -static void -rdpPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, - int w, int h, int leftPad, int format, char* pBits) -{ - rdpGCPtr priv; - RegionRec clip_reg; - int cd; - int j; - GCFuncs* oldFuncs; - BoxRec box; - - DEBUG_OUT_OPS(("in rdpPutImage\n")); - GC_OP_PROLOGUE(pGC); - pGC->ops->PutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, - format, pBits); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDrawable, pGC); - if (cd == 1) - { - rdpup_begin_update(); - rdpup_send_area(pDrawable->x + x, pDrawable->y + y, w, h); - rdpup_end_update(); - } - else if (cd == 2) - { - rdpup_begin_update(); - for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_set_clip(box.x1, box.y1, (box.x2 - box.x1), (box.y2 - box.y1)); - rdpup_send_area(pDrawable->x + x, pDrawable->y + y, w, h); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } - rdpup_reset_clip(); rdpup_end_update(); } RegionUninit(&clip_reg); GC_OP_EPILOGUE(pGC); } -/******************************************************************************/ -static RegionPtr -rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - rdpGCPtr priv; - RegionPtr rv; - RegionRec clip_reg; - RegionRec box_reg; - int num_clips; - int cd; - int j; - int can_do_screen_blt; - int dx; - int dy; - BoxRec box; - BoxPtr pbox; - GCFuncs* oldFuncs; - - DEBUG_OUT_OPS(("in rdpCopyArea\n")); - GC_OP_PROLOGUE(pGC); - rv = pGC->ops->CopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDst, pGC); - can_do_screen_blt = pSrc->type == DRAWABLE_WINDOW && - ((WindowPtr)pSrc)->viewable && - pGC->alu == GXcopy; - if (cd == 1) - { - rdpup_begin_update(); - if (can_do_screen_blt) - { - rdpup_screen_blt(pDst->x + dstx, pDst->y + dsty, w, h, - pSrc->x + srcx, pSrc->y + srcy); - } - else - { - rdpup_send_area(pDst->x + dstx, pDst->y + dsty, w, h); - } - rdpup_end_update(); - } - else if (cd == 2) - { - num_clips = REGION_NUM_RECTS(&clip_reg); - if (num_clips > 0) - { - rdpup_begin_update(); - if (can_do_screen_blt) - { - dx = dstx - srcx; - dy = dsty - srcy; - if (dy < 0 || (dy == 0 && dx < 0)) - { - for (j = 0; j < num_clips; j++) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - rdpup_screen_blt(pDst->x + dstx, pDst->y + dsty, w, h, - pSrc->x + srcx, pSrc->y + srcy); - } - } - else - { - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - rdpup_screen_blt(pDst->x + dstx, pDst->y + dsty, w, h, - pSrc->x + srcx, pSrc->y + srcy); - } - } - rdpup_reset_clip(); - } - else - { - box.x1 = pDst->x + dstx; - box.y1 = pDst->y + dsty; - box.x2 = box.x1 + w; - box.y2 = box.y1 + h; - RegionInit(&box_reg, &box, 0); - RegionIntersect(&clip_reg, &clip_reg, &box_reg); - num_clips = REGION_NUM_RECTS(&clip_reg); - if (num_clips < 10) - { - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - } - else - { - pbox = RegionExtents(&clip_reg); - rdpup_send_area(pbox->x1, pbox->y1, pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - } - RegionUninit(&box_reg); - } - rdpup_end_update(); - } - } - RegionUninit(&clip_reg); - GC_OP_EPILOGUE(pGC); - return rv; -} - /******************************************************************************/ static RegionPtr rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, @@ -567,7 +429,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(pDst->x + dstx, pDst->y + dsty, w, h); + rdpup_send_area(0, pDst->x + dstx, pDst->y + dsty, w, h); rdpup_end_update(); } else if (cd == 2) @@ -588,13 +450,13 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } } else { pbox = RegionExtents(&clip_reg); - rdpup_send_area(pbox->x1, pbox->y1, pbox->x2 - pbox->x1, + rdpup_send_area(0, pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); } RegionUninit(&box_reg); @@ -715,319 +577,6 @@ rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, GC_OP_EPILOGUE(pGC); } -/******************************************************************************/ -static void -rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, - int npt, DDXPointPtr pptInit) -{ - rdpGCPtr priv; - RegionRec clip_reg; - int num_clips; - int cd; - int i; - int j; - int x1; - int y1; - int x2; - int y2; - GCFuncs* oldFuncs; - BoxRec box; - DDXPointPtr ppts; - - DEBUG_OUT_OPS(("in rdpPolylines\n")); - GC_OP_PROLOGUE(pGC); - ppts = 0; - if (npt > 0) - { - ppts = (DDXPointPtr)g_malloc(sizeof(DDXPointRec) * npt, 0); - for (i = 0; i < npt; i++) - { - ppts[i] = pptInit[i]; - } - } - pGC->ops->Polylines(pDrawable, pGC, mode, npt, pptInit); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDrawable, pGC); - if (cd == 1) - { - if (ppts != 0) - { - rdpup_begin_update(); - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - rdpup_set_pen(0, pGC->lineWidth); - x1 = ppts[0].x + pDrawable->x; - y1 = ppts[0].y + pDrawable->y; - for (i = 1; i < npt; i++) - { - if (mode == CoordModeOrigin) - { - x2 = pDrawable->x + ppts[i].x; - y2 = pDrawable->y + ppts[i].y; - } - else - { - x2 = x1 + ppts[i].x; - y2 = y1 + ppts[i].y; - } - rdpup_draw_line(x1, y1, x2, y2); - x1 = x2; - y1 = y2; - } - rdpup_set_opcode(GXcopy); - rdpup_end_update(); - } - } - else if (cd == 2) - { - num_clips = REGION_NUM_RECTS(&clip_reg); - if (ppts != 0 && num_clips > 0) - { - rdpup_begin_update(); - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - rdpup_set_pen(0, pGC->lineWidth); - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - x1 = ppts[0].x + pDrawable->x; - y1 = ppts[0].y + pDrawable->y; - for (i = 1; i < npt; i++) - { - if (mode == CoordModeOrigin) - { - x2 = pDrawable->x + ppts[i].x; - y2 = pDrawable->y + ppts[i].y; - } - else - { - x2 = x1 + ppts[i].x; - y2 = y1 + ppts[i].y; - } - rdpup_draw_line(x1, y1, x2, y2); - x1 = x2; - y1 = y2; - } - } - rdpup_reset_clip(); - rdpup_set_opcode(GXcopy); - rdpup_end_update(); - } - } - RegionUninit(&clip_reg); - g_free(ppts); - GC_OP_EPILOGUE(pGC); -} - -/******************************************************************************/ -static void -rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs) -{ - rdpGCPtr priv; - RegionRec clip_reg; - int cd; - int i; - int j; - GCFuncs* oldFuncs; - xSegment* segs; - BoxRec box; - - DEBUG_OUT_OPS(("in rdpPolySegment\n")); - GC_OP_PROLOGUE(pGC); - segs = 0; - if (nseg) /* get the rects */ - { - segs = (xSegment*)g_malloc(nseg * sizeof(xSegment), 0); - for (i = 0; i < nseg; i++) - { - segs[i].x1 = pSegs[i].x1 + pDrawable->x; - segs[i].y1 = pSegs[i].y1 + pDrawable->y; - segs[i].x2 = pSegs[i].x2 + pDrawable->x; - segs[i].y2 = pSegs[i].y2 + pDrawable->y; - } - } - pGC->ops->PolySegment(pDrawable, pGC, nseg, pSegs); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDrawable, pGC); - if (cd == 1) /* no clip */ - { - if (segs != 0) - { - rdpup_begin_update(); - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - rdpup_set_pen(0, pGC->lineWidth); - for (i = 0; i < nseg; i++) - { - rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); - } - rdpup_set_opcode(GXcopy); - rdpup_end_update(); - } - } - else if (cd == 2) /* clip */ - { - if (segs != 0) - { - rdpup_begin_update(); - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - rdpup_set_pen(0, pGC->lineWidth); - for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - for (i = 0; i < nseg; i++) - { - rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); - } - } - rdpup_reset_clip(); - rdpup_set_opcode(GXcopy); - rdpup_end_update(); - } - } - g_free(segs); - RegionUninit(&clip_reg); - GC_OP_EPILOGUE(pGC); -} - -/******************************************************************************/ -/* tested with pGC->lineWidth = 0, 1, 2, 4 and opcodes 3 and 6 */ -static void -rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, - xRectangle* rects) -{ - rdpGCPtr priv; - RegionRec clip_reg; - RegionPtr fill_reg; - int num_clips; - int cd; - int lw; - int i; - int j; - int up; - int down; - GCFuncs* oldFuncs; - xRectangle* regRects; - xRectangle* r; - xRectangle* rect1; - BoxRec box; - - DEBUG_OUT_OPS(("in rdpPolyRectangle\n")); - GC_OP_PROLOGUE(pGC); - /* make a copy of rects */ - rect1 = (xRectangle*)g_malloc(sizeof(xRectangle) * nrects, 0); - for (i = 0; i < nrects; i++) - { - rect1[i] = rects[i]; - } - pGC->ops->PolyRectangle(pDrawable, pGC, nrects, rects); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDrawable, pGC); - regRects = 0; - if (cd != 0 && nrects > 0) - { - regRects = (xRectangle*)g_malloc(nrects * 4 * sizeof(xRectangle), 0); - lw = pGC->lineWidth; - if (lw < 1) - { - lw = 1; - } - up = lw / 2; - down = 1 + (lw - 1) / 2; - for (i = 0; i < nrects; i++) - { - r = regRects + i * 4; - r->x = (rect1[i].x + pDrawable->x) - up; - r->y = (rect1[i].y + pDrawable->y) - up; - r->width = rect1[i].width + up + down; - r->height = lw; - r++; - r->x = (rect1[i].x + pDrawable->x) - up; - r->y = (rect1[i].y + pDrawable->y) + down; - r->width = lw; - r->height = MAX(rect1[i].height - (up + down), 0); - r++; - r->x = ((rect1[i].x + rect1[i].width) + pDrawable->x) - up; - r->y = (rect1[i].y + pDrawable->y) + down; - r->width = lw; - r->height = MAX(rect1[i].height - (up + down), 0); - r++; - r->x = (rect1[i].x + pDrawable->x) - up; - r->y = ((rect1[i].y + rect1[i].height) + pDrawable->y) - up; - r->width = rect1[i].width + up + down; - r->height = lw; - } - } - if (cd == 1) - { - if (regRects != 0) - { - rdpup_begin_update(); - if (pGC->lineStyle == LineSolid) - { - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - for (i = 0; i < nrects * 4; i++) - { - r = regRects + i; - rdpup_fill_rect(r->x, r->y, r->width, r->height); - } - rdpup_set_opcode(GXcopy); - } - else - { - for (i = 0; i < nrects * 4; i++) - { - r = regRects + i; - rdpup_send_area(r->x, r->y, r->width, r->height); - } - } - rdpup_end_update(); - } - } - else if (cd == 2) - { - if (regRects != 0) - { - fill_reg = RegionFromRects(nrects * 4, regRects, CT_NONE); - RegionIntersect(&clip_reg, &clip_reg, fill_reg); - num_clips = REGION_NUM_RECTS(&clip_reg); - if (num_clips > 0) - { - rdpup_begin_update(); - if (pGC->lineStyle == LineSolid) - { - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - 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_set_opcode(GXcopy); - } - else - { - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - } - rdpup_end_update(); - } - RegionDestroy(fill_reg); - } - } - RegionUninit(&clip_reg); - g_free(regRects); - g_free(rect1); - GC_OP_EPILOGUE(pGC); -} - /******************************************************************************/ static void rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) @@ -1079,7 +628,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1099,7 +648,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1176,7 +725,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1190,7 +739,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1200,108 +749,6 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, GC_OP_EPILOGUE(pGC); } -/******************************************************************************/ -static void -rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, - xRectangle* prectInit) -{ - int i; - int j; - int cd; - int num_clips; - xRectangle* copy_of_rects; - rdpGCPtr priv; - RegionRec clip_reg; - RegionPtr fill_reg; - BoxRec box; - GCFuncs* oldFuncs; - - DEBUG_OUT_OPS(("in rdpPolyFillRect\n")); - GC_OP_PROLOGUE(pGC); - /* make a copy of rects */ - copy_of_rects = (xRectangle*)g_malloc(sizeof(xRectangle) * nrectFill, 0); - for (i = 0; i < nrectFill; i++) - { - copy_of_rects[i] = prectInit[i]; - } - fill_reg = RegionFromRects(nrectFill, copy_of_rects, CT_NONE); - g_free(copy_of_rects); - RegionTranslate(fill_reg, pDrawable->x, pDrawable->y); - pGC->ops->PolyFillRect(pDrawable, pGC, nrectFill, prectInit); - RegionInit(&clip_reg, NullBox, 0); - cd = rdp_get_clip(&clip_reg, pDrawable, pGC); - if (cd == 1) /* no clip */ - { - rdpup_begin_update(); - if (pGC->fillStyle == 0 && /* solid fill */ - (pGC->alu == GXclear || - pGC->alu == GXset || - pGC->alu == GXinvert || - pGC->alu == GXnoop || - pGC->alu == GXand || - pGC->alu == GXcopy /*|| - pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ - { - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - 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_set_opcode(GXcopy); - } - else /* non solid fill */ - { - for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--) - { - box = REGION_RECTS(fill_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - } - rdpup_end_update(); - } - else if (cd == 2) /* clip */ - { - RegionIntersect(&clip_reg, &clip_reg, fill_reg); - num_clips = REGION_NUM_RECTS(&clip_reg); - if (num_clips > 0) - { - rdpup_begin_update(); - if (pGC->fillStyle == 0 && /* solid fill */ - (pGC->alu == GXclear || - pGC->alu == GXset || - pGC->alu == GXinvert || - pGC->alu == GXnoop || - pGC->alu == GXand || - pGC->alu == GXcopy /*|| - pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ - { - rdpup_set_fgcolor(pGC->fgPixel); - rdpup_set_opcode(pGC->alu); - 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_set_opcode(GXcopy); - } - else /* non solid fill */ - { - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - } - rdpup_end_update(); - } - } - RegionUninit(&clip_reg); - RegionDestroy(fill_reg); - GC_OP_EPILOGUE(pGC); -} - /******************************************************************************/ static void rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) @@ -1353,7 +800,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1373,7 +820,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1419,7 +866,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1433,7 +880,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1478,7 +925,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1492,7 +939,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1536,7 +983,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1550,7 +997,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1594,7 +1041,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1608,7 +1055,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1652,7 +1099,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1666,7 +1113,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1712,7 +1159,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) @@ -1726,7 +1173,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1759,7 +1206,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, if (cd == 1) { rdpup_begin_update(); - rdpup_send_area(x, y, w, h); + rdpup_send_area(0, x, y, w, h); rdpup_end_update(); } else if (cd == 2) @@ -1773,7 +1220,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -1994,7 +1441,7 @@ rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h, for (j = REGION_NUM_RECTS(®) - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); RegionUninit(®); @@ -2020,7 +1467,7 @@ rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed) for (j = REGION_NUM_RECTS(®) - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); RegionUninit(®); @@ -2130,7 +1577,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®1)[j]; - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } @@ -2144,7 +1591,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, box.x2 = box.x1 + width; box.y2 = box.y1 + height; rdpup_begin_update(); - rdpup_send_area(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } } diff --git a/xorg/X11R7.6/rdp/rdpdraw.h b/xorg/X11R7.6/rdp/rdpdraw.h new file mode 100644 index 00000000..0a1569e8 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpdraw.h @@ -0,0 +1,45 @@ +/* +Copyright 2005-2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPDRAW_H +#define __RDPDRAW_H + +/******************************************************************************/ +#define GC_OP_PROLOGUE(_pGC) \ +{ \ + priv = (rdpGCPtr)dixGetPrivateAddr(&(pGC->devPrivates), &g_rdpGCIndex); \ + oldFuncs = _pGC->funcs; \ + (_pGC)->funcs = priv->funcs; \ + (_pGC)->ops = priv->ops; \ +} + +/******************************************************************************/ +#define GC_OP_EPILOGUE(_pGC) \ +{ \ + priv->ops = (_pGC)->ops; \ + (_pGC)->funcs = oldFuncs; \ + (_pGC)->ops = &g_rdpGCOps; \ +} + +int +rdp_get_clip(RegionPtr pRegion, DrawablePtr pDrawable, GCPtr pGC); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 4154ac9c..5d0049d3 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -27,6 +27,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DEBUG_OUT_UP(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) + +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; @@ -46,6 +54,8 @@ static int g_cursor_y = 0; static OsTimerPtr g_timer = 0; static int g_scheduled = 0; static int g_count = 0; +static int g_rdpid = -1; + extern ScreenPtr g_pScreen; /* from rdpmain.c */ extern int g_Bpp; /* from rdpmain.c */ extern int g_Bpp_mask; /* from rdpmain.c */ @@ -171,6 +181,23 @@ rdpup_send_msg(struct stream* s) return rv; } +/******************************************************************************/ +static int +rdpup_send_pending(void) +{ + 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; + return 0; +} + /******************************************************************************/ static CARD32 rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) @@ -483,7 +510,7 @@ param4 %d\n", msg, param1, param2, param3, param4)); break; case 200: rdpup_begin_update(); - rdpup_send_area((param1 >> 16) & 0xffff, param1 & 0xffff, + rdpup_send_area(0, (param1 >> 16) & 0xffff, param1 & 0xffff, (param2 >> 16) & 0xffff, param2 & 0xffff); rdpup_end_update(); break; @@ -521,6 +548,30 @@ param4 %d\n", msg, param1, param2, param3, param4)); return 0; } +/******************************************************************************/ +void +rdpup_get_screen_image_rect(struct image_data* id) +{ + id->width = g_rdpScreen.width; + id->height = g_rdpScreen.height; + id->bpp = g_rdpScreen.rdp_bpp; + id->Bpp = g_rdpScreen.rdp_Bpp; + id->lineBytes = g_rdpScreen.paddedWidthInBytes; + id->pixels = g_rdpScreen.pfbMemory; +} + +/******************************************************************************/ +void +rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data* id) +{ + id->width = pPixmap->drawable.width; + id->height = pPixmap->drawable.height; + id->bpp = g_rdpScreen.rdp_bpp; + id->Bpp = g_rdpScreen.rdp_Bpp; + id->lineBytes = id->width * id->Bpp; + id->pixels = (char*)(pPixmap->devPrivate.ptr); +} + /******************************************************************************/ int rdpup_init(void) @@ -631,6 +682,7 @@ rdpup_check(void) g_connected = 1; g_sck_closed = 0; g_begin = 0; + g_con_number++; AddEnabledDevice(g_sck); } } @@ -1031,6 +1083,70 @@ rdpup_set_cursor(short x, short y, char* cur_data, char* cur_mask) return 0; } +/******************************************************************************/ +int +rdpup_create_os_surface(int rdpid, int width, int height) +{ + if (g_connected) + { + DEBUG_OUT_UP((" rdpup_create_os_surface\n")); + rdpup_pre_check(10); + out_uint16_le(g_out_s, 20); + g_count++; + out_uint32_le(g_out_s, rdpid); + out_uint16_le(g_out_s, width); + out_uint16_le(g_out_s, height); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_switch_os_surface(int rdpid) +{ + LLOGLN(10, ("rdpup_switch_os_surface:")); + if (g_connected) + { + if (g_rdpid == rdpid) + { + return 0; + } + g_rdpid = rdpid; + rdpup_send_pending(); + LLOGLN(0, ("rdpup_switch_os_surface: rdpid %d", rdpid)); + + /* switch surface */ + out_uint16_le(g_out_s, 21); + out_uint32_le(g_out_s, rdpid); + + /* begin update */ + out_uint16_le(g_out_s, 1); + g_begin = 1; + g_count = 2; + + } + return 0; +} + +/******************************************************************************/ +int +rdpup_delete_os_surface(int rdpid) +{ + if (g_connected) + { + DEBUG_OUT_UP((" rdpup_delete_os_surface\n")); + //if (g_current_surface == rdpid) + //{ + // g_current_surface = -1; + //} + rdpup_pre_check(6); + out_uint16_le(g_out_s, 22); + g_count++; + out_uint32_le(g_out_s, rdpid); + } + return 0; +} + /******************************************************************************/ static int get_single_color(int x, int y, int w, int h) @@ -1111,7 +1227,7 @@ get_single_color(int x, int y, int w, int h) /******************************************************************************/ /* split the bitmap up into 64 x 64 pixel areas */ void -rdpup_send_area(int x, int y, int w, int h) +rdpup_send_area(struct image_data* id, int x, int y, int w, int h) { char* s; int i; @@ -1205,3 +1321,23 @@ rdpup_send_area(int x, int y, int w, int h) } } } + +/******************************************************************************/ +void +rdpup_paint_rect_os(int x, int y, int cx, int cy, + int rdpid, int srcx, int srcy) +{ + if (g_connected) + { + rdpup_pre_check(18); + out_uint16_le(g_out_s, 23); + g_count++; + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, cx); + out_uint16_le(g_out_s, cy); + out_uint32_le(g_out_s, rdpid); + out_uint16_le(g_out_s, srcx); + out_uint16_le(g_out_s, srcy); + } +}