Пример #1
0
void SetViewPort (int X1,int Y1,int X2,int Y2, int Clip) 
{
   Ox = X1;
   Oy = Y1;
   vp.x1=X1;
   vp.y1=Y1;
   vp.x2=X2;
   vp.y2=Y2;
   vp.clip=Clip;

   if (Clip) {
      XRectangle xr;
      xr.x=X1;
      xr.y=Y1;
      xr.width=X2-X1+1;
      xr.height=Y2-Y1+1;
      XSetClipRectangles(dpy, gc, 0, 0, &xr, 1, Unsorted);
      XSetClipRectangles(dpy, gcfill, 0, 0, &xr, 1, Unsorted);
      XSetClipRectangles(dpy, gcpixel, 0, 0, &xr, 1, Unsorted);
   } else {
      XSetClipMask(dpy, gc, None);
      XSetClipMask(dpy, gcfill, None);
      XSetClipMask(dpy, gcpixel, None);
   }
}
Пример #2
0
void Painter::Clip(
    Canvas* c, IntCoord left, IntCoord bottom, IntCoord right, IntCoord top
) {
    XRectangle& r = rep->xclip[0];
    IntCoord x, y;
    XDisplay* d = rep->display->rep()->display_;

    if (left > right) {
	x = right; r.width = left - right + 1;
    } else {
	x = left; r.width = right - left + 1;
    }
    if (bottom > top) {
	y = bottom; r.height = bottom - top + 1;
    } else {
	y = top; r.height = top - bottom + 1;
    }
    r.x = x;
    r.y = c->pheight() - 1 - y;
    if (r.x == 0 && r.y == 0 &&
	r.width == c->pwidth() && r.height == c->pheight()
    ) {
	/* clipping to entire canvas is equivalent to no clipping at all */
	NoClip();
    } else {
	rep->clipped = true;
	XSetClipRectangles(d, rep->fillgc, 0, 0, rep->xclip, 1, Unsorted);
	XSetClipRectangles(d, rep->dashgc, 0, 0, rep->xclip, 1, Unsorted);
    }
}
Пример #3
0
/**********************************************************************
 *	XG_SETCLIP
 *	- sets clipping mask for all gc's
 **********************************************************************/
void xg_setclip(void *xgid, int x, int y, int width, int height) {
	struct xg_graphic *graphic;
	XRectangle rectangle[1];

	/* set up rectangle */
	rectangle[0].x = x;
	rectangle[0].y = y;
	rectangle[0].width = width;
	rectangle[0].height = height;

	/* set clip rectangle */
	graphic = (struct xg_graphic *)xgid;
	XSetClipRectangles(graphic->dpy, graphic->gc_solid, 0, 0, rectangle, 1, Unsorted);
	XSetClipRectangles(graphic->dpy, graphic->gc_dash, 0, 0, rectangle, 1, Unsorted);
}
Пример #4
0
Файл: gcs.c Проект: deadpixi/sam
/*
 * GCs are all for same screen, and depth is either 1 or screen depth.
 * Return a GC for the depth of b, with values as specified by gcv.
 *
 * Also, set (or unset) the clip rectangle if necessary.
 * (This implementation should be improved if setting a clip rectangle is not rare).
 */
GC
_getgc(Bitmap *b, uint64_t gcvm, XGCValues *pgcv)
{
    static GC gc0, gcn;
    static bool clipset = false;
    GC g;
    XRectangle xr;

    g = (b->ldepth==0)? gc0 : gcn;
    if(!g){
        g = XCreateGC(_dpy, (Drawable)b->id, gcvm, pgcv);
        if(b->ldepth==0)
            gc0 = g;
        else
            gcn = g;
    } else
        XChangeGC(_dpy, g, gcvm, pgcv);
    if(b->flag&CLIP){
        xr.x = b->clipr.min.x;
        xr.y = b->clipr.min.y;
        xr.width = Dx(b->clipr);
        xr.height = Dy(b->clipr);
        if(b->flag&SHIFT){
            xr.x -= b->r.min.x;
            xr.y -= b->r.min.y;
        }
        XSetClipRectangles(_dpy, g, 0, 0, &xr, 1, YXBanded);
        clipset = true;
    }else if(clipset){
        pgcv->clip_mask = None;
        XChangeGC(_dpy, g, GCClipMask, pgcv);
        clipset = false;
    }
    return g;
}
Пример #5
0
void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
    if (d_ptr->device.isNull())
        return;

    QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
    QRegion wrgn(rgn);
    QRect br = rgn.boundingRect();
    if (!wOffset.isNull())
        wrgn.translate(-wOffset);
    QRect wbr = wrgn.boundingRect();

    int num;
    XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
    if (num <= 0)
        return;
