예제 #1
0
void
draw_point(int x, int y, int width, int size, XftColor *color)
{
	XPointDouble p[4];

	p[0].x = x - size;
	p[0].y = y - 1;
	p[1].x = x - size;
	p[1].y = y + 1;
	p[2].x = x + size;
	p[2].y = y + 1;
	p[3].x = x + size;
	p[3].y = y - 1;

	XRenderCompositeDoublePoly(display, PictOpOver,
	    XftDrawSrcPicture(draw, color),
	    XftDrawPicture(draw),
	    XRenderFindStandardFormat(display, PictStandardA8),
	    0, 0, 0, 0, p, 4, 0);
	p[0].x = x - 1;
	p[0].y = y - size;
	p[1].x = x + 1;
	p[1].y = y - size;
	p[2].x = x + 1;
	p[2].y = y + size;
	p[3].x = x - 1;
	p[3].y = y + size;
	XRenderCompositeDoublePoly(display, PictOpOver,
	    XftDrawSrcPicture(draw, color),
	    XftDrawPicture(draw),
	    XRenderFindStandardFormat(display, PictStandardA8),
	    0, 0, 0, 0, p, 4, 0);
}
예제 #2
0
static Picture createPicture(Pixmap pix, int depth)
{
    if (pix == None)
        return None;
    if (renderformats[ depth ] == NULL) {
        switch(depth) {
        case 1:
            renderformats[ 1 ] = XRenderFindStandardFormat(display(), PictStandardA1);
            break;
        case 8:
            renderformats[ 8 ] = XRenderFindStandardFormat(display(), PictStandardA8);
            break;
        case 24:
            renderformats[ 24 ] = XRenderFindStandardFormat(display(), PictStandardRGB24);
            break;
        case 32:
            renderformats[ 32 ] = XRenderFindStandardFormat(display(), PictStandardARGB32);
            break;
        default: {
            XRenderPictFormat req;
            long mask = PictFormatType | PictFormatDepth;
            req.type = PictTypeDirect;
            req.depth = depth;
            renderformats[ depth ] = XRenderFindFormat(display(), mask, &req, 0);
            break;
        }
        }
        if (renderformats[ depth ] == NULL) {
            kWarning(1212) << "Could not find XRender format for depth" << depth;
            return None;
        }
    }
    return XRenderCreatePicture(display(), pix, renderformats[ depth ], 0, NULL);
}
예제 #3
0
/* static */
XRenderPictFormat*
gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
{
    switch (format) {
        case ImageFormatARGB32:
            return XRenderFindStandardFormat (dpy, PictStandardARGB32);
        case ImageFormatRGB24:
            return XRenderFindStandardFormat (dpy, PictStandardRGB24);
        case ImageFormatRGB16_565: {
            // PictStandardRGB16_565 is not standard Xrender format
            // we should try to find related visual
            // and find xrender format by visual
            Visual *visual = FindVisual(DefaultScreenOfDisplay(dpy), format);
            if (!visual)
                return NULL;
            return XRenderFindVisualFormat(dpy, visual);
        }
        case ImageFormatA8:
            return XRenderFindStandardFormat (dpy, PictStandardA8);
        case ImageFormatA1:
            return XRenderFindStandardFormat (dpy, PictStandardA1);
        default:
            break;
    }

    return (XRenderPictFormat*)NULL;
}
예제 #4
0
static XRenderPictFormat *mask_format(Display *dpy, enum mask mask)
{
	switch (mask) {
	default:
	case MASK_NONE: return NULL;
	case MASK_A1: return XRenderFindStandardFormat(dpy, PictStandardA1);
	case MASK_A8: return XRenderFindStandardFormat(dpy, PictStandardA8);
	}
}
예제 #5
0
파일: gui.c 프로젝트: mortehu/bra
static void
x11_connect (void)
{
  char *c;
  int nitems;

  if (x11_connected)
    return;

  XInitThreads ();

  GUI_display = XOpenDisplay (0);

  if (!GUI_display)
    errx (EXIT_FAILURE, "Failed to open GUI_display");

  XSynchronize (GUI_display, True);

  GUI_screenidx = DefaultScreen (GUI_display);
  GUI_screen = DefaultScreenOfDisplay (GUI_display);
  GUI_visual = DefaultVisual (GUI_display, GUI_screenidx);
  GUI_visual_info = XGetVisualInfo (GUI_display, VisualNoMask, &GUI_visual_template, &nitems);

  xa_wm_delete_window = XInternAtom (GUI_display, "WM_DELETE_WINDOW", False);
  xa_clipboard = XInternAtom (GUI_display, "CLIPBOARD", False);
  xa_utf8_string = XInternAtom (GUI_display, "UTF8_STRING", False);
  xa_prop_paste = XInternAtom (GUI_display, "BRA_PASTE", False);

  xim = 0;

  if ((c = XSetLocaleModifiers ("")) && *c)
    xim = XOpenIM (GUI_display, 0, 0, 0);

  if (!xim && (c = XSetLocaleModifiers ("@im=none")) && *c)
    xim = XOpenIM (GUI_display, 0, 0, 0);

  if (!xim)
    errx (EXIT_FAILURE, "Failed to open X Input Method");

  xrenderpictformat = XRenderFindVisualFormat (GUI_display, GUI_visual);

  if (!xrenderpictformat)
    errx (EXIT_FAILURE, "XRenderFindVisualFormat failed");

  argb32pictformat = XRenderFindStandardFormat (GUI_display, PictStandardARGB32);

  a8pictformat = XRenderFindStandardFormat (GUI_display, PictStandardA8);

  if (!a8pictformat)
    errx (EXIT_FAILURE, "XrenderFindStandardFormat failed for PictStandardA8");

  XSynchronize (GUI_display, False);

  x11_connected = 1;
}
예제 #6
0
/* For the xlib backend we distinguish between TEST and PERF mode in a
 * couple of ways.
 *
 * For TEST, we always test against pixmaps of depth 32 (for
 * COLOR_ALPHA) or 24 (for COLOR) and we use XSynchronize to make it
 * easier to debug problems.
 *
 * For PERF, we test against 32-bit pixmaps for COLOR_ALPHA, but for
 * COLOR we test against _windows_ at the depth of the default visual.
 * For obvious reasons, we don't use XSynchronize.
 */
