Bool rdpDestroyPixmap(PixmapPtr pPixmap) { Bool rv; ScreenPtr pScreen; rdpPixmapRec *priv; LLOGLN(10, ("rdpDestroyPixmap:")); priv = GETPIXPRIV(pPixmap); LLOGLN(10, ("status %d refcnt %d", priv->status, pPixmap->refcnt)); if (pPixmap->refcnt < 2) { if (XRDP_IS_OS(priv)) { rdpup_remove_os_bitmap(priv->rdpindex); rdpup_delete_os_surface(priv->rdpindex); draw_item_remove_all(priv); } } pScreen = pPixmap->drawable.pScreen; pScreen->DestroyPixmap = g_rdpScreen.DestroyPixmap; rv = pScreen->DestroyPixmap(pPixmap); pScreen->DestroyPixmap = rdpDestroyPixmap; return rv; }
int xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) { RegionRec reg1; BoxRec box; int width; int height; struct image_data id; if (!XRDP_IS_OS(priv)) { width = pix->drawable.width; height = pix->drawable.height; if ((pix->usage_hint == 0) && (pix->drawable.depth >= g_rdpScreen.depth) && (width > 1) && (height > 1) && (priv->kind_width > 0)) { LLOGLN(10, ("%d %d", priv->kind_width, pix->drawable.width)); 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); box.x1 = 0; box.y1 = 0; box.x2 = width; box.y2 = height; if (g_do_dirty_os) { if (priv->con_number != g_con_number) { draw_item_remove_all(priv); RegionInit(®1, &box, 0); draw_item_add_img_region(priv, ®1, GXcopy, RDI_IMGLL); RegionUninit(®1); priv->is_dirty = 1; priv->con_number = g_con_number; } } else { rdpup_get_pixmap_image_rect(pix, &id); rdpup_switch_os_surface(priv->rdpindex); rdpup_begin_update(); rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); rdpup_switch_os_surface(-1); } return 1; } } return 0; } return 1; }
void rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs) { RegionRec clip_reg; int cd; int i; int j; int got_id; xSegment* segs; BoxRec box; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpPolySegment:")); segs = 0; if (nseg) /* get the rects */ { segs = (xSegment*)g_malloc(nseg * sizeof(xSegment), 0); for (i = 0; i < nseg; i++) { segs[i].x1 = pSegs[i].x1 + pDrawable->x; segs[i].y1 = pSegs[i].y1 + pDrawable->y; segs[i].x2 = pSegs[i].x2 + pDrawable->x; segs[i].y2 = pSegs[i].y2 + pDrawable->y; } } /* do original call */ rdpPolySegmentOrg(pDrawable, pGC, nseg, pSegs); got_id = 0; if (pDrawable->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDrawable; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDrawable->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDrawable; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { g_free(segs); return; } RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDrawable, pGC); if (cd == 1) /* no clip */ { if (segs != 0) { rdpup_begin_update(); rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); rdpup_set_pen(0, pGC->lineWidth); for (i = 0; i < nseg; i++) { rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); } rdpup_set_opcode(GXcopy); rdpup_end_update(); } } else if (cd == 2) /* clip */ { if (segs != 0) { rdpup_begin_update(); rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); rdpup_set_pen(0, pGC->lineWidth); for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); for (i = 0; i < nseg; i++) { rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2); } } rdpup_reset_clip(); rdpup_set_opcode(GXcopy); rdpup_end_update(); } } g_free(segs); RegionUninit(&clip_reg); rdpup_switch_os_surface(-1); }
void rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr* ppci, pointer pglyphBase) { RegionRec reg; RegionRec reg1; int num_clips; int cd; int j; int got_id; BoxRec box; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpPolyGlyphBlt:")); if (nglyph != 0) { GetTextBoundingBox(pDrawable, pGC->font, x, y, nglyph, &box); } /* do original call */ rdpPolyGlyphBltOrg(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); got_id = 0; if (pDrawable->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDrawable; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDrawable->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDrawable; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { return; } RegionInit(®, NullBox, 0); if (nglyph == 0) { cd = 0; } else { cd = rdp_get_clip(®, pDrawable, pGC); } if (cd == 1) { rdpup_begin_update(); rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } else if (cd == 2) { RegionInit(®1, &box, 0); RegionIntersect(®, ®, ®1); num_clips = REGION_NUM_RECTS(®); if (num_clips > 0) { rdpup_begin_update(); for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(®)[j]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } RegionUninit(®1); } RegionUninit(®); rdpup_switch_os_surface(-1); return; }
void rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) { RegionRec clip_reg; int num_clips; int cd; int i; int j; int x1; int y1; int x2; int y2; int got_id; BoxRec box; DDXPointPtr ppts; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpPolylines:")); ppts = 0; if (npt > 0) { ppts = (DDXPointPtr)g_malloc(sizeof(DDXPointRec) * npt, 0); for (i = 0; i < npt; i++) { ppts[i] = pptInit[i]; } } /* do original call */ rdpPolylinesOrg(pDrawable, pGC, mode, npt, pptInit); got_id = 0; if (pDrawable->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDrawable; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDrawable->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDrawable; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { g_free(ppts); return; } RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDrawable, pGC); if (cd == 1) { if (ppts != 0) { rdpup_begin_update(); rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); rdpup_set_pen(0, pGC->lineWidth); x1 = ppts[0].x + pDrawable->x; y1 = ppts[0].y + pDrawable->y; for (i = 1; i < npt; i++) { if (mode == CoordModeOrigin) { x2 = pDrawable->x + ppts[i].x; y2 = pDrawable->y + ppts[i].y; } else { x2 = x1 + ppts[i].x; y2 = y1 + ppts[i].y; } rdpup_draw_line(x1, y1, x2, y2); x1 = x2; y1 = y2; } rdpup_set_opcode(GXcopy); rdpup_end_update(); } } else if (cd == 2) { num_clips = REGION_NUM_RECTS(&clip_reg); if (ppts != 0 && num_clips > 0) { rdpup_begin_update(); rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); rdpup_set_pen(0, pGC->lineWidth); for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); x1 = ppts[0].x + pDrawable->x; y1 = ppts[0].y + pDrawable->y; for (i = 1; i < npt; i++) { if (mode == CoordModeOrigin) { x2 = pDrawable->x + ppts[i].x; y2 = pDrawable->y + ppts[i].y; } else { x2 = x1 + ppts[i].x; y2 = y1 + ppts[i].y; } rdpup_draw_line(x1, y1, x2, y2); x1 = x2; y1 = y2; } } rdpup_reset_clip(); rdpup_set_opcode(GXcopy); rdpup_end_update(); } } RegionUninit(&clip_reg); g_free(ppts); rdpup_switch_os_surface(-1); }
RegionPtr rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty, unsigned long bitPlane) { RegionPtr rv; RegionRec clip_reg; RegionRec box_reg; int cd; int num_clips; int j; int got_id; BoxRec box; BoxPtr pbox; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpCopyPlane:")); /* do original call */ rv = rdpCopyPlaneOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, bitPlane); got_id = 0; if (pDst->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDst; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDst->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDst; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { return rv; } RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDst, pGC); if (cd == 1) { rdpup_begin_update(); rdpup_send_area(&id, pDst->x + dstx, pDst->y + dsty, w, h); rdpup_end_update(); } else if (cd == 2) { num_clips = REGION_NUM_RECTS(&clip_reg); if (num_clips > 0) { rdpup_begin_update(); box.x1 = pDst->x + dstx; box.y1 = pDst->y + dsty; box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(&box_reg, &box, 0); RegionIntersect(&clip_reg, &clip_reg, &box_reg); num_clips = REGION_NUM_RECTS(&clip_reg); if (num_clips < 10) { for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } } else { pbox = RegionExtents(&clip_reg); rdpup_send_area(&id, pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); } RegionUninit(&box_reg); rdpup_end_update(); } } RegionUninit(&clip_reg); return rv; }
/* 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 j; int num_clips; int got_id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; struct image_data id; LLOGLN(10, ("rdpComposite:")); ps = GetPictureScreen(g_pScreen); ps->Composite = g_rdpScreen.Composite; ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); ps->Composite = rdpComposite; p = pDst->pDrawable; got_id = 0; if (p->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)p; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (p->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)p; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { return; } if (pDst->clientClipType == CT_REGION) { box.x1 = p->x + xDst; box.y1 = p->y + yDst; box.x2 = box.x1 + width; box.y2 = box.y1 + height; RegionInit(®1, &box, 0); RegionInit(®2, NullBox, 0); RegionCopy(®2, pDst->clientClip); RegionTranslate(®2, p->x + pDst->clipOrigin.x, p->y + pDst->clipOrigin.y); RegionIntersect(®1, ®1, ®2); 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; rdpup_begin_update(); rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); rdpup_end_update(); } rdpup_switch_os_surface(-1); }
void rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle* prectInit) { int j; int cd; int num_clips; RegionRec clip_reg; RegionPtr fill_reg; BoxRec box; int got_id; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpPolyFillRect:")); /* make a copy of rects */ fill_reg = RegionFromRects(nrectFill, prectInit, CT_NONE); /* do original call */ rdpPolyFillRectOrg(pDrawable, pGC, nrectFill, prectInit); got_id = 0; if (pDrawable->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDrawable; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDrawable->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDrawable; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { RegionDestroy(fill_reg); return; } RegionTranslate(fill_reg, pDrawable->x, pDrawable->y); RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDrawable, pGC); if (cd == 1) /* no clip */ { rdpup_begin_update(); if (pGC->fillStyle == 0 && /* solid fill */ (pGC->alu == GXclear || pGC->alu == GXset || pGC->alu == GXinvert || pGC->alu == GXnoop || pGC->alu == GXand || pGC->alu == GXcopy /*|| pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ { rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--) { box = REGION_RECTS(fill_reg)[j]; rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_set_opcode(GXcopy); } else /* non solid fill */ { for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--) { box = REGION_RECTS(fill_reg)[j]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } } rdpup_end_update(); } else if (cd == 2) /* clip */ { RegionIntersect(&clip_reg, &clip_reg, fill_reg); num_clips = REGION_NUM_RECTS(&clip_reg); if (num_clips > 0) { rdpup_begin_update(); if (pGC->fillStyle == 0 && /* solid fill */ (pGC->alu == GXclear || pGC->alu == GXset || pGC->alu == GXinvert || pGC->alu == GXnoop || pGC->alu == GXand || pGC->alu == GXcopy /*|| pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */ { rdpup_set_fgcolor(pGC->fgPixel); rdpup_set_opcode(pGC->alu); for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_set_opcode(GXcopy); } else /* non solid fill */ { for (j = num_clips - 1; j >= 0; j--) { box = REGION_RECTS(&clip_reg)[j]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } } rdpup_end_update(); } } RegionUninit(&clip_reg); RegionDestroy(fill_reg); rdpup_switch_os_surface(-1); }
void rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs) { RegionRec clip_reg; RegionPtr tmpRegion; int cd; int lw; int extra; int i; int num_clips; int got_id; xRectangle* rects; BoxRec box; struct image_data id; WindowPtr pDstWnd; PixmapPtr pDstPixmap; rdpPixmapRec* pDstPriv; LLOGLN(10, ("rdpPolyArc:")); rects = 0; if (narcs > 0) { rects = (xRectangle*)g_malloc(narcs * sizeof(xRectangle), 0); lw = pGC->lineWidth; if (lw == 0) { lw = 1; } extra = lw / 2; for (i = 0; i < narcs; i++) { rects[i].x = (parcs[i].x - extra) + pDrawable->x; rects[i].y = (parcs[i].y - extra) + pDrawable->y; rects[i].width = parcs[i].width + lw; rects[i].height = parcs[i].height + lw; } } /* do original call */ rdpPolyArcOrg(pDrawable, pGC, narcs, parcs); got_id = 0; if (pDrawable->type == DRAWABLE_PIXMAP) { pDstPixmap = (PixmapPtr)pDrawable; pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { rdpup_switch_os_surface(pDstPriv->rdpindex); rdpup_get_pixmap_image_rect(pDstPixmap, &id); got_id = 1; } } else { if (pDrawable->type == DRAWABLE_WINDOW) { pDstWnd = (WindowPtr)pDrawable; if (pDstWnd->viewable) { rdpup_get_screen_image_rect(&id); got_id = 1; } } } if (!got_id) { g_free(rects); return; } RegionInit(&clip_reg, NullBox, 0); cd = rdp_get_clip(&clip_reg, pDrawable, pGC); if (cd == 1) { if (rects != 0) { tmpRegion = RegionFromRects(narcs, rects, CT_NONE); num_clips = REGION_NUM_RECTS(tmpRegion); if (num_clips > 0) { rdpup_begin_update(); for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } RegionDestroy(tmpRegion); } } else if (cd == 2) { if (rects != 0) { tmpRegion = RegionFromRects(narcs, rects, CT_NONE); RegionIntersect(tmpRegion, tmpRegion, &clip_reg); num_clips = REGION_NUM_RECTS(tmpRegion); if (num_clips > 0) { rdpup_begin_update(); for (i = num_clips - 1; i >= 0; i--) { box = REGION_RECTS(tmpRegion)[i]; rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); } rdpup_end_update(); } RegionDestroy(tmpRegion); } } RegionUninit(&clip_reg); g_free(rects); rdpup_switch_os_surface(-1); }