//         qDebug() << "XSetClipRectangles";
//         for  (int i = 0; i < num; ++i)
//             qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
    if (num != 1)
        XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded);
    XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
              br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
    if (num != 1)
        XSetClipMask(X11->display, gc, XNone);
}
Пример #6
0
// This can be improved by collecting the dirty regions and painting
// when the event loop goes idle
void pxWindowNative::invalidateRectInternal(pxRect *r)
{
    Display* display = mDisplayRef.getDisplay();
    GC gc=XCreateGC(display, win, 0, NULL);
                
    pxSurfaceNativeDesc d;
    d.display = display;
    d.drawable = win;
    d.gc = gc;
    
    if (r)
    {
	// Set up clip area
	XRectangle xr;
	xr.x = r->left();
	xr.y = r->top();
	xr.width = r->width();
	xr.height = r->height();
	XSetClipRectangles(display, gc, 0, 0, &xr, 1, Unsorted);
    }

    onDraw(&d);
    
    XFreeGC(display, gc);

}
Пример #7
0
static PyObject *
PaxGC_SetClipRectangles(PaxGCObject *self, PyObject*args)
{
	int arg1;
	int arg2;
	PyObject *arg3; XRectangle *rects_arg3; int nrects_arg3;
	int arg4;
	if (self->shared) {
		PyErr_SetString(PyExc_TypeError, "can't modify shared GC");
		return NULL;
	}
	if (!PyArg_ParseTuple(args, "iiOi",
			&arg1,
			&arg2,
			&arg3,
			&arg4))
		return NULL;
	if (!checkshortlist(4, arg3, (short**)&rects_arg3, &nrects_arg3)) {
		if (!PyErr_Occurred())
			PyErr_SetString(PyExc_TypeError, "arg3 should be XRectangle[]");
		return NULL;
	}
XSetClipRectangles(self->display, self->gc,
			arg1,
			arg2,
			rects_arg3, nrects_arg3,
			arg4);
	PyMem_Free(rects_arg3);
	Py_INCREF(Py_None);
	return Py_None;
}
Пример #8
0
void QX11WindowSurface::setGeometry(const QRect &rect)
{
    QWindowSurface::setGeometry(rect);

    const QSize size = rect.size();

    if (d_ptr->device.size() == size || size.width() <= 0 || size.height() <= 0)
        return;
#ifndef QT_NO_XRENDER
    if (d_ptr->translucentBackground) {
        QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
        data->xinfo = d_ptr->widget->x11Info();
        data->resize(size.width(), size.height());
        d_ptr->device = QPixmap(data);
    } else
#endif
    {
        QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());

        QX11PixmapData *oldData = static_cast<QX11PixmapData *>(d_ptr->device.pixmapData());

        if (oldData && !(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) {
            // Copy the content of the old pixmap into the new one.
            QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType);
            newData->resize(size.width(), size.height());
            Q_ASSERT(oldData->d == newData->d);

            QRegion staticRegion(staticContents());
            // Make sure we're inside the boundaries of the old pixmap.
            staticRegion &= QRect(0, 0, oldData->w, oldData->h);
            const QRect boundingRect(staticRegion.boundingRect());
            const int dx = boundingRect.x();
            const int dy = boundingRect.y();

            int num;
            XRectangle *rects = (XRectangle *)qt_getClipRects(staticRegion, num);
            GC tmpGc = XCreateGC(X11->display, oldData->hd, 0, 0);
            XSetClipRectangles(X11->display, tmpGc, 0, 0, rects, num, YXBanded);
            XCopyArea(X11->display, oldData->hd, newData->hd, tmpGc,
                      dx, dy, qMin(boundingRect.width(), size.width()),
                      qMin(boundingRect.height(), size.height()), dx, dy);
            XFreeGC(X11->display, tmpGc);
            newData->flags &= ~QX11PixmapData::Uninitialized;

            d_ptr->device = QPixmap(newData);
        } else {
            d_ptr->device = QPixmap(size);
        }
    }

    if (gc) {
        XFreeGC(X11->display, gc);
        gc = 0;
    }
    if (!d_ptr->device.isNull()) {
        gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
        XSetGraphicsExposures(X11->display, gc, False);
    }
}
Пример #9
0
void iupDrawSetClipRect(IdrawCanvas* dc, int x1, int y1, int x2, int y2)
{
    XRectangle rect;
    rect.x      = (short)x1;
    rect.y      = (short)y1;
    rect.width  = (unsigned short)(x2-x1+1);
    rect.height = (unsigned short)(y2-y1+1);
    XSetClipRectangles(iupmot_display, dc->pixmap_gc, 0, 0, &rect, 1, Unsorted);
}
Пример #10
0
void  sg_setClip(int x1,int y1,int x2,int y2)
{
  XRectangle rects;
  rects.x=x1;
  rects.y=y1;
  rects.width=x2-x1+1;
  rects.height=y2-y1+1;
  XSetClipRectangles(display,gc,0,0,&rects,1,Unsorted);
}
Пример #11
0
Файл: plot.c Проект: rhdunn/sptk
static void clip(int xmin, int ymin, int xmax, int ymax)
{
   rect.x = xmin;
   rect.y = ymin;
   rect.width = xmax - xmin;
   rect.height = ymax - ymin;

   XSetClipRectangles(display, gc, 0, 0, &rect, 1, Unsorted);
}
static void
XawMultiSinkResize(Widget w)
{
    TextWidget ctx = (TextWidget)XtParent(w);
    MultiSinkObject sink = (MultiSinkObject)w;
    XRectangle rect;
    int width, height;

    if (w->core.widget_class != multiSinkObjectClass)
	return;

    rect.x = ctx->text.r_margin.left;
    rect.y = ctx->text.r_margin.top;
    width = (int)XtWidth(ctx) -
      (int)ctx->text.r_margin.right - (int)ctx->text.r_margin.left;
    height = (int)XtHeight(ctx) -
      (int)ctx->text.r_margin.top - (int)ctx->text.r_margin.bottom;
    rect.width = width;
    rect.height = height;

    if (sink->multi_sink.normgc) {
	if (width >= 0 && height >= 0)
	    XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.normgc,
			       0, 0, &rect, 1, Unsorted);
	else
	    XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.normgc, None);
    }
    if (sink->multi_sink.invgc) {
	if (width >= 0 && height >= 0)
	    XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.invgc,
			       0, 0, &rect, 1, Unsorted);
	else
	    XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.invgc, None);
    }
    if (sink->multi_sink.xorgc) {
	if (width >= 0 && height >= 0)
	    XSetClipRectangles(XtDisplay((Widget)ctx), sink->multi_sink.xorgc,
			       0, 0, &rect, 1, Unsorted);
	else
	    XSetClipMask(XtDisplay((Widget)ctx), sink->multi_sink.xorgc, None);
    }
}
Пример #13
0
static PetscErrorCode PetscDrawSetViewport_X(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr)
{
  PetscDraw_X* XiWin = (PetscDraw_X*)draw->data;
  XRectangle   box;

  PetscFunctionBegin;
  box.x = (int)(xl*XiWin->w);   box.y = (int)((1.0-yr)*XiWin->h);
  box.width = (int)((xr-xl)*XiWin->w);box.height = (int)((yr-yl)*XiWin->h);
  XSetClipRectangles(XiWin->disp,XiWin->gc.set,0,0,&box,1,Unsorted);
  PetscFunctionReturn(0);
}
Пример #14
0
static void
surface_scissor(XSurface *surf, float x, float y, float w, float h)
{
    XRectangle clip_rect;
    clip_rect.x = (short)(x - 1);
    clip_rect.y = (short)(y - 1);
    clip_rect.width = (unsigned short)(w + 2);
    clip_rect.height = (unsigned short)(h + 2);
    clip_rect.width = (unsigned short)MIN(surf->w, clip_rect.width);
    clip_rect.height = (unsigned short)MIN(surf->h, clip_rect.height);
    XSetClipRectangles(surf->dpy, surf->gc, 0, 0, &clip_rect, 1, Unsorted);
}
Пример #15
0
void MSToggleButtonBase::configure(void)
{
  int Xoffset=highlightThickness()+shadowThickness()+margin()+textHeight()+spacing();
  int Yoffset=highlightThickness()+shadowThickness()+margin();
  XRectangle clipRect[1];
  clipRect[0].x=0;
  clipRect[0].y=0;     
  clipRect[0].width=drawWidth();
  clipRect[0].height=drawHeight();
  XSetClipRectangles(display(),textGC(),Xoffset,Yoffset,&clipRect[0],1,Unsorted);
  redraw();
}
Пример #16
0
void
JXGC::SetClipRect
	(
	const JRect& clipRect
	)
{
	ClearPrivateClipping();

	XRectangle xrect = JXJToXRect(clipRect);
	itsClipRegion    = JXRectangleRegion(&xrect);
	itsClipOffset    = JPoint(0,0);
	XSetClipRectangles(*itsDisplay, itsXGC, 0,0, &xrect, 1, Unsorted);
}
Пример #17
0
void draw_text_box(char *txt,int w,int h,int x,int y,rgb c1,rgb c2){
	long t0=get_msec(),t1;
	int txt_w=0;
	txt_w=XTextWidth(sfont,txt,strlen(txt));

	int xpos=0;

	int paddingX=w*0.1;
	int innerW=w*0.8;
	int innerH=h*0.8;

	if( txt_w <= innerW ) {
		xpos=(innerW-txt_w)/2;	
	}else{
		xpos=0;
	}


	XRectangle rects[]={ {0,0,w+1,h+1} };
	XSetClipRectangles(dpy,gc,x,y,rects,1,Unsorted);

	XColor fg=_rgb2XColor(c1.r,c1.g,c1.b);
	XColor bg=_rgb2XColor(c2.r,c2.g,c2.b);
	XColor white=_rgb2XColor(255,255,255);
	assert(txt);

	int x0,y0,w0,h0;

/*	GC fg_gc=XCreateGC(dpy,d,0,0);
	GC bg_gc=XCreateGC(dpy,d,0,0);
	GC white_gc=XCreateGC(dpy,d,0,0);
	*/

	d=double_buffer;

	XAllocColor(dpy,attr.colormap,&white);
	XAllocColor(dpy,attr.colormap,&bg);
	
	XSetForeground(dpy,gc,bg.pixel);
	XSetFillStyle(dpy,gc,FillSolid);
	XFillRectangle(dpy,d,gc,x,y,w,h);

	XSetForeground(dpy,gc,white.pixel);
	XSetBackground(dpy,gc,white.pixel);
	XDrawRectangle(dpy,d,gc,x,y,w,h);

	XSetForeground(dpy,gc,white.pixel);
	XDrawString(dpy,d,gc,x+paddingX+xpos,y+((h-10)/2),txt,strlen(txt));

}
Пример #18
0
Файл: List.c Проект: aosm/X11
/* ClipToShadowInteriorAndLongest()
 *
 * Converts the passed gc so that any drawing done with that GC will not
 * write in the empty margin (specified by internal_width/height) (which also
 * prevents erasing the shadow.  It also clips against the value longest.
 * If the user doesn't set longest, this has no effect (as longest is the
 * maximum of all item lengths).  If the user does specify, say, 80 pixel
 * columns, though, this prevents items from overwriting other items.
 */
