]> icculus.org git repositories - dana/openbox.git/blob - otk/rendercontrol.hh
start on the rendering images code
[dana/openbox.git] / otk / rendercontrol.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __rendercontrol_hh
3 #define __rendercontrol_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 }
9
10 #include "surface.hh"
11
12 namespace otk {
13
14 class ScreenInfo;
15 class RenderTexture;
16 class Font;
17 class RenderColor;
18 class ustring;
19 class PixmapMask;
20
21 class RenderControl {
22 protected:
23   int _screen;
24
25   /*
26   // color tables, meaning, 256 (possibly) different shades of each color,
27   // based on the number of bits there are available for each color in the
28   // visual
29   unsigned char _red_color_table[256];
30   unsigned char _green_color_table[256];
31   unsigned char _blue_color_table[256];
32   */
33
34 /*
35   Bool _dither;
36
37   int _cpc; // colors-per-channel: must be a value between [2,6]
38   int _bpp; // bits-per-pixel
39
40   unsigned int *_grad_xbuffer;
41   unsigned int *_grad_ybuffer;
42   unsigned int _grad_buffer_width;
43   unsigned int _grad_buffer_height;
44
45   unsigned long *_sqrt_table;
46
47   // These values are all determined based on a visual
48
49   int _red_bits;    // the number of bits (1-255) that each shade of color
50   int _green_bits;  // spans across. best case is 1, which gives 255 shades.
51   int _blue_bits;
52   unsigned char _red_color_table[256];
53   unsigned char _green_color_table[256];
54   unsigned char _blue_color_table[256];
55
56   // These are only used for TrueColor visuals
57   int _red_offset;  // the offset of each color in a color mask
58   int _green_offset;
59   int _blue_offset;
60
61   // These are only used for !TrueColor visuals
62   XColor *_colors;
63   int _ncolors;
64 */
65
66   RenderControl(int screen);
67
68   virtual void drawSolidBackground(Surface& sf,
69                                    const RenderTexture& texture) const;
70   
71 public:
72   virtual ~RenderControl();
73
74   static RenderControl *getRenderControl(int screen);
75
76   virtual void drawRoot(const RenderColor &color) const;
77   
78   //! Draws a background onto a Surface, as specified by a RenderTexture
79   /*!
80     This function will overwrite the entire surface.
81   */
82   virtual void drawBackground(Surface &sf,
83                               const RenderTexture &texture) const = 0;
84
85   //! Draws an image onto the surface
86   /*!
87     This function will overwrite the entire surface.<br>
88     The image must be specified in 32-bit packed ARGB format. The current
89     background will be used for applying the alpha.
90   */
91   virtual void drawImage(Surface &sf, int w, int h,
92                          unsigned long *data) const = 0;
93   
94   //! Draws a string onto a Surface
95   virtual void drawString(Surface &sf, const Font &font, int x, int y,
96                           const RenderColor &color,
97                           const ustring &string) const;
98
99   //! Draws a PixmapMask with a specified color onto a Surface
100   virtual void drawMask(Surface &sf, const RenderColor &color,
101                         const PixmapMask &mask) const;
102 };
103
104 }
105
106 #endif // __rendercontrol_hh