]> Dogcows Code - chaz/openbox/blob - otk/surface.hh
kill some whitespace
[chaz/openbox] / otk / surface.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __surface_hh
3 #define __surface_hh
4
5 #include "size.hh"
6
7 extern "C" {
8 #include <X11/Xlib.h>
9 #define _XFT_NO_COMPAT_ // no Xft 1 API
10 #include <X11/Xft/Xft.h>
11
12 #ifdef HAVE_STDINT_H
13 # include <stdint.h>
14 #else
15 # ifdef HAVE_SYS_TYPES_H
16 # include <sys/types.h>
17 # endif
18 #endif
19 }
20
21 namespace otk {
22
23 class ScreenInfo;
24 class RenderColor;
25 class RenderControl;
26 class TrueRenderControl;
27 class PseudoRenderControl;
28
29 #ifdef HAVE_STDINT_H
30 typedef uint32_t pixel32;
31 typedef uint16_t pixel16;
32 #else
33 typedef u_int32_t pixel32;
34 typedef u_int16_t pixel16;
35 #endif /* HAVE_STDINT_H */
36
37 #ifdef WORDS_BIGENDIAN
38 const int default_red_shift=0;
39 const int default_green_shift=8;
40 const int default_blue_shift=16;
41 const int endian=MSBFirst;
42 #else
43 const int default_red_shift=16;
44 const int default_green_shift=8;
45 const int default_blue_shift=0;
46 const int endian=LSBFirst;
47 #endif /* WORDS_BIGENDIAN */
48
49 class Surface {
50 int _screen;
51 Size _size;
52 pixel32 *_pixel_data;
53 Pixmap _pixmap;
54 XftDraw *_xftdraw;
55
56 protected:
57 void createObjects();
58 void destroyObjects();
59
60 void setPixmap(XImage *image);
61 void setPixmap(const RenderColor &color);
62
63 public:
64 Surface(int screen, const Size &size);
65 virtual ~Surface();
66
67 inline int screen(void) const { return _screen; }
68
69 const Size& size() const { return _size; }
70
71 Pixmap pixmap() const { return _pixmap; }
72
73 pixel32 *pixelData() { return _pixel_data; }
74
75 //! Frees the pixel data when it will no longer be needed. Only do this once
76 //! you have completed rendering onto the surface.
77 void freePixelData();
78
79 // The RenderControl classes use the internal objects in this class to render
80 // to it. Noone else needs them tho, so they are private.
81 friend class RenderControl;
82 friend class TrueRenderControl;
83 friend class PseudoRenderControl;
84 };
85
86 }
87
88 #endif // __surface_hh
This page took 0.036809 seconds and 4 git commands to generate.