static void
ClipToShadowInteriorAndLongest(ListWidget lw, GC *gc_p, unsigned int x)
{
    XRectangle rect;

    rect.x = x;
    rect.y = lw->list.internal_height;
    rect.height = XtHeight(lw) - (lw->list.internal_height << 1);
    rect.width = XtWidth(lw) - lw->list.internal_width - x;
    if (rect.width > lw->list.longest)
	rect.width = lw->list.longest;

    XSetClipRectangles(XtDisplay((Widget)lw), *gc_p, 0, 0, &rect, 1, YXBanded);
}
Пример #19
0
static void
xf_decode_frame(xfInfo * xfi, int x, int y, uint8 * bitmapData, uint32 bitmapDataLength)
{
    int i;
    int tx, ty;
    XImage * image;
    RFX_MESSAGE * message;

    switch (xfi->codec)
    {
    case XF_CODEC_REMOTEFX:

        message = rfx_process_message((RFX_CONTEXT *) xfi->rfx_context, bitmapData, bitmapDataLength);

        /* Clip the updated region based on the union of rects, so that pixels outside of the region will not be drawn. */
        XSetFunction(xfi->display, xfi->gc, GXcopy);
        XSetFillStyle(xfi->display, xfi->gc, FillSolid);
        XSetClipRectangles(xfi->display, xfi->gc, x, y, (XRectangle*)message->rects, message->num_rects, YXBanded);

        /* Draw the tiles to backstore, each is 64x64. */
        for (i = 0; i < message->num_tiles; i++)
        {
            image = XCreateImage(xfi->display, xfi->visual, 24, ZPixmap, 0,
                                 (char *) message->tiles[i]->data, 64, 64, 32, 0);
            tx = message->tiles[i]->x + x;
            ty = message->tiles[i]->y + y;
            XPutImage(xfi->display, xfi->backstore, xfi->gc, image, 0, 0, tx, ty, 64, 64);
            XFree(image);
        }

        /* Copy the updated region from backstore to the window. */
        for (i = 0; i < message->num_rects; i++)
        {
            tx = message->rects[i].x + x;
            ty = message->rects[i].y + y;
            XCopyArea(xfi->display, xfi->backstore, xfi->wnd, xfi->gc_default,
                      tx, ty, message->rects[i].width, message->rects[i].height, tx, ty);
        }
        rfx_message_free(xfi->rfx_context, message);

        XSetClipMask(xfi->display, xfi->gc, None);

        break;

    default:
        printf("xf_decode_frame: no codec defined.\n");
        break;
    }
}
Пример #20
0
int C_StretchBoxProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv)
{
  double x2,y2,xtemp2,ytemp2;
  Pixmap pm;
  XRectangle theClientArea;
  Tk_Window tkwin;
  WindowType theWindow = theWindowArray[atoi(argv[1])];

  tkwin = theWindow->tkwin;

  theClientArea.x = 0;
  theClientArea.y = 0;
  theClientArea.width = Tk_Width(tkwin);
  theClientArea.height = Tk_Height(tkwin);
  XSetClipRectangles(theDisplay, theWindow->xwingc, 0, 0, &theClientArea, 
		     1, Unsorted);

  pm = XCreatePixmap(theDisplay, Tk_WindowId(tkwin), Tk_Width(tkwin),
		     Tk_Height(tkwin), Tk_Depth(tkwin));
  XCopyArea(theDisplay, theWindow->pixmap_buffer, pm, theWindow->xwingc, 0,
	    0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0);

  x2 = atof(argv[2]);
  y2 = atof(argv[3]);

  if (Is_X_Log(theWindow)) {
    xtemp2 = theWindow->c1 * log10(max(x2, DBL_MIN)) + theWindow->d1;
  } else {
    xtemp2 = theWindow->c1 * x2 + theWindow->d1;
  }
    
  if (Is_Y_Log(theWindow)) {
    ytemp2 = theWindow->c2 * log10(max(y2, DBL_MIN)) + theWindow->d2;
  } else {
    ytemp2 = theWindow->c2 * y2 + theWindow->d2;
  }

  XSetForeground(theDisplay, theWindow->xwingc, theWhitePixel);
  XDrawRectangle(theDisplay, pm, theWindow->xwingc, min(xtemp1,xtemp2), 
		 min(ytemp1,ytemp2), fabs(xtemp2 - xtemp1), 
		 fabs(ytemp2 - ytemp1));
  XCopyArea(theDisplay, pm, Tk_WindowId(tkwin), theWindow->xwingc, 0, 0,
	    Tk_Width(tkwin), Tk_Height(tkwin), 0, 0);
  XFlush(theDisplay);
  XFreePixmap(theDisplay, pm);
  
  return TCL_OK;
}
Пример #21
0
void
XmLStringDraw(Widget w,
	      XmString string,
	      XmStringDirection stringDir,
	      XmFontList fontList,
	      unsigned char alignment,
	      GC gc,
	      XRectangle *rect,
	      XRectangle *clipRect)
	{
	Display *dpy;
	Window win;
	Dimension width, height;
	int x, y, drawType;
	unsigned char strAlignment;

	if (!string)
		return;
	dpy = XtDisplay(w);
	win = XtWindow(w);
	XmStringExtent(fontList, string, &width, &height);
	drawType = XmLDrawCalc(w, width, height, alignment,
		rect, clipRect, &x, &y);
	if (drawType == XmLDrawNODRAW)
		return;
	x = rect->x + 2;
	if (alignment == XmALIGNMENT_LEFT ||
		alignment == XmALIGNMENT_TOP_LEFT ||
		alignment == XmALIGNMENT_BOTTOM_LEFT)
		strAlignment = XmALIGNMENT_BEGINNING;
	else if (alignment == XmALIGNMENT_CENTER ||
		alignment == XmALIGNMENT_TOP ||
		alignment == XmALIGNMENT_BOTTOM)
        if (width <= rect->width - 4)
            strAlignment = XmALIGNMENT_CENTER;
        else
            strAlignment = XmALIGNMENT_BEGINNING;
	else
		strAlignment = XmALIGNMENT_END;
	/* XmStringDraw clipping doesnt work in all cases
	   so we use a clip region for clipping */
	if (drawType == XmLDrawCLIPPED)
		XSetClipRectangles(dpy, gc, 0, 0, clipRect, 1, Unsorted);
	XmStringDraw(dpy, win, fontList, string, gc,
		x, y, rect->width - 4, strAlignment, stringDir, clipRect);
	if (drawType == XmLDrawCLIPPED)
		XSetClipMask(dpy, gc, None);
	}
