1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
7 #include "screeninfo.hh"
8 #include "rendercolor.hh"
11 #include <X11/Xutil.h>
16 Surface::Surface(int screen, const Size &size)
29 void Surface::setPixmap(const RenderColor &color)
34 XFillRectangle(**display, _pixmap, color.gc(), 0, 0,
35 _size.width(), _size.height());
38 void Surface::setPixmap(XImage *image)
40 assert(image->width == _size.width());
41 assert(image->height == _size.height());
46 XPutImage(**display, _pixmap, DefaultGC(**display, _screen),
47 image, 0, 0, 0, 0, _size.width(), _size.height());
50 void Surface::createObjects()
52 assert(_pixmap == None); assert(!_xftdraw);
54 const ScreenInfo *info = display->screenInfo(_screen);
56 _pixmap = XCreatePixmap(**display, info->rootWindow(),
57 _size.width(), _size.height(), info->depth());
58 assert(_pixmap != None);
60 _xftdraw = XftDrawCreate(**display, _pixmap,
61 info->visual(), info->colormap());
65 void Surface::destroyObjects()
68 XftDrawDestroy(_xftdraw);
72 if (_pixmap != None) {
73 XFreePixmap(**display, _pixmap);