static cairo_surface_t *
_cairo_boilerplate_xlib_test_create_surface (Display		   *dpy,
					     cairo_content_t	    content,
					     int		    width,
					     int		    height,
					     xlib_target_closure_t *xtc)
{
    XRenderPictFormat *xrender_format;
    cairo_surface_t *surface;

    /* This kills performance, but it makes debugging much
     * easier. That's why we have it here when in TEST mode, but not
     * over in PERF mode. */
    XSynchronize (xtc->dpy, 1);

    /* XXX: Currently we don't do any xlib testing when the X server
     * doesn't have the Render extension. We could do better here,
     * (perhaps by converting the tests from ARGB32 to RGB24). One
     * step better would be to always test the non-Render fallbacks
     * for each test even if the server does have the Render
     * extension. That would probably be through another
     * cairo_boilerplate_target which would use an extended version of
     * cairo_test_xlib_disable_render.	*/
    switch (content) {
    case CAIRO_CONTENT_COLOR_ALPHA:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
	break;
    case CAIRO_CONTENT_COLOR:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
	break;
    case CAIRO_CONTENT_ALPHA:
    default:
	CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content));
	return NULL;
    }
    if (xrender_format == NULL) {
	CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
	return NULL;
    }

    xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
				   width, height, xrender_format->depth);
    xtc->drawable_is_pixmap = TRUE;

    surface = cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
							  DefaultScreenOfDisplay (dpy),
							  xrender_format,
							  width, height);

    _cairo_boilerplate_xlib_setup_test_surface(surface);

    return surface;
}
예제 #7
0
void DrawTrayWindow(int f_state, int x, int y, int w, int h) {
    if ( !bUseTrayIcon )
	return;
	
    if (!tray_mapped) {
        tray_mapped = True;
        if (!tray_find_dock(dpy, tray.window))
            return;
    }

    if (!tray_get_visual(dpy, &tray))
    {
        XClearArea (dpy, tray.window, x, y, w, h, False);
        XSetClipOrigin(dpy, tray.gc, x, y);
        XPutImage(dpy, tray.window, tray.gc, tray.icon[f_state],
                x, y, x, y, w, h);
    }
    else
    {
        Picture trayw, mask, icon;
        
        XWindowAttributes attrs;
        
        XGetWindowAttributes( dpy, tray.window , &attrs );
        XRenderPictFormat*  format = XRenderFindVisualFormat( dpy, attrs.visual );

        XRenderPictFormat *pformat = XRenderFindStandardFormat( dpy, PictStandardA1 );
        XRenderPictFormat *pformat2 = XRenderFindStandardFormat( dpy, PictStandardRGB24 );

        XRenderPictureAttributes pattrs;
        
        trayw = XRenderCreatePicture(dpy, tray.window,
                format, 0, NULL);
        
        mask = XRenderCreatePicture(dpy, tray.icon_mask[f_state],
                pformat, 0, NULL);

        pattrs.alpha_map = mask;
        icon = XRenderCreatePicture(dpy, tray.picon[f_state],
                pformat2, CPAlphaMap, &pattrs);



        XRenderComposite(dpy, PictOpOver, icon, None, trayw, 
                x,y , x,y,x,y,w,h);
        XRenderFreePicture(dpy,trayw);
        XRenderFreePicture(dpy,mask);
        XRenderFreePicture(dpy,icon);

    }
}
예제 #8
0
JNIEXPORT void JNICALL
   Java_sun_java2d_xr_XRSurfaceData_initXRPicture(JNIEnv *env, jobject xsd,
                                                  jlong pXSData,
                                                  jint pictFormat)
{
#ifndef HEADLESS

  X11SDOps *xsdo;
  XRenderPictFormat *fmt;

  J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initXRender");

  xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
  if (xsdo == NULL) {
      return;
  }

  if (xsdo->xrPic == None) {
      XRenderPictureAttributes pict_attr;
      pict_attr.repeat = RepeatNone;
      fmt = XRenderFindStandardFormat(awt_display, pictFormat);
      xsdo->xrPic =
         XRenderCreatePicture(awt_display, xsdo->drawable, fmt,
                              CPRepeat, &pict_attr);
  }

  (*env)->SetIntField (env, xsd, pictID, xsdo->xrPic);
  (*env)->SetIntField (env, xsd, xidID, xsdo->drawable);
#endif /* !HEADLESS */
}
예제 #9
0
static cairo_surface_t *
create_source_surface (int size)
{
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
    XRenderPictFormat *xrender_format;
    struct closure *data;
    cairo_surface_t *surface;

    data = xmalloc (sizeof (struct closure));

    data->dpy = XOpenDisplay (NULL);
    if (!data->dpy) {
	return NULL;
    }

    xrender_format = XRenderFindStandardFormat (data->dpy, PictStandardARGB32);

    data->pix = XCreatePixmap (data->dpy, DefaultRootWindow (data->dpy),
			       size, size, xrender_format->depth);

    surface = cairo_xlib_surface_create_with_xrender_format (data->dpy,
	                                                     data->pix,
							     DefaultScreenOfDisplay (data->dpy),
							     xrender_format,
							     size, size);
    cairo_surface_set_user_data (surface, &closure_key, data, cleanup);

    return surface;
#else
    return NULL;
#endif
}
예제 #10
0
void xf_draw_screen_scaled(xfInfo* xfi)
{
	XTransform transform;
	Picture windowPicture;
	Picture primaryPicture;
	XRenderPictureAttributes pa;
	XRenderPictFormat* picFormat;

	picFormat = XRenderFindStandardFormat(xfi->display, PictStandardRGB24);
	pa.subwindow_mode = IncludeInferiors;
	primaryPicture = XRenderCreatePicture(xfi->display, xfi->primary, picFormat, CPSubwindowMode, &pa);
	windowPicture = XRenderCreatePicture(xfi->display, xfi->window->handle, picFormat, CPSubwindowMode, &pa);

	transform.matrix[0][0] = XDoubleToFixed(1);
	transform.matrix[0][1] = XDoubleToFixed(0);
	transform.matrix[0][2] = XDoubleToFixed(0);

	transform.matrix[1][0] = XDoubleToFixed(0);
	transform.matrix[1][1] = XDoubleToFixed(1);
	transform.matrix[1][2] = XDoubleToFixed(0);

	transform.matrix[2][0] = XDoubleToFixed(0);
	transform.matrix[2][1] = XDoubleToFixed(0);
	transform.matrix[2][2] = XDoubleToFixed(xfi->scale);

	XRenderSetPictureTransform(xfi->display, primaryPicture, &transform);
	XRenderComposite(xfi->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, 0, 0, xfi->currentWidth, xfi->currentHeight);
}
예제 #11
0
static XPicture sGetSolidFill(Color c)
{
	int q = GetHashValue(c) % (int)XRSolidFillCount;
	XRSolidFill& f = sFill[q];
	if(f.color == c && f.picture)
		return f.picture;
	if(f.picture)
		XRenderFreePicture(Xdisplay, f.picture);
	if(f.pixmap)
		XFreePixmap(Xdisplay, f.pixmap);
	f.pixmap = XCreatePixmap(Xdisplay, Xroot, 1, 1, 32);
	XRenderPictureAttributes attr;
	attr.repeat = XTrue;
	f.picture = XRenderCreatePicture(Xdisplay, f.pixmap,
	                                 XRenderFindStandardFormat(Xdisplay, PictStandardARGB32),
	                                                           CPRepeat, &attr);
	f.color = c;
	XRenderColor xc;
	xc.red = s255d16(c.GetR());
	xc.green = s255d16(c.GetG());
	xc.blue = s255d16(c.GetB());
	xc.alpha = 65535;
	XRenderFillRectangle(Xdisplay, PictOpSrc, f.picture, &xc, 0, 0, 1, 1);
	return f.picture;
}
예제 #12
0
static void fill_rect(struct test_display *t, Picture p,
		      int x, int y, int w, int h,
		      uint8_t red, uint8_t green, uint8_t blue)
{
	Drawable tmp;
	XRenderColor c;
	Picture src;
	XRenderPictFormat *format;

	format = XRenderFindStandardFormat(t->dpy, PictStandardRGB24);

	tmp = XCreatePixmap(t->dpy, DefaultRootWindow(t->dpy),
			    w, h, format->depth);

	src = XRenderCreatePicture(t->dpy, tmp, format, 0, NULL);
	c.red = (int)red << 8 | red;
	c.green = (int)green << 8 | green;
	c.blue = (int)blue << 8 | blue;
	c.alpha = 0xffff;
	XRenderFillRectangle(t->dpy, PictOpSrc, src, &c, 0, 0, w, h);
	XRenderComposite(t->dpy, PictOpOver, src, 0, p, 0, 0, 0, 0, x, y, w, h);

	XRenderFreePicture(t->dpy, src);
	XFreePixmap(t->dpy, tmp);
}
예제 #13
0
void SetSurface(SystemDraw& w, int x, int y, int cx, int cy, const RGBA *pixels)
{
	GuiLock __;
	Pixmap pixmap = XCreatePixmap(Xdisplay, Xroot, cx, cy, 24);
	XPicture picture = XRenderCreatePicture(
		Xdisplay, pixmap,
	    XRenderFindStandardFormat(Xdisplay, PictStandardRGB24),
	    0, 0
	);
	XImage ximg;
	sInitXImage(ximg, Size(cx, cy));
	ximg.bitmap_pad = 32;
	ximg.bytes_per_line = 4 * cx;
	ximg.bits_per_pixel = 32;
	ximg.blue_mask = 0x00ff0000;
	ximg.green_mask = 0x0000ff00;
	ximg.red_mask = 0x000000ff;
	ximg.bitmap_unit = 32;
	ximg.depth = 24;
	ximg.data = (char *)pixels;
	XInitImage(&ximg);
	GC gc = XCreateGC(Xdisplay, pixmap, 0, 0);
	XPutImage(Xdisplay, pixmap, gc, &ximg, 0, 0, 0, 0, cx, cy);
	XFreeGC(Xdisplay, gc);
	XFreePixmap(Xdisplay, pixmap);
	XRenderComposite(Xdisplay, PictOpOver,
	                 picture, 0, XftDrawPicture(w.GetXftDraw()),
	                 0, 0, 0, 0, x, y, cx, cy);
	XRenderFreePicture(Xdisplay, picture);
}
예제 #14
0
void
WallScreen::setupCairoContext (WallCairoContext &context)
{
    XRenderPictFormat *format;
    Screen            *xScreen;
    int               width, height;

    xScreen = ScreenOfDisplay (screen->dpy (), screen->screenNum ());

    width = context.width;
    height = context.height;

    format = XRenderFindStandardFormat (screen->dpy (), PictStandardARGB32);

    context.pixmap = XCreatePixmap (screen->dpy (), screen->root (),
				    width, height, 32);

    context.texture = GLTexture::bindPixmapToTexture (context.pixmap,
						      width, height, 32);
    if (context.texture.empty ())
    {
	screen->logMessage ("wall", CompLogLevelError,
			    "Couldn't create cairo context for switcher");
    }

    context.surface =
	cairo_xlib_surface_create_with_xrender_format (screen->dpy (),
						       context.pixmap,
						       xScreen, format,
						       width, height);

    context.cr = cairo_create (context.surface);
    clearCairoLayer (context.cr);
}
예제 #15
0
파일: extinitwin.c 프로젝트: Limsik/e17
static void
_eiw_render_loop(Window win, EImage * im, EiwData * d)
{
   int                 w, h;
   XRenderPictFormat  *pictfmt;
   Pixmap              pmap;
   Picture             pict;

   EImageGetSize(im, &w, &h);

   pictfmt = XRenderFindStandardFormat(disp, PictStandardARGB32);
   pmap = XCreatePixmap(disp, WinGetXwin(VROOT), w, h, 32);
   imlib_context_set_image(im);
   imlib_context_set_drawable(pmap);
   imlib_render_image_on_drawable(0, 0);
   pict = XRenderCreatePicture(disp, pmap, pictfmt, 0, 0);
   XFreePixmap(disp, pmap);

   if (d->curs != None)
      XFreeCursor(disp, d->curs);
   d->curs = XRenderCreateCursor(disp, pict, w / 2, h / 2);
   XRenderFreePicture(disp, pict);

   XDefineCursor(disp, win, d->curs);
}
예제 #16
0
static Picture source_pixmap(struct test_display *t, struct test_target *target, int format)
{
	XRenderColor render_color[2] = {
		{ 0x8000, 0x8000, 0x8000, 0x8000 },
		{ 0xffff, 0xffff, 0xffff, 0xffff },
	};
	Pixmap pixmap;
	Picture picture;

	pixmap = XCreatePixmap(t->dpy, t->root,
			       target->width, target->height,
			       PIXMAN_FORMAT_DEPTH(formats[format].pixman_format));

	picture = XRenderCreatePicture(t->dpy, pixmap,
				       XRenderFindStandardFormat(t->dpy, format),
				       0, NULL);
	XFreePixmap(t->dpy, pixmap);

	XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[0],
			     0, 0, target->width, target->height/2);
	XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[1],
			     0, target->height/2, target->width, target->height/2);

	return picture;
}
예제 #17
0
static Picture source_shm(struct test_display *t, struct test_target *target)
{
	XShmSegmentInfo *shm = t->target == REF ? &shmref : &shmout;
	Pixmap pixmap;
	Picture picture;
	int size;

	if (shm->shmid == -1)
		return 0;

	pixmap = XShmCreatePixmap(t->dpy, t->root,
				  shm->shmaddr, shm,
				  target->width, target->height, 32);

	picture = XRenderCreatePicture(t->dpy, pixmap,
				       XRenderFindStandardFormat(t->dpy, 0),
				       0, NULL);
	XFreePixmap(t->dpy, pixmap);

	size = target->width * target->height * 4;
	memset(shm->shmaddr, 0x80, size/2);
	memset(shm->shmaddr+size/2, 0xff, size/2);

	return picture;
}
예제 #18
0
Picture PreviewCursor::createPicture(const XcursorImage *image) const
{
    Display *dpy = QPaintDevice::x11AppDisplay();

    XImage ximage;
    ximage.width = image->width;
    ximage.height = image->height;
    ximage.xoffset = 0;
    ximage.format = ZPixmap;
    ximage.data = reinterpret_cast< char * >(image->pixels);
    ximage.byte_order = ImageByteOrder(dpy);
    ximage.bitmap_unit = 32;
    ximage.bitmap_bit_order = ximage.byte_order;
    ximage.bitmap_pad = 32;
    ximage.depth = 32;
    ximage.bits_per_pixel = 32;
    ximage.bytes_per_line = image->width * 4;
    ximage.red_mask = 0x00ff0000;
    ximage.green_mask = 0x0000ff00;
    ximage.blue_mask = 0x000000ff;
    ximage.obdata = 0;

    XInitImage(&ximage);

    Pixmap pix = XCreatePixmap(dpy, DefaultRootWindow(dpy), ximage.width, ximage.height, 32);
    GC gc = XCreateGC(dpy, pix, 0, NULL);
    XPutImage(dpy, pix, gc, &ximage, 0, 0, 0, 0, ximage.width, ximage.height);
    XFreeGC(dpy, gc);

    XRenderPictFormat *fmt = XRenderFindStandardFormat(dpy, PictStandardARGB32);
    Picture pict = XRenderCreatePicture(dpy, pix, fmt, 0, NULL);
    XFreePixmap(dpy, pix);

    return pict;
}
예제 #19
0
static void DrawTrayExtend(winlist_t *win)
{
    Pixmap tray, dummy;
    XpmAttributes attr;
    attr.valuemask = 0;
    XpmCreatePixmapFromData(gui->display, win->window,
			oxim_tray, &tray, &dummy, &attr);

    int tray_w = attr.width;
    int tray_h = attr.height;
    int w = win->width;
    int h = win->height;
    int x=0, y=0;
    int offset_y = h/2 - tray_h/2;
    
    Picture trayw, mask, icon;
    
    XWindowAttributes attrs;

    XGetWindowAttributes( gui->display, win->window , &attrs );
    XRenderPictFormat*  format = XRenderFindVisualFormat( gui->display, attrs.visual );

    XRenderPictFormat *pformat = XRenderFindStandardFormat( gui->display, PictStandardA1 );
    XRenderPictFormat *pformat2 = XRenderFindStandardFormat( gui->display, PictStandardRGB24 );

    XRenderPictureAttributes pattrs;

    trayw = XRenderCreatePicture(gui->display, win->window,
	    format, 0, NULL);

    mask = XRenderCreatePicture(gui->display, icon_mask,
	    pformat, 0, NULL);

    pattrs.alpha_map = mask;
    icon = XRenderCreatePicture(gui->display, picon,
	    pformat2, CPAlphaMap, &pattrs);

    XRenderComposite(gui->display, PictOpOver, icon, None, trayw, 
	    x,y-offset_y , x,y,x,y,w,h);
    XRenderFreePicture(gui->display,trayw);
    XRenderFreePicture(gui->display,mask);
    XRenderFreePicture(gui->display,icon);
    XFreePixmap(gui->display,tray);
    if(dummy)
	XFreePixmap(gui->display,dummy);
}
예제 #20
0
static cairo_surface_t *
_cairo_boilerplate_xlib_perf_create_surface (Display		   *dpy,
					     cairo_content_t	    content,
					     int		    width,
					     int		    height,
					     xlib_target_closure_t *xtc)
{
    XSetWindowAttributes attr;
    XRenderPictFormat *xrender_format;
    Visual *visual;

    switch (content) {
    case CAIRO_CONTENT_COLOR_ALPHA:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
	if (xrender_format == NULL) {
	    CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
	    return NULL;
	}

	xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
				       width, height, xrender_format->depth);
	xtc->drawable_is_pixmap = TRUE;
	break;

    case CAIRO_CONTENT_COLOR:
	if (! _cairo_boilerplate_xlib_check_screen_size (dpy,
							 DefaultScreen (dpy),
							 width, height)) {
	    CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n"));
	    return NULL;
	}

	visual = DefaultVisual (dpy, DefaultScreen (dpy));
	xrender_format = XRenderFindVisualFormat (dpy, visual);
	if (xrender_format == NULL) {
	    CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
	    return NULL;
	}

	attr.override_redirect = True;
	xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
				       width, height, 0, xrender_format->depth,
				       InputOutput, visual, CWOverrideRedirect, &attr);
	XMapWindow (dpy, xtc->drawable);
	xtc->drawable_is_pixmap = FALSE;
	break;

    case CAIRO_CONTENT_ALPHA:
    default:
	CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content));
	return NULL;
    }

    return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
							  DefaultScreenOfDisplay (dpy),
							  xrender_format,
							  width, height);
}
예제 #21
0
void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h, BOOL scale)
{
#ifdef WITH_XRENDER
	XTransform transform;
	Picture windowPicture;
	Picture primaryPicture;
	XRenderPictureAttributes pa;
	XRenderPictFormat* picFormat;
	XRectangle xr;

	picFormat = XRenderFindStandardFormat(xfc->display, PictStandardRGB24);
	pa.subwindow_mode = IncludeInferiors;
	primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat, CPSubwindowMode, &pa);
	windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle, picFormat, CPSubwindowMode, &pa);

	transform.matrix[0][0] = XDoubleToFixed(1);
	transform.matrix[0][1] = XDoubleToFixed(0);
	transform.matrix[0][2] = XDoubleToFixed(0);

	transform.matrix[1][0] = XDoubleToFixed(0);
	transform.matrix[1][1] = XDoubleToFixed(1);
	transform.matrix[1][2] = XDoubleToFixed(0);

	transform.matrix[2][0] = XDoubleToFixed(0);
	transform.matrix[2][1] = XDoubleToFixed(0);
	transform.matrix[2][2] = XDoubleToFixed(xfc->settings->ScalingFactor);

	if( (w != 0) && (h != 0) )
	{

		if(scale == TRUE)
		{
			xr.x = x * xfc->settings->ScalingFactor;
			xr.y = y * xfc->settings->ScalingFactor;
			xr.width = (w+1) * xfc->settings->ScalingFactor;
			xr.height = (h+1) * xfc->settings->ScalingFactor;
		}
		else
		{
			xr.x = x;
			xr.y = y;
			xr.width = w;
			xr.height = h;
		}

		XRenderSetPictureClipRectangles(xfc->display, primaryPicture, 0, 0, &xr, 1);
	}

	XRenderSetPictureTransform(xfc->display, primaryPicture, &transform);

	XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, xfc->offset_x, xfc->offset_y, xfc->currentWidth, xfc->currentHeight);

	XRenderFreePicture(xfc->display, primaryPicture);
	XRenderFreePicture(xfc->display, windowPicture);

