summaryrefslogtreecommitdiff
path: root/otk/surface.cc
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-01-20 06:11:12 +0000
committerDana Jansens <danakj@orodu.net>2003-01-20 06:11:12 +0000
commitd8d9b42777ace234f3471918e1210062578f8188 (patch)
tree915e9aa986ba44dda4c357bc834c68b4dc550525 /otk/surface.cc
parent0ba441fe8f379ec506000f7fa29f867cb6bc0d51 (diff)
widegt using new render system
Diffstat (limited to 'otk/surface.cc')
-rw-r--r--otk/surface.cc68
1 files changed, 38 insertions, 30 deletions
diff --git a/otk/surface.cc b/otk/surface.cc
index af9da7a6..99fa82b0 100644
--- a/otk/surface.cc
+++ b/otk/surface.cc
@@ -7,6 +7,7 @@
#include "surface.hh"
#include "display.hh"
#include "screeninfo.hh"
+#include "gccache.hh"
extern "C" {
#include <X11/Xutil.h>
@@ -14,22 +15,12 @@ extern "C" {
namespace otk {
-Surface::Surface(int screen)
- : _screen(screen),
- _size(1, 1),
- _pm(None),
- _xftdraw(0)
-{
- createObjects();
-}
-
Surface::Surface(int screen, const Point &size)
: _screen(screen),
_size(size),
- _pm(None),
+ _pixmap(None),
_xftdraw(0)
{
- createObjects();
}
Surface::~Surface()
@@ -37,36 +28,53 @@ Surface::~Surface()
destroyObjects();
}
-void Surface::createObjects()
+void Surface::setPixmap(const Color &color)
{
- assert(_pm == None); assert(!_xftdraw);
+ if (_pixmap == None)
+ createObjects();
- const ScreenInfo *info = display->screenInfo(_screen);
+ Pen p(color);
+ XFillRectangle(**display, _pixmap, p.gc(), 0, 0,
+ _size.x(), _size.y());
+}
+
+void Surface::setPixmap(XImage *image)
+{
+ printf("SET PIXMAP\n");
+ assert(image->width == _size.x());
+ assert(image->height == _size.y());
- _pm = XCreatePixmap(**display, info->rootWindow(), _size.x(), _size.y(),
- info->depth());
+ if (_pixmap == None)
+ createObjects();
- _xftdraw = XftDrawCreate(**display, _pm, info->visual(), info->colormap());
+ XPutImage(**display, _pixmap, DefaultGC(**display, _screen),
+ image, 0, 0, 0, 0, _size.x(), _size.y());
}
-void Surface::destroyObjects()
+void Surface::createObjects()
{
- assert(_pm != None); assert(_xftdraw);
-
- XftDrawDestroy(_xftdraw);
- _xftdraw = 0;
+ assert(_pixmap == None); assert(!_xftdraw);
- XFreePixmap(**display, _pm);
- _pm = None;
+ const ScreenInfo *info = display->screenInfo(_screen);
+
+ _pixmap = XCreatePixmap(**display, info->rootWindow(),
+ _size.x(), _size.y(), info->depth());
+
+ _xftdraw = XftDrawCreate(**display, _pixmap,
+ info->visual(), info->colormap());
}
-void Surface::setSize(int w, int h)
+void Surface::destroyObjects()
{
- if (w == _size.x() && h == _size.y()) return; // no change
-
- _size.setPoint(w, h);
- destroyObjects();
- createObjects();
+ if (_xftdraw) {
+ XftDrawDestroy(_xftdraw);
+ _xftdraw = 0;
+ }
+
+ if (_pixmap != None) {
+ XFreePixmap(**display, _pixmap);
+ _pixmap = None;
+ }
}
}