]> icculus.org git repositories - mikachu/openbox.git/blob - otk/rendercontrol.hh
make all the rendering code in RenderControl. use true/pseudo RenderControl classes...
[mikachu/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 reduceDepth(Surface &sf, XImage *im) const = 0;
69   
70   inline void highlight(pixel32 *x, pixel32 *y, bool raised) const;
71   void verticalGradient(Surface &sf, const RenderTexture &texture) const;
72   void diagonalGradient(Surface &sf, const RenderTexture &texture) const;
73   void crossDiagonalGradient(Surface &sf, const RenderTexture &texture) const;
74   virtual void drawGradientBackground(Surface &sf,
75                                       const RenderTexture &texture) const;
76   virtual void drawSolidBackground(Surface& sf,
77                                    const RenderTexture& texture) const;
78
79 public:
80   virtual ~RenderControl();
81
82   static RenderControl *getRenderControl(int screen);
83
84   virtual void drawRoot(const RenderColor &color) const;
85   
86   //! Draws a background onto a Surface, as specified by a RenderTexture
87   /*!
88     This function will overwrite the entire surface.
89   */
90   virtual void drawBackground(Surface &sf,
91                               const RenderTexture &texture) const;
92
93   //! Draws an image onto the surface
94   /*!
95     This function will overwrite the entire surface.<br>
96     The image must be specified in 32-bit packed ARGB format. The current
97     background will be used for applying the alpha.
98   */
99   virtual void drawImage(Surface &sf, int w, int h,
100                          unsigned long *data) const;
101   
102   //! Draws a string onto a Surface
103   virtual void drawString(Surface &sf, const Font &font, int x, int y,
104                           const RenderColor &color,
105                           const ustring &string) const;
106
107   //! Draws a PixmapMask with a specified color onto a Surface
108   virtual void drawMask(Surface &sf, const RenderColor &color,
109                         const PixmapMask &mask) const;
110 };
111
112 }
113
114 #endif // __rendercontrol_hh