Пример #22
0
  void Graphics::PrepareGraphicsContext()
  {
    XRectangle clip;
    XSetBackground(this->display, this->gc, this->backgroundColor);
    XSetForeground(this->display, this->gc, this->foregroundColor);
    XSetFunction(this->display, this->gc, this->drawingMode);
    clip.x = (int)this->clipRect.x;
    clip.y = (int)this->clipRect.y;
    clip.width = (int)this->clipRect.width;
    clip.height = (int)this->clipRect.height;
    XSetClipRectangles(this->display, this->gc, 0, 0, &clip, 1, Unsorted);

    if (this->clipRect.IsEmpty()) {
      LOG_PAINT << "Graphics: Clip rect is empty in PrepareGraphicsContext()";
    }
  }
Пример #23
0
void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
    if (d_ptr->device.isNull())
        return;

#ifndef Q_FLATTEN_EXPOSE
    extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
    extern QWidgetData* qt_widget_data(QWidget *);
    QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
    GC gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
    QRegion wrgn(rgn);
    QRect br = rgn.boundingRect();
    if (!wOffset.isNull())
        wrgn.translate(-wOffset);
    QRect wbr = wrgn.boundingRect();

    // #### why dirty widget here? should be up to date already
//     if (br.right() + offset.x() >= d_ptr->device.size().width() || br.bottom() + offset.y() >= d_ptr->device.size().height()) {
// //             QRegion dirty = rgn - QRect(-offset, d_ptr->device.size());
// //             qDebug() << dirty;
//         widget->d_func()->dirtyWidget_sys(rgn - QRect(-offset, d_ptr->device.size()));
//     }

    int num;
    XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