#endif

}
예제 #22
0
/* Apply the cursor to the Chromium OS X11 server.
 * Adapted from the XcursorImageLoadCursor implementation in libXcursor,
 * copyright 2002 Keith Packard.
 */
static void apply_cursor(Display* d, Window w, XFixesCursorImage *image) {
    static Cursor cur_cursor = 0;
    XImage ximage;
    Pixmap pixmap;
    Picture picture;
    GC gc;
    XRenderPictFormat *format;
    Cursor cursor;

    /* Unset the current cursor if no image is passed. */
    if (!image) {
        if (cur_cursor) {
            XUndefineCursor(d, w);
            XFreeCursor(d, cur_cursor);
            cur_cursor = 0;
        }
        return;
    }

    ximage.width = image->width;
    ximage.height = image->height;
    ximage.xoffset = 0;
    ximage.format = ZPixmap;
    ximage.data = (char *) image->pixels;
    ximage.byte_order = LSBFirst;
    ximage.bitmap_unit = 32;
    ximage.bitmap_bit_order = ximage.byte_order;
    ximage.bitmap_pad = 32;
    ximage.depth = 32;
    ximage.bits_per_pixel = 32;
    ximage.bytes_per_line = image->width * 4;
    ximage.red_mask = 0xff0000;
    ximage.green_mask = 0x00ff00;
    ximage.blue_mask = 0x0000ff;
    ximage.obdata = 0;
    if (!XInitImage(&ximage)) {
        puts("failed to init image");
        return;
    }
    pixmap = XCreatePixmap(d, w, image->width, image->height, 32);
    gc = XCreateGC(d, pixmap, 0, 0);
    XPutImage(d, pixmap, gc, &ximage, 0, 0, 0, 0, image->width, image->height);
    XFreeGC(d, gc);
    format = XRenderFindStandardFormat(d, PictStandardARGB32);
    picture = XRenderCreatePicture(d, pixmap, format, 0, 0);
    XFreePixmap(d, pixmap);
    cursor = XRenderCreateCursor(d, picture, image->xhot, image->yhot);
    XRenderFreePicture(d, picture);
    XDefineCursor(d, w, cursor);
    XFlush(d);
    if (cur_cursor)
        XFreeCursor(d, cur_cursor);
    cur_cursor = cursor;
}
예제 #23
0
static GlyphSet create_glyphs(Display *dpy, int format_id)
{
#define N_GLYPHS 4
	XRenderPictFormat *format;
	XGlyphInfo glyph = { 8, 8, 0, 0, 8, 0 };
	char image[4*8*8];
	GlyphSet glyphset;
	Glyph gid;
	int image_size;
	int bpp;
	int n;

	format = XRenderFindStandardFormat(dpy, format_id);
	if (format == NULL)
		return 0;

	switch (format_id) {
	case PictStandardARGB32:
	case PictStandardRGB24:
		image_size = 4 * 8 * 8;
		bpp = 4;
		break;
	case PictStandardA8:
	case PictStandardA4:
		image_size = 8 * 8;
		bpp = 1;
		break;
	case PictStandardA1:
		image_size = 8;
		bpp = 0;
		break;
	default:
		return 0;
	}

	glyphset = XRenderCreateGlyphSet(dpy, format);
	for (n = 0; n < N_GLYPHS; n++) {
		gid = n;

		switch (n) {
		case 0: render_clear(image, image_size, bpp); break;
		case 1: render_black(image, image_size, bpp); break;
		case 2: render_green(image, image_size, bpp); break;
		case 3: render_white(image, image_size, bpp); break;
		}

		XRenderAddGlyphs(dpy, glyphset,
				 &gid, &glyph, 1, image, image_size);
	}

	return glyphset;
}
예제 #24
0
파일: csi-replay.c 프로젝트: ghub/NVprSDK
static cairo_surface_t *
_xrender_surface_create (void *closure,
			 cairo_content_t content,
			 double width, double height,
			 long uid)
{
    Display *dpy;
    Pixmap pixmap;
    XRenderPictFormat *xrender_format;
    cairo_surface_t *surface;

    dpy = _get_display ();

    content = CAIRO_CONTENT_COLOR_ALPHA;

    switch (content) {
    case CAIRO_CONTENT_COLOR_ALPHA:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
	break;
    case CAIRO_CONTENT_COLOR:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
	break;
    case CAIRO_CONTENT_ALPHA:
    default:
	xrender_format = XRenderFindStandardFormat (dpy, PictStandardA8);
    }

    pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
		       width, height, xrender_format->depth);

    surface = cairo_xlib_surface_create_with_xrender_format (dpy, pixmap,
							     DefaultScreenOfDisplay (dpy),
							     xrender_format,
							     width, height);
    cairo_surface_set_user_data (surface, &_key,
				 (void *) pixmap, _destroy_pixmap);

    return surface;
}
XRenderPictFormat*
gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
{
    switch (format) {
        case ImageFormatARGB32:
            return XRenderFindStandardFormat (dpy, PictStandardARGB32);
            break;
        case ImageFormatRGB24:
            return XRenderFindStandardFormat (dpy, PictStandardRGB24);
            break;
        case ImageFormatA8:
            return XRenderFindStandardFormat (dpy, PictStandardA8);
            break;
        case ImageFormatA1:
            return XRenderFindStandardFormat (dpy, PictStandardA1);
            break;
        default:
            return NULL;
    }

    return (XRenderPictFormat*)NULL;
}
예제 #26
0
void
XrGStateInit(XrGState *gstate, Display *dpy)
{
    gstate->dpy = dpy;

    gstate->op = XR_GSTATE_OP_DEFAULT;
    gstate->winding = XR_GSTATE_WINDING_DEFAULT;
    gstate->line_width = XR_GSTATE_LINE_WIDTH_DEFAULT;

    gstate->solidFormat = XRenderFindStandardFormat(dpy, PictStandardARGB32);
    gstate->alphaFormat = XRenderFindStandardFormat(dpy, PictStandardA8);

    XrPictureInit(&gstate->picture, dpy);

    XrPictureInit(&gstate->src, dpy);
    XrColorInit(&gstate->color);
    XrPictureSetSolidColor(&gstate->src, &gstate->color, gstate->solidFormat);

    XrTransformInit(&gstate->transform);

    XrPathInit(&gstate->path);
    XrPathInit(&gstate->outline);
}
예제 #27
0
void test_target_create_render(struct test_display *dpy,
                               enum target target,
                               struct test_target *tt)
{
    XSetWindowAttributes attr;
    XGCValues gcv;

