diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2013-09-26 11:28:07 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2013-09-26 11:28:07 -0700 |
commit | c1b7cbd6571b5cb71ddf59014273a189ffa32f66 (patch) | |
tree | 1c8363f3f6521aaa1d83a262e3ce2c75bce63477 /xorg/X11R7.6/rdp | |
parent | 5e005bf26ce965350cac7f942678031d5482d867 (diff) | |
parent | b857a69332933244838fcbcfdfe4688953d149f9 (diff) | |
download | xrdp-proprietary-c1b7cbd6571b5cb71ddf59014273a189ffa32f66.tar.gz xrdp-proprietary-c1b7cbd6571b5cb71ddf59014273a189ffa32f66.zip |
merges from authentic8
Diffstat (limited to 'xorg/X11R7.6/rdp')
26 files changed, 2744 insertions, 274 deletions
diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index e40b7473..3b84c43c 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -13,7 +13,7 @@ rdpPolylines.o rdpPolySegment.o rdpFillSpans.o rdpSetSpans.o \ rdpCopyPlane.o rdpPolyPoint.o rdpPolyArc.o rdpFillPolygon.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o \ rdpImageText8.o rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o \ -rdpPushPixels.o rdpxv.o \ +rdpPushPixels.o rdpxv.o rdpglyph.o rdpComposite.o \ miinitext.o \ fbcmap_mi.o @@ -43,7 +43,7 @@ LIBS = $(XSRCBASE)/dbe/.libs/libdbe.a \ LLIBS = -Wl,-rpath=$(LIBBASE) -lfreetype -lz -lm -lXfont -lXau \ -lXdmcp -lpixman-1 -lrt -ldl -lcrypto -lGL -lXdamage -CFLAGS = -O2 -Wall -fno-strength-reduce \ +CFLAGS = -g -O2 -Wall -fno-strength-reduce \ -I../../include \ -I../../cfb \ -I../../mfb \ diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 91f50c26..63c7436a 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -95,6 +95,23 @@ 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)) +#define TAG_COMPOSITE 0 +#define TAG_COPYAREA 1 +#define TAG_POLYFILLRECT 2 +#define TAG_PUTIMAGE 3 +#define TAG_POLYRECTANGLE 4 +#define TAG_COPYPLANE 5 +#define TAG_POLYARC 6 +#define TAG_FILLPOLYGON 7 +#define TAG_POLYFILLARC 8 +#define TAG_IMAGETEXT8 9 +#define TAG_POLYTEXT8 10 +#define TAG_POLYTEXT16 11 +#define TAG_IMAGETEXT16 12 +#define TAG_IMAGEGLYPHBLT 13 +#define TAG_POLYGLYPHBLT 14 +#define TAG_PUSHPIXELS 15 + struct image_data { int width; @@ -118,7 +135,9 @@ struct _rdpScreenInfoRec int height; int depth; int bitsPerPixel; - int sizeInBytes; + int sizeInBytes; /* size of current used frame buffer */ + int sizeInBytesAlloc; /* size of current alloc frame buffer, + always >= sizeInBytes */ char* pfbMemory; Pixel blackPixel; Pixel whitePixel; @@ -146,6 +165,8 @@ struct _rdpScreenInfoRec CopyWindowProcPtr CopyWindow; ClearToBackgroundProcPtr ClearToBackground; ScreenWakeupHandlerProcPtr WakeupHandler; + CreatePictureProcPtr CreatePicture; + DestroyPictureProcPtr DestroyPicture; CompositeProcPtr Composite; GlyphsProcPtr Glyphs; /* Backing store procedures */ @@ -202,6 +223,7 @@ typedef rdpWindowRec* rdpWindowPtr; #define RDI_IMGLY 3 /* lossy */ #define RDI_LINE 4 #define RDI_SCRBLT 5 +#define RDI_TEXT 6 struct urdp_draw_item_fill { @@ -238,17 +260,25 @@ struct urdp_draw_item_scrblt int cy; }; +struct urdp_draw_item_text +{ + int opcode; + int fg_color; + struct rdp_text* rtext; /* in rdpglyph.h */ +}; + union urdp_draw_item { struct urdp_draw_item_fill fill; struct urdp_draw_item_img img; struct urdp_draw_item_line line; struct urdp_draw_item_scrblt scrblt; + struct urdp_draw_item_text text; }; struct rdp_draw_item { - int type; + int type; /* RDI_FILL, RDI_IMGLL, ... */ int flags; struct rdp_draw_item* prev; struct rdp_draw_item* next; @@ -265,6 +295,11 @@ struct _rdpPixmapRec int con_number; int is_dirty; int is_scratch; + int is_alpha_dirty_not; + /* number of times used in a remote operation + if this gets above XRDP_USE_COUNT_THRESHOLD + then we force remote the pixmap */ + int use_count; int kind_width; /* number of times used in a remote operation if this gets above XRDP_USE_COUNT_THRESHOLD @@ -335,6 +370,8 @@ void hexdump(unsigned char *p, unsigned int len); void RegionAroundSegs(RegionPtr reg, xSegment* segs, int nseg); +int +get_crc(char* data, int data_bytes); /* rdpdraw.c */ Bool @@ -363,6 +400,9 @@ int draw_item_add_srcblt_region(rdpPixmapRec* priv, RegionPtr reg, int srcx, int srcy, int dstx, int dsty, int cx, int cy); +int +draw_item_add_text_region(rdpPixmapRec* priv, RegionPtr reg, int color, + int opcode, struct rdp_text* rtext); PixmapPtr rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, @@ -421,15 +461,19 @@ rdpDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor); void rdpRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); + +/* rdpglyph.c */ +/* look in rdpglyph.h */ + +/* rdpComposite.c */ +int +rdpCreatePicture(PicturePtr pPicture); +void +rdpDestroyPicture(PicturePtr pPicture); void rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, - GlyphPtr* glyphs); /* rdpinput.c */ int @@ -516,6 +560,8 @@ rdpup_set_cursor_ex(short x, short y, char *cur_data, char *cur_mask, int bpp); int rdpup_create_os_surface(int rdpindexd, int width, int height); int +rdpup_create_os_surface_bpp(int rdpindexd, int width, int height, int bpp); +int rdpup_switch_os_surface(int rdpindex); int rdpup_delete_os_surface(int rdpindex); @@ -532,7 +578,29 @@ rdpup_delete_window(WindowPtr pWindow, rdpWindowRec* priv); int rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv); int +rdpup_check_alpha_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv); +int rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv); +int +rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes); +int +rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes); +int +rdpup_draw_text(int font, int flags, int mixmode, + short clip_left, short clip_top, + short clip_right, short clip_bottom, + short box_left, short box_top, + short box_right, short box_bottom, short x, short y, + char* data, int data_bytes); +int +rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, + PictTransform* srctransform, CARD8 mskflags, + short mskidx, int mskformat, short mskwidth, CARD8 mskrepeat, + CARD8 op, short srcx, short srcy, short mskx, short msky, + short dstx, short dsty, short width, short height, + int dstformat); void rdpScheduleDeferredUpdate(void); @@ -604,6 +672,13 @@ struct stream #endif /******************************************************************************/ +#define out_uint8(s, v) \ +{ \ + *((s)->p) = (unsigned char)((v) >> 0); \ + (s)->p++; \ +} + +/******************************************************************************/ #define init_stream(s, v) \ { \ if ((v) > (s)->size) \ @@ -631,6 +706,13 @@ struct stream } /******************************************************************************/ +#define out_uint8s(s, n) do \ +{ \ + memset((s)->p, 0, (n)); \ + (s)->p += (n); \ +} while (0) + +/******************************************************************************/ #if defined(B_ENDIAN) || defined(NEED_ALIGN) #define out_uint32_le(s, v) \ { \ diff --git a/xorg/X11R7.6/rdp/rdpComposite.c b/xorg/X11R7.6/rdp/rdpComposite.c new file mode 100644 index 00000000..57661520 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpComposite.c @@ -0,0 +1,835 @@ +/* + Copyright 2012-2013 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 int g_can_do_pix_to_pix; /* from rdpmain.c */ +extern int g_do_dirty_os; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ +extern int g_doing_font; /* in rdpmain.c */ +extern int g_do_composite; /* in rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +extern int g_crc_seed; /* in rdpmisc.c */ +extern int g_crc_table[]; /* in rdpmisc.c */ + +/******************************************************************************/ +int +rdpCreatePicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + int rv; + + LLOGLN(10, ("rdpCreatePicture:")); + ps = GetPictureScreen(g_pScreen); + ps->CreatePicture = g_rdpScreen.CreatePicture; + rv = ps->CreatePicture(pPicture); + ps->CreatePicture = rdpCreatePicture; + return rv; +} + +/******************************************************************************/ +void +rdpDestroyPicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + + LLOGLN(10, ("rdpDestroyPicture:")); + ps = GetPictureScreen(g_pScreen); + ps->DestroyPicture = g_rdpScreen.DestroyPicture; + ps->DestroyPicture(pPicture); + ps->DestroyPicture = rdpDestroyPicture; +} + +/******************************************************************************/ +static int +print_format(PictFormatShort format) +{ + switch (format) + { + case PIXMAN_a2r10g10b10: + LLOGLN(0, (" PIXMAN_x2r10g10b10")); + break; + case PIXMAN_x2r10g10b10: + LLOGLN(0, (" PIXMAN_x2r10g10b10")); + break; + case PIXMAN_a2b10g10r10: + LLOGLN(0, (" PIXMAN_a2b10g10r10")); + break; + case PIXMAN_x2b10g10r10: + LLOGLN(0, (" PIXMAN_x2b10g10r10")); + break; + + case PIXMAN_a8r8g8b8: + LLOGLN(0, (" PIXMAN_a8r8g8b8")); + break; + case PIXMAN_x8r8g8b8: + LLOGLN(0, (" PIXMAN_x8r8g8b8")); + break; + case PIXMAN_a8b8g8r8: + LLOGLN(0, (" PIXMAN_a8b8g8r8")); + break; + case PIXMAN_x8b8g8r8: + LLOGLN(0, (" PIXMAN_x8b8g8r8")); + break; + case PIXMAN_b8g8r8a8: + LLOGLN(0, (" PIXMAN_b8g8r8a8")); + break; + case PIXMAN_b8g8r8x8: + LLOGLN(0, (" PIXMAN_b8g8r8x8")); + break; + + /* 24bpp formats */ + case PIXMAN_r8g8b8: + LLOGLN(0, (" PIXMAN_r8g8b8")); + break; + case PIXMAN_b8g8r8: + LLOGLN(0, (" PIXMAN_b8g8r8")); + break; + + /* 16bpp formats */ + case PIXMAN_r5g6b5: + LLOGLN(0, (" PIXMAN_r5g6b5")); + break; + case PIXMAN_b5g6r5: + LLOGLN(0, (" PIXMAN_b5g6r5")); + break; + + case PIXMAN_a1r5g5b5: + LLOGLN(0, (" PIXMAN_a1r5g5b5")); + break; + case PIXMAN_x1r5g5b5: + LLOGLN(0, (" PIXMAN_x1r5g5b5")); + break; + case PIXMAN_a1b5g5r5: + LLOGLN(0, (" PIXMAN_a1b5g5r5")); + break; + case PIXMAN_x1b5g5r5: + LLOGLN(0, (" PIXMAN_x1b5g5r5")); + break; + case PIXMAN_a4r4g4b4: + LLOGLN(0, (" PIXMAN_a4r4g4b4")); + break; + case PIXMAN_x4r4g4b4: + LLOGLN(0, (" PIXMAN_x4r4g4b4")); + break; + case PIXMAN_a4b4g4r4: + LLOGLN(0, (" PIXMAN_a4b4g4r4")); + break; + case PIXMAN_x4b4g4r4: + LLOGLN(0, (" PIXMAN_x4b4g4r4")); + break; + + /* 8bpp formats */ + case PIXMAN_a8: + LLOGLN(0, (" PIXMAN_a8")); + break; + case PIXMAN_r3g3b2: + LLOGLN(0, (" PIXMAN_r3g3b2")); + break; + case PIXMAN_b2g3r3: + LLOGLN(0, (" PIXMAN_b2g3r3")); + break; + case PIXMAN_a2r2g2b2: + LLOGLN(0, (" PIXMAN_a2r2g2b2")); + break; + case PIXMAN_a2b2g2r2: + LLOGLN(0, (" PIXMAN_a2b2g2r2")); + break; + + case PIXMAN_c8: + LLOGLN(0, (" PIXMAN_c8")); + break; + case PIXMAN_g8: + LLOGLN(0, (" PIXMAN_g8")); + break; + + case PIXMAN_x4a4: + LLOGLN(0, (" PIXMAN_x4a4")); + break; + + /* 4bpp formats */ + case PIXMAN_a4: + LLOGLN(0, (" PIXMAN_a4")); + break; + case PIXMAN_r1g2b1: + LLOGLN(0, (" PIXMAN_r1g2b1")); + break; + case PIXMAN_b1g2r1: + LLOGLN(0, (" PIXMAN_b1g2r1")); + break; + case PIXMAN_a1r1g1b1: + LLOGLN(0, (" PIXMAN_a1r1g1b1")); + break; + case PIXMAN_a1b1g1r1: + LLOGLN(0, (" PIXMAN_a1b1g1r1")); + break; + + case PIXMAN_c4: + LLOGLN(0, (" PIXMAN_c4")); + break; + case PIXMAN_g4: + LLOGLN(0, (" PIXMAN_g4")); + break; + + /* 1bpp formats */ + case PIXMAN_a1: + LLOGLN(0, (" PIXMAN_a1")); + break; + case PIXMAN_g1: + LLOGLN(0, (" PIXMAN_g1")); + break; + } + return 0; +} + +/******************************************************************************/ +static int +compsoite_print(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + PixmapPtr pSrcPixmap; + PixmapPtr pDstPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pDstPriv; + + LLOGLN(0, ("compsoite_print: op %d xSrc %d ySrc %d xDst %d yDst %d " + "width %d height %d", + op, xSrc, ySrc, xDst, yDst, width, height)); + + if (pSrc != 0) + { + LLOGLN(0, (" src depth %d width %d height %d repeat %d repeatType %d " + "dither %d filter %d alphaMap %p componentAlpha %d", pSrc->pDrawable->depth, + pSrc->pDrawable->width, pSrc->pDrawable->height, + pSrc->repeat, pSrc->repeatType, pSrc->dither, pSrc->filter, + pSrc->alphaMap, pSrc->componentAlpha)); + LLOGLN(0, (" transform %p", pSrc->transform)); + LLOGLN(0, (" detail format red %d red mask %d green %d green mask %d " + "blue %d blue mask %d", + pSrc->pFormat->direct.red, pSrc->pFormat->direct.redMask, + pSrc->pFormat->direct.green, pSrc->pFormat->direct.greenMask, + pSrc->pFormat->direct.blue, pSrc->pFormat->direct.blueMask)); + print_format(pSrc->format); + if (pSrc->pDrawable->type == DRAWABLE_PIXMAP) + { + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + LLOGLN(0, (" DRAWABLE_PIXMAP pSrcPriv %p status %d", pSrcPriv, pSrcPriv->status)); + } + else if (pSrc->pDrawable->type == DRAWABLE_WINDOW) + { + LLOGLN(0, (" DRAWABLE_WINDOW")); + } + else + { + LLOGLN(0, (" OTHER")); + } + } + if (pMask != 0) + { + LLOGLN(0, (" msk depth %d width %d height %d repeat %d repeatType %d", + pMask->pDrawable->depth, + pMask->pDrawable->width, + pMask->pDrawable->height, pMask->repeat, pMask->repeatType)); + print_format(pMask->format); + } + if (pDst != 0) + { + LLOGLN(0, (" dst depth %d width %d height %d repeat %d repeatType %d " + "dither %d filter %d alphaMap %p", pDst->pDrawable->depth, + pDst->pDrawable->width, pDst->pDrawable->height, + pDst->repeat, pDst->repeatType, pDst->dither, pDst->filter, + pDst->alphaMap)); + LLOGLN(0, (" transform %p", pDst->transform)); + print_format(pDst->format); + if (pDst->pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + LLOGLN(0, (" DRAWABLE_PIXMAP pDstPriv %p status %d", pDstPriv, pDstPriv->status)); + } + else if (pDst->pDrawable->type == DRAWABLE_WINDOW) + { + LLOGLN(0, (" DRAWABLE_WINDOW")); + } + else + { + LLOGLN(0, (" OTHER")); + } + } + return 0; +} + +/******************************************************************************/ +static int +src_alpha_needed(CARD8 op) +{ + int rv; + + rv = 0; + switch (op) + { + case 3: /* Over */ + case 6: /* InReverse */ + case 8: /* OutReverse */ + case 9: /* Atop */ + case 10: /* AtopReverse */ + case 11: /* Xor */ + case 13: /* Saturate */ + case 17: /* DisjointOver */ + case 18: /* DisjointOverReverse */ + case 19: /* DisjointIn */ + case 20: /* DisjointInReverse */ + case 21: /* DisjointOut */ + case 22: /* DisjointOutReverse */ + case 23: /* DisjointAtop */ + case 24: /* DisjointAtopReverse */ + case 25: /* DisjointXor */ + case 29: /* ConjointOver */ + case 30: /* ConjointOverReverse */ + case 31: /* ConjointIn */ + case 32: /* ConjointInReverse */ + case 33: /* ConjointOut */ + case 34: /* ConjointOutReverse */ + case 35: /* ConjointAtop */ + case 36: /* ConjointAtopReverse */ + case 37: /* ConjointXor */ + rv = 1; + break; + } + return rv; +} + +/******************************************************************************/ +static int +dst_alpha_needed(CARD8 op) +{ + int rv; + + rv = 0; + switch (op) + { + case 4: /* OverReverse */ + case 5: /* In */ + case 7: /* Out */ + case 9: /* Atop */ + case 10: /* AtopReverse */ + case 11: /* Xor */ + case 13: /* Saturate */ + case 17: /* DisjointOver */ + case 18: /* DisjointOverReverse */ + case 19: /* DisjointIn */ + case 20: /* DisjointInReverse */ + case 21: /* DisjointOut */ + case 22: /* DisjointOutReverse */ + case 23: /* DisjointAtop */ + case 24: /* DisjointAtopReverse */ + case 25: /* DisjointXor */ + case 29: /* ConjointOver */ + case 30: /* ConjointOverReverse */ + case 31: /* ConjointIn */ + case 32: /* ConjointInReverse */ + case 33: /* ConjointOut */ + case 34: /* ConjointOutReverse */ + case 35: /* ConjointAtop */ + case 36: /* ConjointAtopReverse */ + case 37: /* ConjointXor */ + rv = 1; + break; + } + return rv; +} + +struct msk_info +{ + int flags; + int idx; + int format; + int width; + int repeat; +}; + +static char g_com_fail_strings[][128] = +{ + "OK", + "src not remotable", + "dst not remotable", + "msk not remotable" +}; + +/******************************************************************************/ +/* returns boolean */ +static int +check_drawables(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height, struct msk_info* msk) +{ + int rv; + int fail_reason; + PixmapPtr pSrcPixmap; + PixmapPtr pDstPixmap; + PixmapPtr pMskPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pMskPriv; + + fail_reason = 0; + pSrcPixmap = 0; + pDstPixmap = 0; + pMskPixmap = 0; + pSrcPriv = 0; + pDstPriv = 0; + pMskPriv = 0; + rv = 0; + if (pSrc != 0) + { + if (pSrc->pDrawable != 0) + { + if (pSrc->pDrawable->type == DRAWABLE_PIXMAP) + { + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + if (xrdp_is_os(pSrcPixmap, pSrcPriv)) + { + if (pDst != 0) + { + if (pDst->pDrawable != 0) + { + if (pDst->pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + if (xrdp_is_os(pDstPixmap, pDstPriv)) + { + rv = 1; + } + else + { + fail_reason = 2; + } + } + } + } + } + else + { + fail_reason = 1; + } + } + } + } + if (rv) + { + if (pMask != 0) + { +#if 1 + rv = 0; + if (pMask->pDrawable != 0) + { + if (pMask->pDrawable->type == DRAWABLE_PIXMAP) + { + pMskPixmap = (PixmapPtr)(pMask->pDrawable); + pMskPriv = GETPIXPRIV(pMskPixmap); + if (xrdp_is_os(pMskPixmap, pMskPriv)) + { + rv = 1; + msk->flags = 1; + msk->idx = pMskPriv->rdpindex; + msk->format = pMask->format; + msk->width = pMask->pDrawable->width; + msk->repeat = pMask->repeatType; + } + else + { + fail_reason = 3; + } + } + } +#endif + } + } + if (rv == 0) + { + LLOGLN(10, ("check_drawables: can not remote [%s]", g_com_fail_strings[fail_reason])); +#if 0 + compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); +#endif + } + else + { + LLOGLN(10, ("check_drawables: can remote [%s]", g_com_fail_strings[fail_reason])); +#if 0 + compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); +#endif + } + return rv; +} + +/******************************************************************************/ +static int +rdpRemoteComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + int ok_to_remote; + PixmapPtr pSrcPixmap; + PixmapPtr pMskPixmap; + PixmapPtr pDstPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pMskPriv; + rdpPixmapRec* pDstPriv; + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int j; + int num_clips; + struct msk_info msk; + + LLOGLN(10, ("rdpRemoteComposite:")); + + memset(&msk, 0, sizeof(msk)); + ok_to_remote = check_drawables(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, + &msk); + if (!ok_to_remote) + { + return 1; + } + + ValidatePicture(pSrc); + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + rdpup_check_dirty(pSrcPixmap, pSrcPriv); + if (PIXMAN_FORMAT_A(pSrc->format) > 0) + { + if (src_alpha_needed(op)) + { + rdpup_check_alpha_dirty(pSrcPixmap, pSrcPriv); + } + } + + ValidatePicture(pDst); + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + rdpup_check_dirty(pDstPixmap, pDstPriv); + + if (PIXMAN_FORMAT_A(pDst->format) > 0) + { + if (dst_alpha_needed(op)) + { + rdpup_check_alpha_dirty(pDstPixmap, pDstPriv); + } + } + + if (pMask != 0) + { + ValidatePicture(pMask); + pMskPixmap = (PixmapPtr)(pMask->pDrawable); + pMskPriv = GETPIXPRIV(pMskPixmap); + rdpup_check_dirty(pMskPixmap, pMskPriv); + if (PIXMAN_FORMAT_A(msk.format) > 0) + { + rdpup_check_alpha_dirty(pMskPixmap, pMskPriv); + } + } + + p = pDst->pDrawable; + rdpup_switch_os_surface(pDstPriv->rdpindex); + if (pDst->pCompositeClip != 0) + { + box.x1 = xDst; + box.y1 = yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + RegionTranslate(®1, p->x, p->y); + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + LLOGLN(10, ("num_clips %d", num_clips)); + rdpup_begin_update(); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, ("pSrc->format 0x%x 0x%x 0x%x %d %d %d %d %d %d %d %d", + pSrc->format, msk.format, pDst->format, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height)); + rdpup_composite(pSrcPriv->rdpindex, pSrc->format, + pSrc->pDrawable->width, pSrc->repeatType, + pSrc->transform, msk.flags, msk.idx, msk.format, + msk.width, msk.repeat, op, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, pDst->format); + } + rdpup_reset_clip(); + rdpup_end_update(); + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + rdpup_begin_update(); + rdpup_composite(pSrcPriv->rdpindex, pSrc->format, + pSrc->pDrawable->width, pSrc->repeatType, + pSrc->transform, msk.flags, msk.idx, msk.format, + msk.width, msk.repeat, op, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, pDst->format); + rdpup_end_update(); + } + rdpup_switch_os_surface(-1); + + return 0; +} + +/******************************************************************************/ +static void +rdpCompositeOrg(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + PictureScreenPtr ps; + + ps = GetPictureScreen(g_pScreen); + ps->Composite = g_rdpScreen.Composite; + ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + ps->Composite = rdpComposite; +} + +/******************************************************************************/ +/* it looks like all the antialias draws go through here + op is one of the following + #define PictOpMinimum 0 + #define PictOpClear 0 + #define PictOpSrc 1 + #define PictOpDst 2 + #define PictOpOver 3 + #define PictOpOverReverse 4 + #define PictOpIn 5 + #define PictOpInReverse 6 + #define PictOpOut 7 + #define PictOpOutReverse 8 + #define PictOpAtop 9 + #define PictOpAtopReverse 10 + #define PictOpXor 11 + #define PictOpAdd 12 + #define PictOpSaturate 13 + #define PictOpMaximum 13 + + see for porter duff + http://www.svgopen.org/2005/papers/abstractsvgopen/ + + */ +void +rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int dirty_type; + int j; + int num_clips; + int post_process; + int reset_surface; + int got_id; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pDirtyPriv; + struct image_data id; + + LLOGLN(10, ("rdpComposite:")); + + if (g_doing_font == 2) + { + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + + return; + } + +#if 0 + if (g_do_glyph_cache && g_do_alpha_glyphs) + { + if (pSrc->pDrawable->width == 1 && + pSrc->pDrawable->height == 1) + { + if (pMask != 0) + { + /* TODO: here we can try to send it as a gylph */ + } + } + } +#endif + + /* try to remote the composite call */ + if (g_do_composite && + rdpRemoteComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height) == 0) + { + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + return; + } + + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + + LLOGLN(10, ("rdpComposite: op %d %p %p %p w %d h %d", op, pSrc, pMask, pDst, width, height)); + + p = pDst->pDrawable; + + pDstPriv = 0; + dirty_type = 0; + pDirtyPriv = 0; + post_process = 0; + reset_surface = 0; + got_id = 0; + if (p->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)p; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + post_process = 1; + if (g_do_dirty_os) + { + LLOGLN(10, ("rdpComposite: gettig dirty")); + pDstPriv->is_dirty = 1; + dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY; + pDirtyPriv = pDstPriv; + } + else + { + rdpup_switch_os_surface(pDstPriv->rdpindex); + reset_surface = 1; + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + LLOGLN(10, ("rdpComposite: offscreen")); + } + } + } + else + { + if (p->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)p; + if (pDstWnd->viewable) + { + post_process = 1; + rdpup_get_screen_image_rect(&id); + got_id = 1; + LLOGLN(10, ("rdpComposite: screen")); + } + } + } + + if (!post_process) + { + return; + } + + if (pDst->pCompositeClip != 0) + { + box.x1 = p->x + xDst; + box.y1 = p->y + yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + if (dirty_type != 0) + { + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); + } + else if (got_id) + { + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + rdpup_begin_update(); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + } + rdpup_end_update(); + } + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + box.x1 = p->x + xDst; + box.y1 = p->y + yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + if (dirty_type != 0) + { + RegionInit(®1, &box, 0); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); + RegionUninit(®1); + } + else if (got_id) + { + rdpup_begin_update(); + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_end_update(); + } + } + if (reset_surface) + { + rdpup_switch_os_surface(-1); + } +} diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.c b/xorg/X11R7.6/rdp/rdpCopyArea.c index 254590ee..4718a89c 100644 --- a/xorg/X11R7.6/rdp/rdpCopyArea.c +++ b/xorg/X11R7.6/rdp/rdpCopyArea.c @@ -474,6 +474,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, } } + LLOGLN(10, ("rdpCopyArea: fallback")); + /* do original call */ rv = rdpCopyAreaOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); @@ -557,7 +559,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 1); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYAREA); RegionUninit(®1); } else if (got_id) @@ -581,7 +583,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, box.y2 = box.y1 + h; RegionInit(&box_reg, &box, 0); RegionIntersect(&clip_reg, &clip_reg, &box_reg); - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 1); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_COPYAREA); RegionUninit(&box_reg); } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpCopyPlane.c b/xorg/X11R7.6/rdp/rdpCopyPlane.c index bd367398..063766ee 100644 --- a/xorg/X11R7.6/rdp/rdpCopyPlane.c +++ b/xorg/X11R7.6/rdp/rdpCopyPlane.c @@ -168,7 +168,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 5); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYPLANE); RegionUninit(®1); } else if (got_id) @@ -194,7 +194,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, RegionInit(®2, NullBox, 0); RegionCopy(®2, &clip_reg); RegionIntersect(®1, ®1, ®2); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 5); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYPLANE); RegionUninit(®1); RegionUninit(®2); } diff --git a/xorg/X11R7.6/rdp/rdpFillPolygon.c b/xorg/X11R7.6/rdp/rdpFillPolygon.c index a9969c22..960f619e 100644 --- a/xorg/X11R7.6/rdp/rdpFillPolygon.c +++ b/xorg/X11R7.6/rdp/rdpFillPolygon.c @@ -203,7 +203,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 7); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_FILLPOLYGON); RegionUninit(®1); } else if (got_id) @@ -223,7 +223,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 7); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_FILLPOLYGON); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c index 96c82a9c..d425a30b 100644 --- a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c @@ -169,7 +169,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 13); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT); RegionUninit(®1); } else if (got_id) @@ -189,7 +189,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 13); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageText16.c b/xorg/X11R7.6/rdp/rdpImageText16.c index 24b869d6..604d85e3 100644 --- a/xorg/X11R7.6/rdp/rdpImageText16.c +++ b/xorg/X11R7.6/rdp/rdpImageText16.c @@ -167,7 +167,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 12); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGETEXT16); RegionUninit(®1); } else if (got_id) @@ -187,7 +187,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 12); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGETEXT16); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageText8.c b/xorg/X11R7.6/rdp/rdpImageText8.c index 69489101..08dead18 100644 --- a/xorg/X11R7.6/rdp/rdpImageText8.c +++ b/xorg/X11R7.6/rdp/rdpImageText8.c @@ -167,7 +167,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 9); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGETEXT8); RegionUninit(®1); } else if (got_id) @@ -187,7 +187,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 9); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGETEXT8); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyArc.c b/xorg/X11R7.6/rdp/rdpPolyArc.c index 78882ddd..84a85587 100644 --- a/xorg/X11R7.6/rdp/rdpPolyArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyArc.c @@ -185,7 +185,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 6); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC); } else if (got_id) { @@ -217,7 +217,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 6); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyFillArc.c b/xorg/X11R7.6/rdp/rdpPolyFillArc.c index 1a18c660..e3822215 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillArc.c @@ -185,7 +185,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 8); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC); } else if (got_id) { @@ -217,7 +217,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 8); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.c b/xorg/X11R7.6/rdp/rdpPolyFillRect.c index af68e83f..7db4be69 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillRect.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.c @@ -196,7 +196,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, else { draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, - dirty_type, 2); + dirty_type, TAG_POLYFILLRECT); } } else if (got_id) @@ -264,7 +264,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, { LLOGLN(10, ("rdpPolyFillRect: 4")); draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, - dirty_type, 2); + dirty_type, TAG_POLYFILLRECT); } } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c index 102976ba..8ce1db08 100644 --- a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c @@ -169,7 +169,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 14); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYGLYPHBLT); RegionUninit(®1); } else if (got_id) @@ -189,7 +189,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 14); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYGLYPHBLT); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.c b/xorg/X11R7.6/rdp/rdpPolyRectangle.c index ba6b5040..c1a5c971 100644 --- a/xorg/X11R7.6/rdp/rdpPolyRectangle.c +++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.c @@ -221,7 +221,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, } else { - draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type, 4); + draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE); } RegionDestroy(fill_reg); @@ -275,7 +275,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, } else { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 4); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE); } } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPolyText16.c b/xorg/X11R7.6/rdp/rdpPolyText16.c index 9643c7d9..a28030f0 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText16.c +++ b/xorg/X11R7.6/rdp/rdpPolyText16.c @@ -170,7 +170,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 11); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYTEXT16); RegionUninit(®1); } else if (got_id) @@ -190,7 +190,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 11); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYTEXT16); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyText8.c b/xorg/X11R7.6/rdp/rdpPolyText8.c index 0182df15..3157a538 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText8.c +++ b/xorg/X11R7.6/rdp/rdpPolyText8.c @@ -170,7 +170,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 10); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYTEXT8); RegionUninit(®1); } else if (got_id) @@ -190,7 +190,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, 10); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYTEXT8); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPushPixels.c b/xorg/X11R7.6/rdp/rdpPushPixels.c index 6913f48f..e7d330d1 100644 --- a/xorg/X11R7.6/rdp/rdpPushPixels.c +++ b/xorg/X11R7.6/rdp/rdpPushPixels.c @@ -160,7 +160,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 15); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUSHPIXELS); RegionUninit(®1); } else if (got_id) @@ -185,7 +185,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 15); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_PUSHPIXELS); RegionUninit(®1); } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPutImage.c b/xorg/X11R7.6/rdp/rdpPutImage.c index 050f5f5f..d244d895 100644 --- a/xorg/X11R7.6/rdp/rdpPutImage.c +++ b/xorg/X11R7.6/rdp/rdpPutImage.c @@ -163,7 +163,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 3); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUTIMAGE); RegionUninit(®1); } else if (got_id) @@ -185,7 +185,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, RegionInit(®2, NullBox, 0); RegionCopy(®2, &clip_reg); RegionIntersect(®1, ®1, ®2); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 3); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUTIMAGE); RegionUninit(®1); RegionUninit(®2); } diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index b573f1a8..0f31862e 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -45,6 +45,7 @@ Xserver drawing ops and funcs #include "rdpImageGlyphBlt.h" #include "rdpPolyGlyphBlt.h" #include "rdpPushPixels.h" +#include "rdpglyph.h" #define LOG_LEVEL 1 #define LLOG(_level, _args) \ @@ -65,11 +66,10 @@ 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 int g_con_number; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ ColormapPtr g_rdpInstalledColormap; -static int g_doing_font = 0; - GCFuncs g_rdpGCFuncs = { rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip, @@ -407,6 +407,8 @@ rdpCloseScreen(int i, ScreenPtr pScreen) int draw_item_add(rdpPixmapRec *priv, struct rdp_draw_item *di) { + priv->is_alpha_dirty_not = 0; + if (priv->draw_item_tail == 0) { priv->draw_item_tail = di; @@ -458,6 +460,11 @@ draw_item_remove(rdpPixmapRec *priv, struct rdp_draw_item *di) g_free(di->u.line.segs); } } + + if (di->type == RDI_TEXT) + { + delete_rdp_text(di->u.text.rtext); + } RegionDestroy(di->reg); g_free(di); @@ -513,6 +520,146 @@ remove_empties(rdpPixmapRec* priv) /******************************************************************************/ int +region_get_pixel_count(RegionPtr reg) +{ + int index; + int count; + int pixels; + int width; + int height; + BoxRec box; + + pixels = 0; + count = REGION_NUM_RECTS(reg); + for (index = 0; index < count; index++) + { + box = REGION_RECTS(reg)[index]; + width = box.x2 - box.x1; + height = box.y2 - box.y1; + pixels += width * height; + } + return pixels; +} + +/******************************************************************************/ +/* returns boolean */ +int +region_in_region(RegionPtr reg_small, int sreg_pcount, RegionPtr reg_big) +{ + int rv; + RegionRec reg; + + rv = 0; + RegionInit(®, NullBox, 0); + RegionIntersect(®, reg_small, reg_big); + if (sreg_pcount == -1) + { + sreg_pcount = region_get_pixel_count(reg_small); + } + if (sreg_pcount == 0) + { + /* empty region not even in */ + return 0; + } + if (region_get_pixel_count(®) == sreg_pcount) + { + rv = 1; + } + RegionUninit(®); + return rv; +} + +/******************************************************************************/ +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; +} + +/******************************************************************************/ +static int +dump_draw_list(rdpPixmapRec* priv) +{ + struct rdp_draw_item* di; + int index; + int count; + BoxRec box; + + LLOGLN(0, ("dump_draw_list:")); + di = priv->draw_item_head; + while (di != 0) + { + LLOGLN(0, (" type %d", di->type)); + count = REGION_NUM_RECTS(di->reg); + if (count == 0) + { + LLOGLN(0, (" empty region")); + } + else + { + box = RegionExtents(di->reg)[0]; + LLOGLN(0, (" region list follows extents x1 %d y1 %d x2 %d y2 %d", + box.x1, box.y1, box.x2, box.y2)); + for (index = 0; index < count; index++) + { + box = REGION_RECTS(di->reg)[index]; + LLOGLN(0, (" index %d x1 %d y1 %d x2 %d y2 %d", + index, box.x1, box.y1, box.x2, box.y2)); + } + } + di = di->next; + } + return 0; +} + +/******************************************************************************/ +/* returns boolean */ +static int +region_interect_at_all(RegionPtr reg_small, RegionPtr reg_big) +{ + int rv; + RegionRec reg; + + if (!RegionNotEmpty(reg_small)) + { + return 0; + } + rv = 0; + RegionInit(®, NullBox, 0); + RegionIntersect(®, reg_big, reg_big); + if (RegionNotEmpty(®)) + { + rv = 1; + } + RegionUninit(®); + return rv; +} + +/******************************************************************************/ +int draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) { struct rdp_draw_item *di; @@ -552,6 +699,17 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di != 0) { +#if 0 + if ((di_prev->type == RDI_IMGLL || di_prev->type == RDI_IMGLY) && + (di->type == RDI_IMGLL || di->type == RDI_IMGLY)) + { + LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL and RDI_IMGLY")); + di_prev->type = RDI_IMGLY; + RegionUnion(di_prev->reg, di_prev->reg, di->reg); + draw_item_remove(priv, di); + di = di_prev->next; + } +#else if ((di_prev->type == RDI_IMGLL) && (di->type == RDI_IMGLL)) { LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL")); @@ -559,6 +717,7 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) draw_item_remove(priv, di); di = di_prev->next; } +#endif else if ((di_prev->type == RDI_IMGLY) && (di->type == RDI_IMGLY)) { LLOGLN(10, ("draw_item_pack: packing RDI_IMGLY")); @@ -578,6 +737,33 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *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->type == RDI_TEXT) && (di_prev->type == RDI_IMGLY)) + { + if (region_interect_at_all(di->reg, di_prev->reg)) + { + di_prev->type = RDI_IMGLL; + } + } + di_prev = di_prev->prev; + } + di = di->prev; + } + } + } + remove_empties(priv); +#endif + +#if 0 /* subtract regions */ if (priv->draw_item_tail != 0) { @@ -598,8 +784,11 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di_prev != 0) { - /* D = M - S */ - RegionSubtract(di_prev->reg, di_prev->reg, di->reg); + if (region_in_region(di_prev->reg, -1, di->reg)) + { + /* empty region so this draw item will get removed below */ + RegionEmpty(di_prev->reg); + } di_prev = di_prev->prev; } } @@ -724,6 +913,25 @@ draw_item_add_srcblt_region(rdpPixmapRec *priv, RegionPtr reg, } /******************************************************************************/ +int +draw_item_add_text_region(rdpPixmapRec* priv, RegionPtr reg, int color, + int opcode, struct rdp_text* rtext) +{ + struct rdp_draw_item* di; + + LLOGLN(10, ("draw_item_add_text_region:")); + di = (struct rdp_draw_item*)g_malloc(sizeof(struct rdp_draw_item), 1); + di->type = RDI_TEXT; + di->u.text.fg_color = color; + di->u.text.opcode = opcode; + di->u.text.rtext = rtext; + di->reg = RegionCreate(NullBox, 0); + RegionCopy(di->reg, reg); + draw_item_add(priv, di); + return 0; +} + +/******************************************************************************/ PixmapPtr rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, unsigned usage_hint) @@ -746,6 +954,7 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0); if ((org_width == 0) && (height == 0)) { + LLOGLN(10, ("rdpCreatePixmap: setting is_scratch")); priv->is_scratch = 1; } return rv; @@ -808,13 +1017,12 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) (width > 0) && (height > 0) && (priv->kind_width > 0) && (priv->is_scratch == 0) && (priv->use_count >= 0)) { - LLOGLN(10, ("%d %d", priv->kind_width, pix->drawable.width)); + width = (width + 3) & ~3; priv->rdpindex = rdpup_add_os_bitmap(pix, priv); if (priv->rdpindex >= 0) { priv->status = 1; - rdpup_create_os_surface(priv->rdpindex, - priv->kind_width, height); + rdpup_create_os_surface(priv->rdpindex, width, height); box.x1 = 0; box.y1 = 0; box.x2 = width; @@ -848,6 +1056,10 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) priv->use_count++; return 1; } + else + { + LLOGLN(10, ("xrdp_is_os: rdpup_add_os_bitmap failed")); + } } priv->use_count++; return 0; @@ -896,6 +1108,10 @@ rdpDestroyWindow(WindowPtr pWindow) if (g_use_rail) { +#ifdef XRDP_WM_RDPUP + LLOGLN(10, (" rdpup_delete_window")); + rdpup_delete_window(pWindow, priv); +#endif } return rv; @@ -957,7 +1173,9 @@ rdpRealizeWindow(WindowPtr pWindow) pWindow->drawable.x, pWindow->drawable.y, pWindow->drawable.width, pWindow->drawable.height)); priv->status = 1; +#ifdef XRDP_WM_RDPUP rdpup_create_window(pWindow, priv); +#endif } } } @@ -986,7 +1204,18 @@ rdpUnrealizeWindow(WindowPtr pWindow) { LLOGLN(10, ("rdpUnrealizeWindow:")); priv->status = 0; - rdpup_delete_window(pWindow, priv); + if (pWindow->overrideRedirect) { +#ifdef XRDP_WM_RDPUP + /* + * Popups are unmapped by X server, so probably + * they will be mapped again. Thereby we should + * just hide those popups instead of destroying + * them. + */ + LLOGLN(10, (" rdpup_show_window")); + rdpup_show_window(pWindow, priv, 0x0); /* 0x0 - do not show the window */ +#endif + } } } @@ -1335,198 +1564,3 @@ rdpSaveScreen(ScreenPtr pScreen, int on) { return 1; } - -/******************************************************************************/ -/* it looks like all the antialias draws go through here */ -void -rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, - INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, - INT16 yDst, CARD16 width, CARD16 height) -{ - BoxRec box; - PictureScreenPtr ps; - RegionRec reg1; - RegionRec reg2; - DrawablePtr p; - int dirty_type; - int j; - int num_clips; - int post_process; - int reset_surface; - int got_id; - WindowPtr pDstWnd; - PixmapPtr pDstPixmap; - rdpPixmapRec *pDstPriv; - rdpPixmapRec *pDirtyPriv; - struct image_data id; - - LLOGLN(10, ("rdpComposite: op %d width %d height %d", op, width, height)); - ps = GetPictureScreen(g_pScreen); - ps->Composite = g_rdpScreen.Composite; - ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); - ps->Composite = rdpComposite; - - p = pDst->pDrawable; - - dirty_type = 0; - pDirtyPriv = 0; - post_process = 0; - reset_surface = 0; - got_id = 0; - - if (p->type == DRAWABLE_PIXMAP) - { - pDstPixmap = (PixmapPtr)p; - pDstPriv = GETPIXPRIV(pDstPixmap); - - if (xrdp_is_os(pDstPixmap, pDstPriv)) - { - post_process = 1; - - if (g_do_dirty_os) - { - LLOGLN(10, ("rdpComposite: getting dirty")); - pDstPriv->is_dirty = 1; - dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY; - pDirtyPriv = pDstPriv; - - } - else - { - rdpup_switch_os_surface(pDstPriv->rdpindex); - reset_surface = 1; - rdpup_get_pixmap_image_rect(pDstPixmap, &id); - got_id = 1; - LLOGLN(10, ("rdpComposite: offscreen")); - } - } - } - else - { - if (p->type == DRAWABLE_WINDOW) - { - pDstWnd = (WindowPtr)p; - - if (pDstWnd->viewable) - { - post_process = 1; - - if (g_do_dirty_ons) - { - LLOGLN(10, ("rdpComposite: getting dirty")); - g_screenPriv.is_dirty = 1; - pDirtyPriv = &g_screenPriv; - dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY; - } - else - { - rdpup_get_screen_image_rect(&id); - got_id = 1; - LLOGLN(10, ("rdpComposite: screen")); - } - } - } - } - - if (!post_process) - { - return; - } - - LLOGLN(10, ("rdpComposite: post_process")); - - if (pDst->pCompositeClip != 0) - { - box.x1 = p->x + xDst; - box.y1 = p->y + yDst; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - RegionInit(®1, &box, 0); - RegionInit(®2, NullBox, 0); - RegionCopy(®2, pDst->pCompositeClip); - RegionIntersect(®1, ®1, ®2); - - if (dirty_type != 0) - { - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 0); - } - else if (got_id) - { - num_clips = REGION_NUM_RECTS(®1); - - if (num_clips > 0) - { - rdpup_begin_update(); - - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(®1)[j]; - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - - rdpup_end_update(); - } - } - - RegionUninit(®1); - RegionUninit(®2); - } - else - { - box.x1 = p->x + xDst; - box.y1 = p->y + yDst; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - - if (dirty_type != 0) - { - RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, 0); - RegionUninit(®1); - } - else if (got_id) - { - rdpup_begin_update(); - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - rdpup_end_update(); - } - } - - if (reset_surface) - { - rdpup_switch_os_surface(-1); - } -} - -/******************************************************************************/ -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, - GlyphPtr *glyphs) -{ - PictureScreenPtr ps; - int index; - - LLOGLN(10, ("rdpGlyphs:")); - LLOGLN(10, ("rdpGlyphs: nlists %d len %d", nlists, lists->len)); - rdpup_set_hints(1, 1); - g_doing_font = 1; - - for (index = 0; index < lists->len; index++) - { - LLOGLN(10, (" index %d size %d refcnt %d width %d height %d", - index, (int)(glyphs[index]->size), (int)(glyphs[index]->refcnt), - glyphs[index]->info.width, glyphs[index]->info.height)); - } - - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - rdpup_set_hints(0, 1); - g_doing_font = 0; - LLOGLN(10, ("rdpGlyphs: out")); -} diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c new file mode 100644 index 00000000..954fbbe4 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -0,0 +1,860 @@ +/* + Copyright 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. + + */ + +/* + http://msdn.microsoft.com/en-us/library/cc241863(v=prot.20).aspx + 4.6.1 "d" Character + This topic has not yet been rated - Rate this topic + The following shows glyph image data (1 bpp format) for character + "d" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6) + Secondary Drawing Order. + + Glyph width = 5 pixels + Glyph height = 9 pixels + Glyph origin = (0, -9), marked with an "X" on the image grid + Bitmap = { 0x08, 0x08, 0x08, 0x78, 0x88, 0x88, 0x88, 0x88, 0x78 } + + http://msdn.microsoft.com/en-us/library/cc241864(v=prot.20).aspx + 4.6.2 "p" Character + This topic has not yet been rated - Rate this topic + The following shows glyph image data (1 bpp format) for character + "p" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6) + Secondary Drawing Order. + + Glyph width = 5 pixels + Glyph height = 8 pixels + Glyph origin = (0, -6), marked with an "X" on the image grid + Bitmap = { 0xF0, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x80, 0x80 } + */ + +#include "rdp.h" +#include "rdpdraw.h" +#include "rdpglyph.h" + +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_do_dirty_os; /* in rdpmain.c */ +extern int g_do_alpha_glyphs; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ +extern int g_doing_font; /* in rdpmain.c */ +extern ScreenPtr g_pScreen; /* in rdpmain.c */ +extern rdpScreenInfoRec g_rdpScreen; /* in rdpmain.c */ + + +#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) + +struct font_cache +{ + int offset; + int baseline; + int width; + int height; + int crc; + int stamp; +}; + +static struct font_cache g_font_cache[12][256]; +static int g_stamp = 0; + +/*****************************************************************************/ +static void +set_mono_pixel(char* data, int x, int y, int width, int pixel) +{ + int start; + int shift; + + width = (width + 7) / 8; + start = (y * width) + x / 8; + shift = x % 8; + if (pixel != 0) + { + data[start] = data[start] | (0x80 >> shift); + } + else + { + data[start] = data[start] & ~(0x80 >> shift); + } +} + +/*****************************************************************************/ +static int +lget_pixel(char* data, int x, int y, int depth, int stride_bytes) +{ + int start; + int shift; + + if (depth == 1) + { + start = (y * stride_bytes) + x / 8; + shift = x % 8; + return (data[start] & (0x01 << shift)) ? 0xff : 0; + } + else if (depth == 8) + { + return data[y * stride_bytes + x]; + } + return 0; +} + +/******************************************************************************/ +static int +glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd) +{ + int i; + int j; + int src_xoff; + int src_yoff; + int src_stride_bytes; + int dst_stride_bytes; + int hh; + int ww; + int src_depth; + unsigned char pixel; + PicturePtr pPicture; + pixman_image_t *src; + uint32_t* pi32; + char* pi8; + + pPicture = GlyphPicture(glyph)[pScreen->myNum]; + if (pPicture == 0) + { + return 0; + } + src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff); + if (src == 0) + { + return 0; + } + + src_stride_bytes = pixman_image_get_stride(src); + if (g_do_alpha_glyphs) + { + dst_stride_bytes = (glyph->info.width + 3) & ~3; + rfd->bpp = 8; + } + else + { + dst_stride_bytes = (((glyph->info.width + 7) / 8) + 3) & ~3; + rfd->bpp = 1; + } + src_depth = pixman_image_get_depth(src); + ww = pixman_image_get_width(src); + hh = pixman_image_get_height(src); + if ((ww != glyph->info.width) || (hh != glyph->info.height) || + ((src_depth != 1) && (src_depth != 8))) + { + LLOGLN(0, ("glyph_get_data: bad glyph")); + free_pixman_pict(pPicture, src); + return 0; + } + rfd->data_bytes = glyph->info.height * dst_stride_bytes; + rfd->data = (char*)g_malloc(rfd->data_bytes, 1); + rfd->offset = -glyph->info.x; + rfd->baseline = -glyph->info.y; + rfd->width = glyph->info.width; + rfd->height = glyph->info.height; + pi32 = pixman_image_get_data(src); + pi8 = (char*)pi32; + for (j = 0; j < rfd->height; j++) + { + for (i = 0; i < rfd->width; i++) + { + pixel = lget_pixel(pi8, i, j, src_depth, src_stride_bytes); + if (g_do_alpha_glyphs) + { + rfd->data[j * dst_stride_bytes + i] = pixel; + } + else + { + if (pixel > 0x7f) + { + set_mono_pixel(rfd->data, i, j, rfd->width, 1); + } + else + { + set_mono_pixel(rfd->data, i, j, rfd->width, 0); + } + } + } + } + free_pixman_pict(pPicture, src); + return 0; +} + +/******************************************************************************/ +struct rdp_text* +create_rdp_text(ScreenPtr pScreen, int nlists, GlyphListPtr lists, + GlyphPtr* glyphs) +{ + struct rdp_text* rv; + struct rdp_text* rtext; + struct rdp_text* last_rtext; + BoxRec box; + RegionRec reg1; + int n; + int lxoff; + int lyoff; + int count; + int lx; + int ly; + int font_index; + int max_height; + int min_height; + int force_new; + GlyphPtr glyph; + struct rdp_font_char* rfd; + + LLOGLN(10, ("create_rdp_text: nlists %d", nlists)); + + max_height = 0; + min_height = 0x7fffffff; + lx = lists->xOff; + ly = lists->yOff; + lxoff = 0; + lyoff = 0; + force_new = 0; + + rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1); + rtext->reg = RegionCreate(NullBox, 0); + rtext->flags = 3; + rtext->mixmode = 0; + rtext->x = lx; + rtext->y = ly; + + rv = rtext; + last_rtext = rtext; + + count = 0; + while (nlists--) + { + LLOGLN(10, ("lists->xOff %d lists->yOff %d", lists->xOff, lists->yOff)); + if (count != 0) + { + lx += lists->xOff; + ly += lists->yOff; + force_new = 1; + } + count++; + n = lists->len; + lists++; + while (n--) + { + glyph = *glyphs++; + /* process glyph here */ + if ((glyph->info.width > 0) && (glyph->info.height > 0)) + { + if (force_new) + { + LLOGLN(10, ("create_rdp_text: too many chars")); + force_new = 0; + rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1); + rtext->reg = RegionCreate(NullBox, 0); + rtext->flags = 3; + rtext->mixmode = 0; + rtext->x = lx; + rtext->y = ly; + last_rtext->next = rtext; + last_rtext = rtext; + lxoff = 0; + lyoff = 0; + } + LLOGLN(10, ("x %d y %d width %d height %d xOff %d yOff %d " + "num_chars %d lxoff %d lyoff %d lx %d ly %d", + glyph->info.x, glyph->info.y, + glyph->info.width, glyph->info.height, + glyph->info.xOff, glyph->info.yOff, rtext->num_chars, + lxoff, lyoff, lx, ly)); + rfd = (struct rdp_font_char*)g_malloc(sizeof(struct rdp_font_char), 1); + rtext->chars[rtext->num_chars] = rfd; + box.x1 = lx - glyph->info.x; + box.y1 = ly - glyph->info.y; + box.x2 = box.x1 + glyph->info.width; + box.y2 = box.y1 + glyph->info.height; + if (glyph->info.height > max_height) + { + max_height = glyph->info.height; + } + if (glyph->info.height < min_height) + { + min_height = glyph->info.height; + } + RegionInit(®1, &box, 0); + RegionUnion(rtext->reg, ®1, rtext->reg); + RegionUninit(®1); + + glyph_get_data(pScreen, glyph, rfd); + + rfd->incby = lxoff; + lxoff = glyph->info.xOff; + lyoff = glyph->info.yOff; + rtext->num_chars++; + if (rtext->num_chars > 63) + { + force_new = 1; + } + } + else + { + lxoff += glyph->info.xOff; + lyoff += glyph->info.yOff; + } + lx += glyph->info.xOff; + ly += glyph->info.yOff; + } + } + if (max_height > 10) + { + font_index = 8; + } + else if (max_height < 7) + { + font_index = 6; + } + else + { + font_index = 7; + } + LLOGLN(10, ("create_rdp_text: min_height %d max_height %d font_index %d", + min_height, max_height, font_index)); + rtext = rv; + while (rtext != 0) + { + rtext->font = font_index; + rtext = rtext->next; + } + return rv; +} + +/******************************************************************************/ +int +delete_rdp_text(struct rdp_text* rtext) +{ + int index; + + if (rtext == 0) + { + return 0; + } + for (index = 0; index < rtext->num_chars; index++) + { + if (rtext->chars[index] != 0) + { + g_free(rtext->chars[index]->data); + g_free(rtext->chars[index]); + } + } + RegionDestroy(rtext->reg); + delete_rdp_text(rtext->next); + g_free(rtext); + return 0; +} + +/******************************************************************************/ +static int +get_color(PicturePtr pPicture) +{ + int src_xoff; + int src_yoff; + int rv; + uint32_t* pi32; + pixman_image_t *src; + + src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff); + if (src == 0) + { + return 0; + } + pi32 = pixman_image_get_data(src); + if (pi32 == 0) + { + return 0; + } + rv = *pi32; + LLOGLN(10, ("get_color: 0x%8.8x width %d height %d ", rv, + pixman_image_get_width(src), + pixman_image_get_height(src))); + free_pixman_pict(pPicture, src); + return rv; +} + +/******************************************************************************/ +static int +find_or_add_char(int font, struct rdp_font_char* rfd) +{ + int crc; + int index; + int char_index; + int oldest; + + crc = get_crc(rfd->data, rfd->data_bytes); + LLOGLN(10, ("find_or_add_char: crc 0x%8.8x", crc)); + char_index = 0; + oldest = 0x7fffffff; + for (index = 0; index < 250; index++) + { + if ((g_font_cache[font][index].crc == crc) && + (g_font_cache[font][index].width == rfd->width) && + (g_font_cache[font][index].height == rfd->height) && + (g_font_cache[font][index].offset == rfd->offset) && + (g_font_cache[font][index].baseline == rfd->baseline)) + { + g_stamp++; + g_font_cache[font][index].stamp = g_stamp; + LLOGLN(10, ("find_or_add_char: found char at %d %d", font, index)); + return index; + } + if (g_font_cache[font][index].stamp < oldest) + { + oldest = g_font_cache[font][index].stamp; + char_index = index; + } + } + g_stamp++; + g_font_cache[font][char_index].stamp = g_stamp; + g_font_cache[font][char_index].crc = crc; + g_font_cache[font][char_index].width = rfd->width; + g_font_cache[font][char_index].height = rfd->height; + g_font_cache[font][char_index].offset = rfd->offset; + g_font_cache[font][char_index].baseline = rfd->baseline; + LLOGLN(10, ("find_or_add_char: adding char at %d %d", font, char_index)); + if (rfd->bpp == 8) + { + rdpup_add_char_alpha(font, char_index, rfd->offset, rfd->baseline, + rfd->width, rfd->height, + rfd->data, rfd->data_bytes); + } + else + { + rdpup_add_char(font, char_index, rfd->offset, rfd->baseline, + rfd->width, rfd->height, + rfd->data, rfd->data_bytes); + } + return char_index; +} + +/******************************************************************************/ +int +rdp_text_chars_to_data(struct rdp_text* rtext) +{ + int index; + int data_bytes; + int char_index; + struct rdp_font_char* rfd; + + LLOGLN(10, ("rdp_text_chars_to_data: rtext->num_chars %d", rtext->num_chars)); + data_bytes = 0; + for (index = 0; index < rtext->num_chars; index++) + { + rfd = rtext->chars[index]; + if (rfd == 0) + { + LLOGLN(0, ("rdp_text_chars_to_data: error rfd is nil")); + continue; + } + char_index = find_or_add_char(rtext->font, rfd); + rtext->data[data_bytes] = char_index; + data_bytes++; + if (rfd->incby > 127) + { + rtext->data[data_bytes] = 0x80; + data_bytes++; + rtext->data[data_bytes] = (rfd->incby >> 0) & 0xff; + data_bytes++; + rtext->data[data_bytes] = (rfd->incby >> 8) & 0xff; + data_bytes++; + } + else + { + rtext->data[data_bytes] = rfd->incby; + data_bytes++; + } + } + rtext->data_bytes = data_bytes; + return 0; +} + +/******************************************************************************/ +/* + typedef struct _GlyphList { + INT16 xOff; + INT16 yOff; + CARD8 len; + PictFormatPtr format; + } GlyphListRec, *GlyphListPtr; + */ +/* see ghyphstr.h but the follow is not in there + typedef struct _XGlyphInfo { + unsigned short width; + unsigned short height; + short x; + short y; + short xOff; + short yOff; + } XGlyphInfo; + */ +static void +rdpGlyphu(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs, + BoxPtr extents) +{ + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int dirty_type; + int j; + int num_clips; + int post_process; + int reset_surface; + int got_id; + int fg_color; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pDirtyPriv; + struct image_data id; + struct rdp_text* rtext; + struct rdp_text* trtext; + + LLOGLN(10, ("rdpGlyphu: xSrc %d ySrc %d", xSrc, ySrc)); + + p = pDst->pDrawable; + + dirty_type = 0; + pDirtyPriv = 0; + post_process = 0; + reset_surface = 0; + got_id = 0; + if (p->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)p; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + rdpup_check_dirty(pDstPixmap, pDstPriv); + post_process = 1; + if (g_do_dirty_os) + { + LLOGLN(10, ("rdpGlyphu: gettig dirty")); + pDstPriv->is_dirty = 1; + dirty_type = RDI_IMGLL; + pDirtyPriv = pDstPriv; + + } + else + { + rdpup_switch_os_surface(pDstPriv->rdpindex); + reset_surface = 1; + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + LLOGLN(10, ("rdpGlyphu: offscreen")); + } + } + } + else + { + if (p->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)p; + if (pDstWnd->viewable) + { + post_process = 1; + rdpup_get_screen_image_rect(&id); + got_id = 1; + LLOGLN(10, ("rdpGlyphu: screen")); + } + } + } + if (!post_process) + { + return; + } + + rtext = create_rdp_text(pDst->pDrawable->pScreen, nlists, lists, glyphs); + if (rtext == 0) + { + LLOGLN(0, ("rdpGlyphu: create_rdp_text failed")); + return; + } + fg_color = get_color(pSrc); + + LLOGLN(10, ("rdpGlyphu: pDst->clientClipType %d pCompositeClip %p", + pDst->clientClipType, pDst->pCompositeClip)); + + if (pDst->pCompositeClip != 0) + { + box.x1 = p->x + extents->x1; + box.y1 = p->y + extents->y1; + box.x2 = p->x + extents->x2; + box.y2 = p->y + extents->y2; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + if (dirty_type != 0) + { + LLOGLN(10, ("1")); + draw_item_add_text_region(pDirtyPriv, ®1, fg_color, GXcopy, rtext); + rtext = 0; + } + else if (got_id) + { + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + LLOGLN(10, (" num_clips %d", num_clips)); + rdpup_begin_update(); + rdpup_set_fgcolor(fg_color); + trtext = rtext; + while (trtext != 0) + { + rdp_text_chars_to_data(trtext); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + LLOGLN(10, ("2")); + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, ("rdpGlyphu: rdpup_draw_text")); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1 + p->x, box.y1 + p->y, + box.x2 + p->x, box.y2 + p->y, + //box.x1 + p->x, box.y1 + p->y, + //box.x2 + p->x, box.y2 + p->y, + 0, 0, 0, 0, + trtext->x + p->x, trtext->y + p->y, + trtext->data, trtext->data_bytes); + } + trtext = trtext->next; + } + rdpup_reset_clip(); + rdpup_end_update(); + } + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + box.x1 = p->x + extents->x1; + box.y1 = p->y + extents->y1; + box.x2 = p->x + extents->x2; + box.y2 = p->y + extents->y2; + if (dirty_type != 0) + { + RegionInit(®1, &box, 0); + LLOGLN(10, ("3")); + draw_item_add_text_region(pDirtyPriv, ®1, fg_color, GXcopy, rtext); + rtext = 0; + RegionUninit(®1); + } + else if (got_id) + { + rdpup_begin_update(); + LLOGLN(10, ("4")); + rdpup_set_fgcolor(fg_color); + trtext = rtext; + while (trtext != 0) + { + LLOGLN(10, ("rdpGlyphu: rdpup_draw_text")); + rdp_text_chars_to_data(trtext); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1 + p->x, box.y1 + p->y, + box.x2 + p->x, box.y2 + p->y, + //box.x1 + p->x, box.y1 + p->y, + //box.x2 + p->x, box.y2 + p->y, + 0, 0, 0, 0, + trtext->x + p->x, trtext->y + p->y, + trtext->data, trtext->data_bytes); + trtext = trtext->next; + } + rdpup_end_update(); + } + } + if (reset_surface) + { + rdpup_switch_os_surface(-1); + } + delete_rdp_text(rtext); +} + +/******************************************************************************/ +static void +GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr* glyphs, BoxPtr extents) +{ + int x1; + int x2; + int y1; + int y2; + int n; + int x; + int y; + GlyphPtr glyph; + + x = 0; + y = 0; + extents->x1 = MAXSHORT; + extents->x2 = MINSHORT; + extents->y1 = MAXSHORT; + extents->y2 = MINSHORT; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + x1 = x - glyph->info.x; + if (x1 < MINSHORT) + { + x1 = MINSHORT; + } + y1 = y - glyph->info.y; + if (y1 < MINSHORT) + { + y1 = MINSHORT; + } + x2 = x1 + glyph->info.width; + if (x2 > MAXSHORT) + { + x2 = MAXSHORT; + } + y2 = y1 + glyph->info.height; + if (y2 > MAXSHORT) + { + y2 = MAXSHORT; + } + if (x1 < extents->x1) + { + extents->x1 = x1; + } + if (x2 > extents->x2) + { + extents->x2 = x2; + } + if (y1 < extents->y1) + { + extents->y1 = y1; + } + if (y2 > extents->y2) + { + extents->y2 = y2; + } + x += glyph->info.xOff; + y += glyph->info.yOff; + } + } +} + +/******************************************************************************/ +static void +rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs) +{ + BoxRec extents; + + GlyphExtents(nlists, lists, glyphs, &extents); + if ((extents.x2 <= extents.x1) || (extents.y2 <= extents.y1)) + { + return; + } + rdpGlyphu(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, + glyphs, &extents); +} + +/******************************************************************************/ +/* make sure no glyph is too big */ +/* returns boolean */ +static int +rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) +{ + int n; + GlyphPtr glyph; + + while (nlist--) + { + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + if ((glyph->info.width * glyph->info.height) > 8192) + { + LLOGLN(10, ("rdpGlyphCheck: too big")); + return 0; + } + } + } + return 1; +} + +/******************************************************************************/ +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr* glyphs) +{ + PictureScreenPtr ps; + + LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", + op, xSrc, ySrc, maskFormat)); + + if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) + { + g_doing_font = 2; + rdpGlypht(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + } + else + { + g_doing_font = 1; + rdpup_set_hints(1, 1); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + rdpup_set_hints(0, 1); + } + g_doing_font = 0; + LLOGLN(10, ("rdpGlyphs: out")); +} + +/******************************************************************************/ +int +rdpGlyphInit(void) +{ + memset(&g_font_cache, 0, sizeof(g_font_cache)); + return 0; +} diff --git a/xorg/X11R7.6/rdp/rdpglyph.h b/xorg/X11R7.6/rdp/rdpglyph.h new file mode 100644 index 00000000..6907f9e7 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpglyph.h @@ -0,0 +1,64 @@ +/* +Copyright 2012-2013 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 __RDPGLYPH_H +#define __RDPGLYPH_H + +struct rdp_font_char +{ + int offset; /* x */ + int baseline; /* y */ + int width; /* cx */ + int height; /* cy */ + int incby; + int bpp; + char* data; + int data_bytes; +}; + +struct rdp_text +{ + RegionPtr reg; + int font; + int x; + int y; + int flags; + int mixmode; + char data[256]; + int data_bytes; + struct rdp_font_char* chars[256]; + int num_chars; + struct rdp_text* next; +}; + +int +delete_rdp_text(struct rdp_text* rtext); +int +rdp_text_chars_to_data(struct rdp_text* rtext); + +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs); +int +rdpGlyphInit(void); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 18e267b6..c8739ba0 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -64,6 +64,7 @@ static int g_tab_down = 0; /* this is toggled every time num lock key is released, not like the above *_down vars */ static int g_scroll_lock_down = 0; +static OsTimerPtr g_kbtimer = 0; static OsTimerPtr g_timer = 0; static int g_x = 0; @@ -327,10 +328,57 @@ rdpBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls) } /******************************************************************************/ +static CARD32 +rdpInDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) +{ + //ErrorF("rdpInDeferredUpdateCallback:\n"); + + /* our keyboard device */ + XkbSetRepeatKeys(g_keyboard, -1, AutoRepeatModeOff); + /* the main one for the server */ + XkbSetRepeatKeys(inputInfo.keyboard, -1, AutoRepeatModeOff); + + return 0; +} + +/******************************************************************************/ void rdpChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) { + XkbControlsPtr ctrls; + ErrorF("rdpChangeKeyboardControl:\n"); + ctrls = 0; + if (pDev != 0) + { + if (pDev->key != 0) + { + if (pDev->key->xkbInfo != 0) + { + if (pDev->key->xkbInfo->desc != 0) + { + if (pDev->key->xkbInfo->desc->ctrls != 0) + { + ctrls = pDev->key->xkbInfo->desc->ctrls; + } + } + } + } + } + if (ctrls != 0) + { + if (ctrls->enabled_ctrls & XkbRepeatKeysMask) + { + //ErrorF("rdpChangeKeyboardControl: autoRepeat on\n"); + /* schedual to turn off the autorepeat after 100 ms so any app + * polling it will be happy it's on */ + g_kbtimer = TimerSet(g_kbtimer, 0, 100, rdpInDeferredUpdateCallback, 0);\ + } + else + { + //ErrorF("rdpChangeKeyboardControl: autoRepeat off\n"); + } + } } /******************************************************************************/ @@ -419,9 +467,9 @@ rdpMouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl) int rdpMouseProc(DeviceIntPtr pDevice, int onoff) { - BYTE map[6]; + BYTE map[8]; DevicePtr pDev; - Atom btn_labels[6]; + Atom btn_labels[8]; Atom axes_labels[2]; DEBUG_OUT_INPUT(("rdpMouseProc\n")); @@ -437,17 +485,21 @@ rdpMouseProc(DeviceIntPtr pDevice, int onoff) map[3] = 3; map[4] = 4; map[5] = 5; + map[6] = 6; + map[7] = 7; btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - InitPointerDeviceStruct(pDev, map, 5, btn_labels, rdpMouseCtrl, + InitPointerDeviceStruct(pDev, map, 7, btn_labels, rdpMouseCtrl, GetMotionHistorySize(), 2, axes_labels); break; @@ -961,9 +1013,13 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) if (x_scancode > 0) { + /* left or right shift */ + if ((rdp_scancode == 42) || (rdp_scancode == 54)) + { + g_shift_down = down ? x_scancode : 0; + } rdpEnqueueKey(type, x_scancode); } - break; case 56: /* left - right alt button */ @@ -977,6 +1033,7 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) x_scancode = 64; /* left alt button */ } + g_alt_down = down ? x_scancode : 0; rdpEnqueueKey(type, x_scancode); break; @@ -1110,6 +1167,14 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) rdpEnqueueKey(type, 117); break; + case 89: /* left meta */ + rdpEnqueueKey(type, 156); + break; + + case 90: /* right meta */ + rdpEnqueueKey(type, 156); + break; + default: x_scancode = rdp_scancode + MIN_KEY_CODE; diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index f1645cfe..20fe437d 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -24,6 +24,7 @@ Sets up the functions #include "rdp.h" #include "rdprandr.h" +#include "rdpglyph.h" #if 1 #define DEBUG_OUT(arg) @@ -46,7 +47,10 @@ DeviceIntPtr g_keyboard = 0; int g_can_do_pix_to_pix = 0; int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */ -int g_do_dirty_ons = 1; /* delay remoting screen */ +int g_do_dirty_ons = 0; /* delay remoting screen */ +int g_do_glyph_cache = 0; /* rdpup.c may set this */ +int g_do_alpha_glyphs = 1; +int g_do_composite = 0; /* rdpup.c may set this */ Bool g_wrapWindow = 1; Bool g_wrapPixmap = 1; @@ -60,6 +64,7 @@ int g_use_rail = 0; int g_con_number = 0; /* increments for each connection */ WindowPtr g_invalidate_window = 0; +int g_doing_font = 0; /* if true, use a unix domain socket instead of a tcp socket */ int g_use_uds = 0; @@ -273,7 +278,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) g_rdpScreen.sizeInBytes = (g_rdpScreen.paddedWidthInBytes * g_rdpScreen.height); ErrorF("buffer size %d\n", g_rdpScreen.sizeInBytes); - g_rdpScreen.pfbMemory = (char *)g_malloc(2048 * 2048 * 4, 1); + g_rdpScreen.pfbMemory = (char *)g_malloc(g_rdpScreen.sizeInBytes, 1); + g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes; } if (g_rdpScreen.pfbMemory == 0) @@ -397,6 +403,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) if (ps) { + g_rdpScreen.CreatePicture = ps->CreatePicture; + g_rdpScreen.DestroyPicture = ps->DestroyPicture; g_rdpScreen.Composite = ps->Composite; g_rdpScreen.Glyphs = ps->Glyphs; @@ -410,6 +418,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) if (ps) { + ps->CreatePicture = rdpCreatePicture; + ps->DestroyPicture = rdpDestroyPicture; ps->Composite = rdpComposite; ps->Glyphs = rdpGlyphs; } @@ -529,6 +539,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) } + rdpGlyphInit(); + //rdpXvInit(pScreen); ErrorF("rdpScreenInit: ret %d\n", ret); diff --git a/xorg/X11R7.6/rdp/rdpmisc.c b/xorg/X11R7.6/rdp/rdpmisc.c index dc54581a..eb5bedad 100644 --- a/xorg/X11R7.6/rdp/rdpmisc.c +++ b/xorg/X11R7.6/rdp/rdpmisc.c @@ -27,6 +27,59 @@ the rest Bool noFontCacheExtension = 1; +static int g_crc_seed = 0xffffffff; +static int g_crc_table[256] = +{ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +#define CRC_START(in_crc) (in_crc) = g_crc_seed +#define CRC_PASS(in_pixel, in_crc) \ + (in_crc) = g_crc_table[((in_crc) ^ (in_pixel)) & 0xff] ^ ((in_crc) >> 8) +#define CRC_END(in_crc) (in_crc) = ((in_crc) ^ g_crc_seed) + /******************************************************************************/ /* print a time-stamped message to the log file (stderr). */ void @@ -599,3 +652,19 @@ RegionAroundSegs(RegionPtr reg, xSegment *segs, int nseg) index++; } } + +/******************************************************************************/ +int +get_crc(char* data, int data_bytes) +{ + int crc; + int index; + + CRC_START(crc); + for (index = 0; index < data_bytes; index++) + { + CRC_PASS(data[index], crc); + } + CRC_END(crc); + return crc; +} diff --git a/xorg/X11R7.6/rdp/rdprandr.c b/xorg/X11R7.6/rdp/rdprandr.c index a767b1d8..8b3eb582 100644 --- a/xorg/X11R7.6/rdp/rdprandr.c +++ b/xorg/X11R7.6/rdp/rdprandr.c @@ -156,6 +156,13 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, ErrorF(" resizing screenPixmap [%p] to %dx%d, currently at %dx%d\n", (void *)screenPixmap, width, height, screenPixmap->drawable.width, screenPixmap->drawable.height); + if (g_rdpScreen.sizeInBytes > g_rdpScreen.sizeInBytesAlloc) + { + g_free(g_rdpScreen.pfbMemory); + g_rdpScreen.pfbMemory = (char*)g_malloc(g_rdpScreen.sizeInBytes, 1); + g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes; + ErrorF("new buffer size %d\n", g_rdpScreen.sizeInBytes); + } pScreen->ModifyPixmapHeader(screenPixmap, width, height, g_rdpScreen.depth, g_rdpScreen.bitsPerPixel, g_rdpScreen.paddedWidthInBytes, diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index c380f285..28919799 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -21,6 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "rdp.h" #include "xrdp_rail.h" +#include "rdpglyph.h" #include <signal.h> #include <sys/ipc.h> @@ -67,8 +68,10 @@ extern ScreenPtr g_pScreen; /* from rdpmain.c */ extern int g_Bpp; /* from rdpmain.c */ extern int g_Bpp_mask; /* from rdpmain.c */ extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern int g_do_glyph_cache; /* from rdpmain.c */ extern int g_can_do_pix_to_pix; /* from rdpmain.c */ extern int g_use_rail; /* from rdpmain.c */ +extern int g_do_composite; /* from rdpmain.c */ /* true is to use unix domain socket */ extern int g_use_uds; /* in rdpmain.c */ @@ -189,6 +192,7 @@ rdpup_disconnect(void) { int index; + LLOGLN(0, ("rdpup_disconnect:")); if (g_do_kill_disconnected) { if (!g_disconnect_scheduled) @@ -229,6 +233,8 @@ rdpup_disconnect(void) g_free(g_os_bitmaps); g_os_bitmaps = 0; g_use_rail = 0; + g_do_glyph_cache = 0; + g_do_composite = 0; return 0; } @@ -471,12 +477,14 @@ rdpup_send(char *data, int len) } else { + LLOGLN(0, ("rdpup_send: g_tcp_send failed(returned -1)")); rdpup_disconnect(); return 1; } } else if (sent == 0) { + LLOGLN(0, ("rdpup_send: g_tcp_send failed(returned zero)")); rdpup_disconnect(); return 1; } @@ -527,6 +535,9 @@ rdpup_send_msg(struct stream *s) static int rdpup_send_pending(void) { + int rv; + + rv = 0; if (g_connected && g_begin) { LLOGLN(10, ("end %d", g_count)); @@ -534,12 +545,16 @@ rdpup_send_pending(void) out_uint16_le(g_out_s, 4); g_count++; s_mark_end(g_out_s); - rdpup_send_msg(g_out_s); + if (rdpup_send_msg(g_out_s) != 0) + { + LLOGLN(0, ("rdpup_send_pending: rdpup_send_msg failed")); + rv = 1; + } } g_count = 0; g_begin = 0; - return 0; + return rv; } /******************************************************************************/ @@ -603,12 +618,14 @@ rdpup_recv(char *data, int len) } else { + LLOGLN(0, ("rdpup_recv: g_tcp_recv failed(returned -1)")); rdpup_disconnect(); return 1; } } else if (rcvd == 0) { + LLOGLN(0, ("rdpup_recv: g_tcp_recv failed(returned 0)")); rdpup_disconnect(); return 1; } @@ -872,6 +889,14 @@ rdpup_send_rail(void) return 0; } +#define XR_BUTTON1 1 +#define XR_BUTTON2 2 +#define XR_BUTTON3 4 +#define XR_BUTTON4 8 +#define XR_BUTTON5 16 +#define XR_BUTTON6 32 +#define XR_BUTTON7 64 + /******************************************************************************/ static int rdpup_process_msg(struct stream *s) @@ -920,44 +945,74 @@ rdpup_process_msg(struct stream *s) g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 101: - g_button_mask = g_button_mask & (~1); + case 101: /* left button up */ + g_button_mask = g_button_mask & (~XR_BUTTON1); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 102: - g_button_mask = g_button_mask | 1; + case 102: /* left button down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON1; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 103: - g_button_mask = g_button_mask & (~4); + case 103: /* right button up */ + g_button_mask = g_button_mask & (~XR_BUTTON3); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 104: - g_button_mask = g_button_mask | 4; + case 104: /* right button down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON3; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 105: - g_button_mask = g_button_mask & (~2); + case 105: /* middle button down */ + g_button_mask = g_button_mask & (~XR_BUTTON2); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 106: - g_button_mask = g_button_mask | 2; + case 106: /* middle button up */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON2; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 107: - g_button_mask = g_button_mask & (~8); + case 107: /* button 4 up */ + g_button_mask = g_button_mask & (~XR_BUTTON4); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 108: - g_button_mask = g_button_mask | 8; + case 108: /* button 4 down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON4; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 109: - g_button_mask = g_button_mask & (~16); + case 109: /* button 5 up */ + g_button_mask = g_button_mask & (~XR_BUTTON5); PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; - case 110: - g_button_mask = g_button_mask | 16; + case 110: /* button 5 down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON5; + PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); + break; + case 111: /* button 6 up */ + g_button_mask = g_button_mask & (~XR_BUTTON6); + PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); + break; + case 112: /* button 6 down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON6; + PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); + break; + case 113: /* button 7 up */ + g_button_mask = g_button_mask & (~XR_BUTTON7); + PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); + break; + case 114: /* button 7 down */ + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); + g_button_mask = g_button_mask | XR_BUTTON7; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 200: @@ -1008,8 +1063,27 @@ rdpup_process_msg(struct stream *s) if (g_rdpScreen.client_info.rail_support_level > 0) { g_use_rail = 1; +#ifdef XRDP_WM_RDPUP rdpup_send_rail(); +#endif + } + if (g_rdpScreen.client_info.orders[0x1b]) /* 27 NEG_GLYPH_INDEX_INDEX */ + { + g_do_glyph_cache = 1; + } + if (g_rdpScreen.client_info.order_flags_ex & 0x100) + { + g_do_composite = 1; + } + if (g_do_glyph_cache) + { + LLOGLN(0, (" using glyph cache")); } + if (g_do_composite) + { + LLOGLN(0, (" using client composite")); + } + LLOGLN(10, ("order_flags_ex 0x%x", g_rdpScreen.client_info.order_flags_ex)); if (g_rdpScreen.client_info.offscreen_cache_entries == 2000) { LLOGLN(0, (" client can do offscreen to offscreen blits")); @@ -1254,6 +1328,7 @@ rdpup_check(void) g_sck_closed = 0; g_begin = 0; g_con_number++; + rdpGlyphInit(); AddEnabledDevice(g_sck); if (g_dis_timer != 0) @@ -1341,6 +1416,9 @@ rdpup_end_update(void) int rdpup_pre_check(int in_size) { + int rv; + + rv = 0; if (!g_begin) { rdpup_begin_update(); @@ -1349,13 +1427,17 @@ rdpup_pre_check(int in_size) if ((g_out_s->p - g_out_s->data) > (g_out_s->size - (in_size + 20))) { s_mark_end(g_out_s); - rdpup_send_msg(g_out_s); + if (rdpup_send_msg(g_out_s) != 0) + { + LLOGLN(0, ("rdpup_pre_check: rdpup_send_msg failed")); + rv = 1; + } g_count = 0; init_stream(g_out_s, 0); s_push_layer(g_out_s, iso_hdr, 8); } - return 0; + return rv; } /******************************************************************************/ @@ -1581,6 +1663,25 @@ convert_pixels(void *src, void *dst, int num_pixels) /******************************************************************************/ int +alpha_pixels(void* src, void* dst, int num_pixels) +{ + unsigned int* src32; + unsigned char* dst8; + int index; + + src32 = (unsigned int*)src; + dst8 = (unsigned char*)dst; + for (index = 0; index < num_pixels; index++) + { + *dst8 = (*src32) >> 24; + dst8++; + src32++; + } + return 0; +} + +/******************************************************************************/ +int rdpup_set_fgcolor(int fgcolor) { if (g_connected) @@ -1752,6 +1853,26 @@ rdpup_create_os_surface(int rdpindex, int width, int height) /******************************************************************************/ int +rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp) +{ + LLOGLN(10, ("rdpup_create_os_surface_bpp:")); + if (g_connected) + { + LLOGLN(10, (" width %d height %d bpp %d", width, height, bpp)); + rdpup_pre_check(13); + out_uint16_le(g_out_s, 31); + out_uint16_le(g_out_s, 13); + g_count++; + out_uint32_le(g_out_s, rdpindex); + out_uint16_le(g_out_s, width); + out_uint16_le(g_out_s, height); + out_uint8(g_out_s, bpp); + } + return 0; +} + +/******************************************************************************/ +int rdpup_switch_os_surface(int rdpindex) { LLOGLN(10, ("rdpup_switch_os_surface:")); @@ -2023,7 +2144,7 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) } ly = y; - while (ly < y + h) + while ((ly < y + h) && g_connected) { lx = x; @@ -2075,6 +2196,103 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) } /******************************************************************************/ +/* split the bitmap up into 64 x 64 pixel areas */ +void +rdpup_send_alpha_area(struct image_data* id, int x, int y, int w, int h) +{ + char* s; + int i; + int lx; + int ly; + int lh; + int lw; + int size; + struct image_data lid; + + LLOGLN(10, ("rdpup_send_alpha_area: id %p x %d y %d w %d h %d", + id, x, y, w, h)); + if (id == 0) + { + rdpup_get_screen_image_rect(&lid); + id = &lid; + } + + if (x >= id->width) + { + return; + } + if (y >= id->height) + { + return; + } + if (x < 0) + { + w += x; + x = 0; + } + if (y < 0) + { + h += y; + y = 0; + } + if (w <= 0) + { + return; + } + if (h <= 0) + { + return; + } + if (x + w > id->width) + { + w = id->width - x; + } + if (y + h > id->height) + { + h = id->height - y; + } + LLOGLN(10, ("%d", w * h)); + if (g_connected && g_begin) + { + LLOGLN(10, (" rdpup_send_area")); + ly = y; + while ((ly < y + h) && g_connected) + { + lx = x; + while ((lx < x + w) && g_connected) + { + lw = MIN(64, (x + w) - lx); + lh = MIN(64, (y + h) - ly); + size = lw * lh + 25; + rdpup_pre_check(size); + out_uint16_le(g_out_s, 32); /* server_paint_rect_bpp */ + out_uint16_le(g_out_s, size); + g_count++; + out_uint16_le(g_out_s, lx); + out_uint16_le(g_out_s, ly); + out_uint16_le(g_out_s, lw); + out_uint16_le(g_out_s, lh); + out_uint32_le(g_out_s, lw * lh); + for (i = 0; i < lh; i++) + { + s = (id->pixels + + ((ly + i) * id->lineBytes) + (lx * g_Bpp)); + alpha_pixels(s, g_out_s->p, lw); + g_out_s->p += lw; + } + out_uint16_le(g_out_s, lw); + out_uint16_le(g_out_s, lh); + out_uint16_le(g_out_s, 0); + out_uint16_le(g_out_s, 0); + out_uint8(g_out_s, 8); + lx += 64; + } + ly += 64; + } + } +} + +/******************************************************************************/ void rdpup_paint_rect_os(int x, int y, int cx, int cy, int rdpindex, int srcx, int srcy) @@ -2165,7 +2383,7 @@ rdpup_create_window(WindowPtr pWindow, rdpWindowRec *priv) out_uint32_le(g_out_s, style); /* style */ out_uint32_le(g_out_s, ext_style); /* extended_style */ flags |= WINDOW_ORDER_FIELD_STYLE; - out_uint32_le(g_out_s, 0); /* show_state */ + out_uint32_le(g_out_s, 0x05); /* show_state */ flags |= WINDOW_ORDER_FIELD_SHOW; out_uint16_le(g_out_s, title_bytes); /* title_info */ out_uint8a(g_out_s, title, title_bytes); @@ -2236,6 +2454,27 @@ rdpup_delete_window(WindowPtr pWindow, rdpWindowRec *priv) } /******************************************************************************/ +void +rdpup_show_window(WindowPtr pWindow, rdpWindowRec* priv, int showState) +{ + LLOGLN(10, ("rdpup_show_window: id 0x%8.8x state 0x%x", pWindow->drawable.id, + showState)); + if (g_connected) + { + int flags = WINDOW_ORDER_TYPE_WINDOW; + + rdpup_pre_check(16); + out_uint16_le(g_out_s, 27); + out_uint16_le(g_out_s, 16); + g_count++; + out_uint32_le(g_out_s, pWindow->drawable.id); + flags |= WINDOW_ORDER_FIELD_SHOW; + out_uint32_le(g_out_s, flags); + out_uint32_le(g_out_s, showState); + } +} + +/******************************************************************************/ int rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) { @@ -2247,6 +2486,8 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) xSegment *seg; struct image_data id; struct rdp_draw_item *di; + struct rdp_text* rtext; + struct rdp_text* trtext; if (pDirtyPriv == 0) { @@ -2349,6 +2590,37 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) case RDI_SCRBLT: LLOGLN(10, (" RDI_SCRBLT")); break; + case RDI_TEXT: + LLOGLN(10, (" RDI_TEXT")); + num_clips = REGION_NUM_RECTS(di->reg); + if (num_clips > 0) + { + LLOGLN(10, (" num_clips %d", num_clips)); + rdpup_set_fgcolor(di->u.text.fg_color); + rdpup_set_opcode(di->u.text.opcode); + rtext = di->u.text.rtext; + trtext = rtext; + while (trtext != 0) + { + rdp_text_chars_to_data(trtext); + for (clip_index = num_clips - 1; clip_index >= 0; clip_index--) + { + box = REGION_RECTS(di->reg)[clip_index]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, (" %d %d %d %d", box.x1, box.y1, box.x2, box.y2)); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1, box.y1, box.x2, box.y2, + //box.x1, box.y1, box.x2, box.y2, + 0, 0, 0, 0, + trtext->x, trtext->y, trtext->data, trtext->data_bytes); + } + trtext = trtext->next; + } + } + rdpup_reset_clip(); + rdpup_set_opcode(GXcopy); + break; } di = di->next; @@ -2484,3 +2756,171 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv) pDirtyPriv->is_dirty = 0; return 0; } + +/******************************************************************************/ +int +rdpup_check_alpha_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv) +{ + struct image_data id; + + LLOGLN(10, ("rdpup_check_alpha_dirty: width %d height %d", + pDirtyPixmap->drawable.width, pDirtyPixmap->drawable.height)); + if (pDirtyPriv == 0) + { + return 0; + } + LLOGLN(10, ("rdpup_check_alpha_dirty: is_alpha_dirty_not %d", + pDirtyPriv->is_alpha_dirty_not)); + if (pDirtyPriv->is_alpha_dirty_not) + { + return 0; + } + pDirtyPriv->is_alpha_dirty_not = 1; + rdpup_switch_os_surface(pDirtyPriv->rdpindex); + rdpup_get_pixmap_image_rect(pDirtyPixmap, &id); + rdpup_begin_update(); + rdpup_send_alpha_area(&id, 0, 0, pDirtyPixmap->drawable.width, + pDirtyPixmap->drawable.height); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + return 0; +} + +/******************************************************************************/ +int +rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_add_char")); + rdpup_pre_check(18 + bmpdata_bytes); + out_uint16_le(g_out_s, 28); /* add char */ + out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, charactor); + 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_uint16_le(g_out_s, bmpdata_bytes); + out_uint8a(g_out_s, bmpdata, bmpdata_bytes); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_add_char_alpha")); + rdpup_pre_check(18 + bmpdata_bytes); + out_uint16_le(g_out_s, 29); /* add char alpha */ + out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, charactor); + 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_uint16_le(g_out_s, bmpdata_bytes); + out_uint8a(g_out_s, bmpdata, bmpdata_bytes); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_draw_text(int font, int flags, int mixmode, + short clip_left, short clip_top, + short clip_right, short clip_bottom, + short box_left, short box_top, + short box_right, short box_bottom, short x, short y, + char* data, int data_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_draw_text")); + rdpup_pre_check(32 + data_bytes); + out_uint16_le(g_out_s, 30); /* draw text */ + out_uint16_le(g_out_s, 32 + data_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, flags); + out_uint16_le(g_out_s, mixmode); + out_uint16_le(g_out_s, clip_left); + out_uint16_le(g_out_s, clip_top); + out_uint16_le(g_out_s, clip_right); + out_uint16_le(g_out_s, clip_bottom); + out_uint16_le(g_out_s, box_left); + out_uint16_le(g_out_s, box_top); + out_uint16_le(g_out_s, box_right); + out_uint16_le(g_out_s, box_bottom); + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, data_bytes); + out_uint8a(g_out_s, data, data_bytes); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, + PictTransform* srctransform, CARD8 mskflags, + short mskidx, int mskformat, short mskwidth, CARD8 mskrepeat, + CARD8 op, short srcx, short srcy, short mskx, short msky, + short dstx, short dsty, short width, short height, + int dstformat) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_composite")); + rdpup_pre_check(84); + out_uint16_le(g_out_s, 33); + out_uint16_le(g_out_s, 84); /* size */ + g_count++; + out_uint16_le(g_out_s, srcidx); + out_uint32_le(g_out_s, srcformat); + out_uint16_le(g_out_s, srcwidth); + out_uint8(g_out_s, srcrepeat); + if (srctransform == 0) + { + out_uint8s(g_out_s, 10 * 4); + } + else + { + out_uint32_le(g_out_s, 1); + out_uint32_le(g_out_s, srctransform->matrix[0][0]); + out_uint32_le(g_out_s, srctransform->matrix[0][1]); + out_uint32_le(g_out_s, srctransform->matrix[0][2]); + out_uint32_le(g_out_s, srctransform->matrix[1][0]); + out_uint32_le(g_out_s, srctransform->matrix[1][1]); + out_uint32_le(g_out_s, srctransform->matrix[1][2]); + out_uint32_le(g_out_s, srctransform->matrix[2][0]); + out_uint32_le(g_out_s, srctransform->matrix[2][1]); + out_uint32_le(g_out_s, srctransform->matrix[2][2]); + } + out_uint8(g_out_s, mskflags); + out_uint16_le(g_out_s, mskidx); + out_uint32_le(g_out_s, mskformat); + out_uint16_le(g_out_s, mskwidth); + out_uint8(g_out_s, mskrepeat); + out_uint8(g_out_s, op); + out_uint16_le(g_out_s, srcx); + out_uint16_le(g_out_s, srcy); + out_uint16_le(g_out_s, mskx); + out_uint16_le(g_out_s, msky); + out_uint16_le(g_out_s, dstx); + out_uint16_le(g_out_s, dsty); + out_uint16_le(g_out_s, width); + out_uint16_le(g_out_s, height); + out_uint32_le(g_out_s, dstformat); + } + return 0; +} |