//         qDebug() << "XSetClipRectangles";
//         for  (int i = 0; i < num; ++i)
//             qDebug() << " " << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
    XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded);
#else
    Q_UNUSED(rgn);
    XGCValues values;
    values.subwindow_mode = IncludeInferiors;
    GC gc = XCreateGC(X11->display, d_ptr->device.handle(), GCSubwindowMode, &values);
#endif
    XSetGraphicsExposures(X11->display, gc, False);
//         XFillRectangle(X11->display, widget->handle(), gc, 0, 0, widget->width(), widget->height());
#ifndef Q_FLATTEN_EXPOSE
    XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
              br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
#else
    Q_ASSERT(widget->isWindow());
    XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
              offset.x(), offset.y(), widget->width(), widget->height(), 0, 0);
#endif
    XFreeGC(X11->display, gc);
}
Пример #24
0
void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, const QPoint &offset)
{
    // We don't need to know the widget which initiated the flush. Instead we just use the offset
    // to translate the widgetRegion:
    Q_UNUSED(widget);

    if (m_backBuffer.isNull()) {
        qDebug("QX11GLWindowSurface::flush() - backBuffer is null, not flushing anything");
        return;
    }

    Q_ASSERT(window()->size() != m_backBuffer.size());

    // Wait for all GL rendering to the back buffer pixmap to complete before trying to
    // copy it to the window. We do this by making sure the pixmap's context is current
    // and then call eglWaitClient. The EGL 1.4 spec says eglWaitClient doesn't have to
    // block, just that "All rendering calls...are guaranteed to be executed before native
    // rendering calls". This makes it potentially less expensive than glFinish.
    QGLContext* ctx = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data())->context();
    if (QGLContext::currentContext() != ctx && ctx && ctx->isValid())
        ctx->makeCurrent();
    eglWaitClient();

    if (m_windowGC == 0) {
        XGCValues attribs;
        attribs.graphics_exposures = False;
        m_windowGC = XCreateGC(X11->display, m_window->handle(), GCGraphicsExposures, &attribs);
    }

    int rectCount;
    XRectangle *rects = (XRectangle *)qt_getClipRects(widgetRegion, rectCount);
    if (rectCount <= 0)
        return;

    XSetClipRectangles(X11->display, m_windowGC, 0, 0, rects, rectCount, YXBanded);

    QRect dirtyRect = widgetRegion.boundingRect().translated(-offset);
    XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_windowGC,
              dirtyRect.x(), dirtyRect.y(), dirtyRect.width(), dirtyRect.height(),
              dirtyRect.x(), dirtyRect.y());

    // Make sure the blit of the update from the back buffer to the window completes
    // before allowing rendering to start again to the back buffer. Otherwise the GPU
    // might start rendering to the back buffer again while the blit takes place.
    eglWaitNative(EGL_CORE_NATIVE_ENGINE);
}
Пример #25
0
static PetscErrorCode PetscDrawCheckResizedWindow_X(PetscDraw draw)
{
  PetscDraw_X    *win = (PetscDraw_X*)draw->data;
  PetscErrorCode ierr;
  int            x,y;
  PetscMPIInt    rank;
  Window         root;
  unsigned int   w,h,border,depth,geo[2];
  PetscReal      xl,xr,yl,yr;
  XRectangle     box;

  PetscFunctionBegin;
  if (!win->win) PetscFunctionReturn(0);
  ierr = MPI_Comm_rank(((PetscObject)draw)->comm,&rank);CHKERRQ(ierr);
  if (!rank) {
    XFlush(win->disp);
    XSync(win->disp,False);
    XSync(win->disp,False);
    XGetGeometry(win->disp,win->win,&root,&x,&y,geo,geo+1,&border,&depth);
  }
  ierr = MPI_Bcast(geo,2,MPI_UNSIGNED,0,((PetscObject)draw)->comm);CHKERRQ(ierr);
  w = geo[0];
  h = geo[1];
  if (w == (unsigned int) win->w && h == (unsigned int) win->h) PetscFunctionReturn(0);

  /* record new window sizes */

  win->h = h; win->w = w;

  /* Free buffer space and create new version (only first processor does this) */
  if (win->drw) {
    win->drw = XCreatePixmap(win->disp,win->win,win->w,win->h,win->depth);
  }
  /* reset the clipping */
  xl = draw->port_xl; yl = draw->port_yl;
  xr = draw->port_xr; yr = draw->port_yr;
  box.x     = (int)(xl*win->w);     box.y      = (int)((1.0-yr)*win->h);
  box.width = (int)((xr-xl)*win->w);box.height = (int)((yr-yl)*win->h);
  XSetClipRectangles(win->disp,win->gc.set,0,0,&box,1,Unsorted);

  /* try to make sure it is actually done before passing info to all */
  XSync(win->disp,False);
  ierr = MPI_Bcast(&win->drw,1,MPI_UNSIGNED_LONG,0,((PetscObject)draw)->comm);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
Пример #26
0
void xf_gdi_set_bounds(rdpContext* context, rdpBounds* bounds)
{
	XRectangle clip;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	if (bounds != NULL)
	{
		clip.x = bounds->left;
		clip.y = bounds->top;
		clip.width = bounds->right - bounds->left + 1;
		clip.height = bounds->bottom - bounds->top + 1;
		XSetClipRectangles(xfi->display, xfi->gc, 0, 0, &clip, 1, YXBanded);
	}
	else
	{
		XSetClipMask(xfi->display, xfi->gc, None);
	}
}
Пример #27
0
void xf_gdi_set_bounds(rdpUpdate* update, BOUNDS* bounds)
{
	XRectangle clip;
	xfInfo* xfi = GET_XFI(update);

	if (bounds != NULL)
	{
		clip.x = bounds->left;
		clip.y = bounds->top;
		clip.width = bounds->right - bounds->left + 1;
		clip.height = bounds->bottom - bounds->top + 1;
		XSetClipRectangles(xfi->display, xfi->gc, 0, 0, &clip, 1, YXBanded);
	}
	else
	{
		XSetClipMask(xfi->display, xfi->gc, None);
	}
}
Пример #28
0
void DrawCellule(struct XObj *xobj,int NbCell,int NbVisCell,int HeightCell,int asc)
{
 XRectangle r;
 char *Title;
 int i;

 r.x=4+BdWidth;
 r.y=r.x;
 r.width=xobj->width-r.x-10-2*BdWidth-SbWidth;
 r.height=xobj->height-r.y-4-2*BdWidth;

 /* Dessin des cellules */ 
 XSetClipRectangles(xobj->display,xobj->gc,0,0,&r,1,Unsorted);
 for (i=xobj->value2;i<xobj->value2+NbVisCell;i++)
 {
  Title=GetMenuTitle(xobj->title,i);
  if (strlen(Title)!=0)
   if (xobj->value==i)
   {
    XSetForeground(xobj->display,xobj->gc,xobj->TabColor[shad].pixel);
    XFillRectangle(xobj->display,xobj->win,xobj->gc,r.x+2,r.y+(i-xobj->value2)*HeightCell+2,
		xobj->width-2,HeightCell-2);
    DrawString(xobj->display,xobj->gc,xobj->win,5+r.x,(i-xobj->value2)*HeightCell+asc+2+r.y,Title,
		strlen(Title),xobj->TabColor[fore].pixel,xobj->TabColor[back].pixel,
		xobj->TabColor[shad].pixel,!xobj->flags[1]);
   }
   else
   {
    XSetForeground(xobj->display,xobj->gc,xobj->TabColor[back].pixel);
    XFillRectangle(xobj->display,xobj->win,xobj->gc,r.x+2,r.y+(i-xobj->value2)*HeightCell+2,
		xobj->width-2,HeightCell-2);
    DrawString(xobj->display,xobj->gc,xobj->win,5+r.x,(i-xobj->value2)*HeightCell+asc+2+r.y,Title,
		strlen(Title),xobj->TabColor[fore].pixel,xobj->TabColor[li].pixel,
		xobj->TabColor[back].pixel,!xobj->flags[1]);
   }
  else
  {
   XSetForeground(xobj->display,xobj->gc,xobj->TabColor[back].pixel);
   XFillRectangle(xobj->display,xobj->win,xobj->gc,r.x+2,r.y+(i-xobj->value2)*HeightCell+2,
	xobj->width-2,HeightCell-2);
  }
 }
 XSetClipMask(xobj->display,xobj->gc,None); 
}
Пример #29
0
/* call higher gr_redraw routine */
static void
redraw(Widget w, XtPointer client_data, XEvent *event, Boolean *continue_dispatch)
{
    GRAPH *graph = (GRAPH *) client_data;
    XExposeEvent *pev = & event->xexpose;
    XEvent ev;
    XRectangle rects[30];
    int n = 1;

    NG_IGNORE(w);
    NG_IGNORE(continue_dispatch);

    DEVDEP(graph).isopen = 1;

    rects[0].x = (Position) pev->x;
    rects[0].y = (Position) pev->y;
    rects[0].width  = (Dimension) pev->width;
    rects[0].height = (Dimension) pev->height;

    /* XXX */
    /* pull out all other expose regions that need to be redrawn */
    while (n < 30 && XCheckWindowEvent(display, DEVDEP(graph).window,
                                       ExposureMask, &ev)) {
        pev = (XExposeEvent *) &ev;
        rects[n].x = (Position) pev->x;
        rects[n].y = (Position) pev->y;
        rects[n].width  = (Dimension) pev->width;
        rects[n].height = (Dimension) pev->height;
        n++;
    }
    XSetClipRectangles(display, DEVDEP(graph).gc, 0, 0, rects, n, Unsorted);

    noclear = True;
    {
        GRAPH *tmp = currentgraph;
        currentgraph = graph;
        gr_redraw(graph);
        currentgraph = tmp;
    }
    noclear = False;

    XSetClipMask(display, DEVDEP(graph).gc, None);
}
Пример #30
0
void QViewport( int left , int top , int right , int bottom )

{
    XRectangle r;

    ViewLeft   = left;
    ViewTop    = top;
    ViewRight  = right;
    ViewBottom = bottom;

    r.x      = left;
    r.y      = top;
    r.width  = right-left+1;
    r.height = bottom-top+1;

    XSetClipRectangles(MyDisplay,MyGc,0,0,&r,1,Unsorted);

    QAdjustScale();
}