Exemplo n.º 1
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);
}
// This code can only run after thumbnailer's drawing_area has been realized,
// and after the main loop has run so that wnck_window is initialized.
static void
initialize_thumbnailer_pictures (SSThumbnailer *thumbnailer)
{
  Display *display;
  GdkScreen *screen;
  XRenderPictFormat *format;
  XRenderPictureAttributes pa;

  display = gdk_x11_get_default_xdisplay ();
  screen = gtk_widget_get_screen (thumbnailer->drawing_area);
  format = XRenderFindVisualFormat (display, DefaultVisual (
      display, gdk_screen_get_number (screen)));

  thumbnailer->thumbnail_pixmap = gdk_pixmap_new (
      thumbnailer->drawing_area->window, THUMBNAIL_SIZE, THUMBNAIL_SIZE, -1);

  thumbnailer->thumbnail_picture = XRenderCreatePicture (display,
      GDK_DRAWABLE_XID (thumbnailer->thumbnail_pixmap), format, 0, NULL);

  pa.subwindow_mode = IncludeInferiors;
  thumbnailer->window_picture = XRenderCreatePicture (display,
      wnck_window_get_xid (thumbnailer->wnck_window),
      format, CPSubwindowMode, &pa);
  XRenderSetPictureFilter (display, thumbnailer->window_picture,
      "good", NULL, 0);
}
Exemplo n.º 3
0
void X11Grabber::setupResources()
{
	if(_XShmAvailable && !_useXGetImage)
	{
		_xImage = XShmCreateImage(_x11Display, _windowAttr.visual,
		_windowAttr.depth, ZPixmap, NULL, &_shminfo,
		_croppedWidth, _croppedHeight);
		_shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
		_xImage->data = (char*)shmat(_shminfo.shmid,0,0);
		_shminfo.shmaddr = _xImage->data;
		_shminfo.readOnly = False;
		XShmAttach(_x11Display, &_shminfo);
	}
	if (_XRenderAvailable && !_useXGetImage)
	{
		if(_XShmPixmapAvailable)
		{
			_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth);
		}
		else
		{
			_pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth);
		}
		_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
		_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
		_srcPicture = XRenderCreatePicture(_x11Display, _window, _srcFormat, CPRepeat, &_pictAttr);
		_dstPicture = XRenderCreatePicture(_x11Display, _pixmap, _dstFormat, CPRepeat, &_pictAttr);
		XRenderSetPictureFilter(_x11Display, _srcPicture, FilterBilinear, NULL, 0);
	}
}
Exemplo n.º 4
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

}
Exemplo n.º 5
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);

    }
}
Exemplo n.º 6
0
static void _render_copy(struct test_target *tt,
			 int x, int y, int w, int h,
			 uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
{
	XRenderColor color;
	Picture src;
	Pixmap tmp;

	tmp = XCreatePixmap(tt->dpy->dpy, DefaultRootWindow(tt->dpy->dpy),
			    10+w, 20+h, tt->format->depth);
	src = XRenderCreatePicture(tt->dpy->dpy, tmp, tt->format, 0, NULL);

	/* magenta border */
	color.red = 0xffff;
	color.green = 0;
	color.blue = 0xffff;
	color.alpha = 0xffff;
	XRenderFillRectangle(tt->dpy->dpy, PictOpSrc, src, &color, 0, 0, w+10, h+20);

	color.red = red * alpha;
	color.green = green * alpha;
	color.blue = blue * alpha;
	color.alpha = alpha << 8 | alpha;
	XRenderFillRectangle(tt->dpy->dpy, PictOpSrc, src, &color, 5, 10, w, h);

	XRenderComposite(tt->dpy->dpy, PictOpSrc,
			 src, 0, tt->picture,
			 5, 10,
			 0, 0,
			 x, y,
			 w, h);

	XRenderFreePicture(tt->dpy->dpy, src);
	XFreePixmap(tt->dpy->dpy, tmp);
}
Exemplo n.º 7
0
void clear_pixmap(Pixmap p, int x, int y, int w, int h)
{
	Picture pict = XRenderCreatePicture(server.dsp, p, XRenderFindVisualFormat(server.dsp, server.visual), 0, 0);
	XRenderColor col = { .red=0, .green=0, .blue=0, .alpha=0 };
	XRenderFillRectangle(server.dsp, PictOpSrc, pict, &col, x, y, w, h);
	XRenderFreePicture(server.dsp, pict);
}
Exemplo n.º 8
0
Arquivo: gui.c Projeto: mortehu/bra
static void
configure_window (struct gui_instance *gi)
{
  if (gi->back_buffer)
    XRenderFreePicture (GUI_display, gi->back_buffer);

  if (gi->fontdraw)
    XftDrawDestroy (gi->fontdraw);

  if (gi->pmap)
    XFreePixmap (GUI_display, gi->pmap);

  if (gi->gc)
    XFreeGC (GUI_display, gi->gc);

  gi->gc = XCreateGC (GUI_display, gi->window, 0, 0);

  gi->pmap = XCreatePixmap (GUI_display, gi->window, gi->width, gi->height, GUI_visual_info->depth);

  gi->fontdraw = XftDrawCreate (GUI_display, gi->pmap, GUI_visual, DefaultColormap (GUI_display, GUI_screenidx));

  gi->back_buffer
    = XRenderCreatePicture (GUI_display, gi->pmap, xrenderpictformat, 0, 0);

  if (!gi->back_buffer)
    errx (EXIT_FAILURE, "Failed to create back buffer for X window (XRenderCreatePicture)");
}
Exemplo n.º 9
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 */
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
static Picture
gdk_x11_drawable_get_picture (GdkDrawable *drawable)
{
  GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable);
  
  if (!impl->picture)
    {
      Display *xdisplay = GDK_SCREEN_XDISPLAY (impl->screen);
      XRenderPictFormat *format;
      
      GdkVisual *visual = gdk_drawable_get_visual (GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper);
      if (!visual)
	return None;

      format = XRenderFindVisualFormat (xdisplay, GDK_VISUAL_XVISUAL (visual));
      if (format)
	{
	  XRenderPictureAttributes attributes;
	  attributes.graphics_exposures = False;
	  
	  impl->picture = XRenderCreatePicture (xdisplay, impl->xid, format,
						CPGraphicsExposure, &attributes);
	}
    }
  
  return impl->picture;
}
Exemplo n.º 12
0
void
clientwin_move(ClientWin *cw, float f, int x, int y)
{
	/* int border = MAX(1, (double)DISTANCE(cw->mainwin) * f * 0.25); */
	int border = 0;
	XSetWindowBorderWidth(cw->mainwin->dpy, cw->mini.window, border);
	
	cw->factor = f;
	cw->mini.x = x + (int)cw->x * f;
	cw->mini.y = y + (int)cw->y * f;
	if(cw->mainwin->lazy_trans)
	{
		cw->mini.x += cw->mainwin->x;
		cw->mini.y += cw->mainwin->y;
	}
	cw->mini.width = MAX(1, (int)cw->client.width * f);
	cw->mini.height = MAX(1, (int)cw->client.height * f);
	XMoveResizeWindow(cw->mainwin->dpy, cw->mini.window, cw->mini.x - border, cw->mini.y - border, cw->mini.width, cw->mini.height);
	
	if(cw->pixmap)
		XFreePixmap(cw->mainwin->dpy, cw->pixmap);
	
	if(cw->destination)
		XRenderFreePicture(cw->mainwin->dpy, cw->destination);
	
	cw->pixmap = XCreatePixmap(cw->mainwin->dpy, cw->mini.window, cw->mini.width, cw->mini.height, cw->mainwin->depth);
	XSetWindowBackgroundPixmap(cw->mainwin->dpy, cw->mini.window, cw->pixmap);
	
	cw->destination = XRenderCreatePicture(cw->mainwin->dpy, cw->pixmap, cw->mini.format, 0, 0);
}
Exemplo n.º 13
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);
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
0
Workspace::Workspace() : mDamage( None ), mWaitForClients( false ), mInitialRepaint( true )
{
    Extensions::initialize();

	XGrabServer( dpy );

	// Redirect all toplevel window contents to offscreen storage
	XCompositeRedirectSubwindows( dpy, rootId(), CompositeRedirectManual );

    initClientList();

	// Request notification about toplevel window state changes
	XSelectInput( dpy, rootId(),
			SubstructureNotifyMask | ExposureMask |
			StructureNotifyMask | PropertyChangeMask );

	XUngrabServer( dpy );

	// Get the picture format for the root window
	mFormat = XRenderFindVisualFormat( dpy, visual() );

	// Create an unclipped picture for drawing on the root window
	XRenderPictureAttributes pa;
	pa.subwindow_mode = IncludeInferiors;
	mFrontbuffer = XRenderCreatePicture( dpy, rootId(), format(), CPSubwindowMode, &pa );

	createBackbuffer();

	XSync( dpy, false );
}
Exemplo n.º 16
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);
}
Exemplo n.º 17
0
void PreviewWidget::paintEvent(QPaintEvent *)
{
    QPixmap buffer(size());
    QPainter p(&buffer);
    p.fillRect(rect(), colorGroup().brush(QColorGroup::Background));
    Picture dest;

    if(!qt_has_xft || !qt_use_xrender)
    {
        XRenderPictFormat *fmt = XRenderFindVisualFormat(x11Display(), (Visual *)buffer.x11Visual());
        dest = XRenderCreatePicture(x11Display(), buffer.handle(), fmt, 0, NULL);
    }
    else
        dest = buffer.x11RenderHandle();

    int rwidth = width() / numCursors;

    for(int i = 0; i < numCursors; i++)
    {
        if(cursors[i]->picture())
        {
            XRenderComposite(x11Display(), PictOpOver, cursors[i]->picture(), 0, dest, 0, 0, 0, 0, rwidth * i + (rwidth - cursors[i]->width()) / 2,
                             (height() - cursors[i]->height()) / 2, cursors[i]->width(), cursors[i]->height());
        }
    }

    bitBlt(this, 0, 0, &buffer);

    if(!qt_has_xft || !qt_use_xrender)
        XRenderFreePicture(x11Display(), dest);
}
Exemplo n.º 18
0
void window_set_mapped(Window id, bool mapped)
{
	window_t *window = window_get(id);
	
	if (window == NULL)
		return;
	
	window->mapped = mapped;
	
	if (mapped == TRUE) {
		XRenderPictFormat *format;
		XRenderPictureAttributes pa;
		
		format = XRenderFindVisualFormat(conn, visual);
		pa.subwindow_mode = IncludeInferiors;
		
		if (window->picture != None)
			XRenderFreePicture(conn, window->picture);
		
		if (window->pixmap != None)
			XFreePixmap(conn, window->pixmap);
		
		window->pixmap = XCompositeNameWindowPixmap(conn, id);
		window->picture = XRenderCreatePicture(conn, window->pixmap,
				format, CPSubwindowMode, &pa);
		XDamageCreate(conn, window->pixmap, XDamageReportNonEmpty);
		
		window_list_remove(id);
		window_list_append(id);
	}
}
Exemplo n.º 19
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);
}
Exemplo n.º 20
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;
}
Exemplo n.º 21
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;
}
Exemplo n.º 22
0
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);
}
Exemplo n.º 23
0
void init_render(struct xinfo *X, struct panel *P)
{
	bbwidth = P->width;
	bbheight = P->theme->height;
	bb = imlib_create_image(bbwidth, bbheight);
	bbcolor = imlib_create_image(bbwidth, bbheight);
	imlib_context_set_image(bb);
	imlib_image_set_has_alpha(1);
	bbdpy = X->display;
	bbvis = X->visual;
	bbwin = P->win;
	bbcm = X->colmap;
	bbx = P->x;
	bby = P->y;
	rootpmap = &X->rootpmap;
	theme = P->theme;

	imlib_context_set_display(bbdpy);
	imlib_context_set_visual(bbvis);
	imlib_context_set_colormap(bbcm);

#ifdef WITH_COMPOSITE
	if (P->theme->use_composite) {
		XRenderPictFormat *fmt = XRenderFindStandardFormat(bbdpy, PictStandardARGB32);
		bbalpha = imlib_create_image(bbwidth, bbheight);

		pixcolor = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32);
		pixalpha = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32);

		piccolor = XRenderCreatePicture(bbdpy, pixcolor, fmt, 0, 0);
		picalpha = XRenderCreatePicture(bbdpy, pixalpha, fmt, 0, 0);
	
		XRenderPictureAttributes pwin;
		pwin.subwindow_mode = IncludeInferiors;
		rootpic = XRenderCreatePicture(bbdpy, bbwin, XRenderFindVisualFormat(bbdpy, bbvis), 
				CPSubwindowMode, &pwin);
	} else 