    tt->dpy = dpy;
    tt->target = target;

    tt->draw = dpy->root;
    tt->format = dpy->format;
    tt->width = dpy->width;
    tt->height = dpy->height;
    tt->depth = dpy->depth;

    switch (target) {
    case ROOT:
        break;

    case CHILD:
        attr.override_redirect = 1;
        tt->width /= 4;
        tt->height /= 4;
        tt->draw = XCreateWindow(dpy->dpy, tt->draw,
                                 dpy->width/2, dpy->height/2,
                                 tt->width, tt->height,
                                 0, tt->format->depth,
                                 InputOutput,
                                 DefaultVisual(dpy->dpy,
                                               DefaultScreen(dpy->dpy)),
                                 CWOverrideRedirect, &attr);
        XMapWindow(dpy->dpy, tt->draw);
        break;

    case PIXMAP:
        tt->format = XRenderFindStandardFormat(dpy->dpy, PictStandardARGB32);
        tt->draw = XCreatePixmap(dpy->dpy, tt->draw,
                                 dpy->width, dpy->height,
                                 tt->format->depth);
        tt->depth = 32;
        break;
    }

    tt->picture =
        XRenderCreatePicture(dpy->dpy, tt->draw, tt->format, 0, NULL);

    gcv.graphics_exposures = 0;
    tt->gc = XCreateGC(dpy->dpy, tt->draw, GCGraphicsExposures, &gcv);
}
예제 #28
0
int
InitCompositePix(XParms xp, Parms p, int reps)
{
    XRenderPictFormat	*format = NULL;
    int			depth;

    (void) InitCompositeWin (xp, p, reps);
    
    /* Create pixmap to write stuff into, and initialize it */
    switch (xp->planemask) {
    case PictStandardNative:
	depth = xp->vinfo.depth;
	format = XRenderFindVisualFormat (xp->d, xp->vinfo.visual);
	break;
    case PictStandardRGB24:
	depth = 24;
	break;
    case PictStandardARGB32:
	depth = 32;
	break;
    case PictStandardA8:
	depth = 8;
	break;
    case PictStandardA4:
	depth = 4;
	break;
    case PictStandardA1:
	depth = 1;
	break;
    default:
	depth = 0;
	break;
    }
    if (!format)
	format = XRenderFindStandardFormat (xp->d, xp->planemask);
    
    pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, depth);
    pixPict = XRenderCreatePicture (xp->d, pix, format, 0, NULL);
    
    XRenderComposite (xp->d, PictOpClear,
		      winPict, None, pixPict,
		      0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
    
#if 1
    XRenderComposite (xp->d, PictOpOver,
		      winPict, None, pixPict,
		      0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
#endif
    return reps;
}
예제 #29
0
TextSurface::TextSurface () :
    mWidth  (0),
    mHeight (0),
    mPixmap (None),
    cr (NULL),
    surface (NULL),
    layout (NULL),
    format (NULL),
    font (NULL),
    scrn (NULL)
{
    Display *dpy = screen->dpy ();

    scrn = ScreenOfDisplay (dpy, screen->screenNum ());

    if (!scrn)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't get screen for %d.", screen->screenNum ());
	return;
    }

    format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
    if (!format)
    {
	compLogMessage ("text", CompLogLevelError, "Couldn't get format.");
	return;
    }

    if (!initCairo (1, 1))
	return;

    /* init pango */
    layout = pango_cairo_create_layout (cr);
    if (!layout)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create pango layout.");
	return;
    }

    font = pango_font_description_new ();
    if (!font)
    {
	compLogMessage ("text", CompLogLevelError,
			"Couldn't create font description.");
	return;
    }
}
예제 #30
0
Xrender_Surf *
xrender_surf_new(Display *disp, Drawable draw, Visual *vis, int w, int h, int alpha)
{
   Xrender_Surf *rs;
   XRenderPictFormat *fmt;
   XRenderPictureAttributes att;
   
   rs = calloc(1, sizeof(Xrender_Surf));
   if (alpha)
     fmt = XRenderFindStandardFormat(disp, PictStandardARGB32);
   else
     fmt = XRenderFindStandardFormat(disp, PictStandardRGB24);
   rs->w = w;
   rs->h = h;
   rs->depth = fmt->depth;
   rs->vis = vis;
   rs->draw = XCreatePixmap(disp, draw, w, h, fmt->depth);
   att.dither = 1;
   att.component_alpha = 1;
   att.repeat = 0;
   rs->pic = XRenderCreatePicture(disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
   rs->allocated = 1;
   return rs;
}