#endif
	if (*rootpmap) {
		update_bg();
	} else {
		set_bg();
	}

	imlib_context_set_blend(0);
	imlib_context_set_operation(IMLIB_OP_COPY);
}
Exemplo n.º 24
0
// Create the compositing buffer. The root window is not double-buffered,
// so it is done manually using this buffer,
void SceneXrender::createBuffer()
{
    if (buffer != None)
        XRenderFreePicture(display(), buffer);
    Pixmap pixmap = XCreatePixmap(display(), rootWindow(), displayWidth(), displayHeight(), DefaultDepth(display(), DefaultScreen(display())));
    buffer = XRenderCreatePicture(display(), pixmap, format, 0, 0);
    XFreePixmap(display(), pixmap);   // The picture owns the pixmap now
}
Exemplo n.º 25
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);
}
Exemplo n.º 26
0
XftDraw *XftDrawCreateAlpha( Display *display,
			     Pixmap pixmap,
			     int depth )
{
    // taken from Xft 1 sources, see copyright above
    XftDraw     *draw;

    draw = (XftDraw *) malloc (sizeof (XftDraw));
    if (!draw)
	return 0;
    draw->dpy = display;
    draw->drawable = pixmap;
    draw->visual = 0;
    draw->colormap = 0;
    draw->core_set = False;
    draw->clip = 0;

    // Qt addition - go ahead and create the render picture now
    draw->render_set = True;
    draw->render_able = False;

    if ( qt_use_xrender ) {
	draw->render_able = True;

	XRenderPictFormat *format = 0;
	XRenderPictFormat req;
	unsigned long mask = PictFormatType | PictFormatDepth | PictFormatAlphaMask;
	req.type = PictTypeDirect;
	req.depth = depth;
	req.direct.alphaMask = 0xff;
	format = XRenderFindFormat(draw->dpy, mask, &req, 0);
	if (format) {
	    draw->render.pict =
		XRenderCreatePicture(draw->dpy, draw->drawable, format, 0, 0);
	}

	// to keep Xft from trying to free zero pixmaps/pictures, we need to create
	// 2 more pictures (that are identical to draw->render.pict) :/
	draw->render.src[0].pict =
	    XRenderCreatePicture( draw->dpy, draw->drawable, format, 0, 0 );
	draw->render.src[1].pict =
	    XRenderCreatePicture( draw->dpy, draw->drawable, format, 0, 0 );
    }

    return draw;
}
Exemplo n.º 27
0
PP_Resource
ppb_graphics2d_create(PP_Instance instance, const struct PP_Size *size, PP_Bool is_always_opaque)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }
    PP_Resource graphics_2d = pp_resource_allocate(PP_RESOURCE_GRAPHICS2D, pp_i);
    struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D);
    if (!g2d) {
        trace_error("%s, can't create graphics2d resource\n", __func__);
        return 0;
    }

    g2d->is_always_opaque = is_always_opaque;
    g2d->scale = config.device_scale;
    g2d->width =  size->width;
    g2d->height = size->height;
    g2d->stride = 4 * size->width;

    g2d->scaled_width = g2d->width * g2d->scale + 0.5;
    g2d->scaled_height = g2d->height * g2d->scale + 0.5;
    g2d->scaled_stride = 4 * g2d->scaled_width;

    g2d->data = calloc(g2d->stride * g2d->height, 1);
    g2d->second_buffer = calloc(g2d->scaled_stride * g2d->scaled_height, 1);
    if (!g2d->data || !g2d->second_buffer) {
        trace_warning("%s, can't allocate memory\n", __func__);
        free_and_nullify(g2d->data);
        free_and_nullify(g2d->second_buffer);
        pp_resource_release(graphics_2d);
        ppb_core_release_resource(graphics_2d);
        return 0;
    }
    g2d->cairo_surf = cairo_image_surface_create_for_data((unsigned char *)g2d->data,
                            CAIRO_FORMAT_ARGB32, g2d->width, g2d->height, g2d->stride);
    g2d->task_list = NULL;

    if (pp_i->is_transparent) {
        // we need XRender picture (which in turn requires X Pixmap) to alpha blend
        // our images with existing pixmap provided by the browser. This is only needed
        // is instance is transparent, therefore depth is always 32-bit.
        pthread_mutex_lock(&display.lock);
        g2d->pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), g2d->scaled_width,
                                    g2d->scaled_height, 32);
        XFlush(display.x);
        g2d->xr_pict = XRenderCreatePicture(display.x, g2d->pixmap, display.pictfmt_argb32, 0, 0);
        g2d->gc = XCreateGC(display.x, g2d->pixmap, 0, 0);
        XFlush(display.x);
        pthread_mutex_unlock(&display.lock);
    }

    pp_resource_release(graphics_2d);
    return graphics_2d;
}
Exemplo n.º 28
0
int
InitCompositeWin(XParms xp, Parms p, int reps)
{
    XRenderPictFormat	*format;
    (void) InitScroll (xp, p, reps);
    InitCopyLocations (xp, p, reps);
    format = XRenderFindVisualFormat (xp->d, xp->vinfo.visual);
    winPict = XRenderCreatePicture (xp->d, xp->w, format, 0, NULL);
    return reps;
}
Exemplo n.º 29
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;
}
Exemplo n.º 30
0
ClientWin *
clientwin_create(MainWin *mw, Window client)
{
	ClientWin *cw = (ClientWin *)malloc(sizeof(ClientWin));
	XSetWindowAttributes sattr;
	XWindowAttributes attr;
	XRenderPictureAttributes pa;
	
	cw->mainwin = mw;
	cw->pixmap = None;
	cw->focused = 0;
	cw->origin = cw->destination = None;
	cw->damage = None;
	cw->damaged = False;
	/* cw->repair = None; */
	
	sattr.border_pixel = sattr.background_pixel = 0;
	sattr.colormap = mw->colormap;
	
	sattr.event_mask = ButtonPressMask |
	                   ButtonReleaseMask |
	                   KeyReleaseMask |
	                   EnterWindowMask |
	                   LeaveWindowMask |
	                   PointerMotionMask |
	                   ExposureMask |
	                   FocusChangeMask;
	
	sattr.override_redirect = mw->lazy_trans;
	
	cw->client.window = client;
	cw->mini.format = mw->format;
	cw->mini.window = XCreateWindow(mw->dpy, mw->lazy_trans ? mw->root : mw->window, 0, 0, 1, 1, 0,
	                                mw->depth, InputOutput, mw->visual,
	                                CWColormap | CWBackPixel | CWBorderPixel | CWEventMask | CWOverrideRedirect, &sattr);
	
	if(cw->mini.window == None)
	{
		free(cw);
		return 0;
	}
	
	XGetWindowAttributes(mw->dpy, client, &attr);
	cw->client.format = XRenderFindVisualFormat(mw->dpy, attr.visual);
	
	pa.subwindow_mode = IncludeInferiors;
	cw->origin = XRenderCreatePicture (cw->mainwin->dpy, cw->client.window, cw->client.format, CPSubwindowMode, &pa);
	
	XRenderSetPictureFilter(cw->mainwin->dpy, cw->origin, FilterBest, 0, 0);
	
	XSelectInput(cw->mainwin->dpy, cw->client.window, SubstructureNotifyMask | StructureNotifyMask);
	
	return cw;
}