]>
Dogcows Code - chaz/openbox/blob - Image.hh
94cb3c6015507ef2b1527411cb154d16d41be4e6
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Image.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
29 #include <X11/Xutil.h>
35 #include "BaseDisplay.hh"
43 BImageControl
*control
;
48 int red_offset
, green_offset
, blue_offset
, red_bits
, green_bits
, blue_bits
,
50 unsigned char *red
, *green
, *blue
, *red_table
, *green_table
, *blue_table
;
51 unsigned int width
, height
, *xtable
, *ytable
;
53 void TrueColorDither(unsigned int bit_depth
, int bytes_per_line
,
54 unsigned char *pixel_data
);
55 void PseudoColorDither(int bytes_per_line
, unsigned char *pixel_data
);
57 void OrderedPseudoColorDither(int bytes_per_line
, unsigned char *pixel_data
);
60 Pixmap
renderPixmap(void);
61 Pixmap
render_solid(const BTexture
&texture
);
62 Pixmap
render_gradient(const BTexture
&texture
);
64 XImage
*renderXImage(void);
69 void border(const BTexture
&texture
);
76 void cdgradient(void);
77 void pcgradient(void);
81 BImage(BImageControl
*c
, int w
, int h
);
84 Pixmap
render(const BTexture
&texture
);
88 class BImageControl
: public TimeoutHandler
{
93 unsigned int count
, width
, height
;
94 unsigned long pixel1
, pixel2
, texture
;
97 BImageControl(BaseDisplay
*dpy
, const ScreenInfo
*scrn
,
98 bool _dither
= False
, int _cpc
= 4,
99 unsigned long cache_timeout
= 300000l,
100 unsigned long cmax
= 200l);
101 virtual ~BImageControl(void);
103 inline BaseDisplay
*getBaseDisplay(void) const { return basedisplay
; }
105 inline bool doDither(void) { return dither
; }
107 inline const ScreenInfo
*getScreenInfo(void) { return screeninfo
; }
109 inline Window
getDrawable(void) const { return window
; }
111 inline Visual
*getVisual(void) { return screeninfo
->getVisual(); }
113 inline int getBitsPerPixel(void) const { return bits_per_pixel
; }
114 inline int getDepth(void) const { return screen_depth
; }
115 inline int getColorsPerChannel(void) const
116 { return colors_per_channel
; }
118 unsigned long getSqrt(unsigned int x
);
120 Pixmap
renderImage(unsigned int width
, unsigned int height
,
121 const BTexture
&texture
);
123 void installRootColormap(void);
124 void removeImage(Pixmap pixmap
);
125 void getColorTables(unsigned char **rmt
, unsigned char **gmt
,
127 int *roff
, int *goff
, int *boff
,
128 int *rbit
, int *gbit
, int *bbit
);
129 void getXColorTable(XColor
**c
, int *n
);
130 void getGradientBuffers(unsigned int w
, unsigned int h
,
131 unsigned int **xbuf
, unsigned int **ybuf
);
132 void setDither(bool d
) { dither
= d
; }
133 void setColorsPerChannel(int cpc
);
135 virtual void timeout(void);
139 BaseDisplay
*basedisplay
;
140 const ScreenInfo
*screeninfo
;
149 int colors_per_channel
, ncolors
, screen_number
, screen_depth
,
150 bits_per_pixel
, red_offset
, green_offset
, blue_offset
,
151 red_bits
, green_bits
, blue_bits
;
152 unsigned char red_color_table
[256], green_color_table
[256],
153 blue_color_table
[256];
154 unsigned int *grad_xbuffer
, *grad_ybuffer
, grad_buffer_width
,
156 unsigned long *sqrt_table
, cache_max
;
158 typedef std::list
<CachedImage
> CacheContainer
;
159 CacheContainer cache
;
161 Pixmap
searchCache(const unsigned int width
, const unsigned int height
,
162 const unsigned long texture
,
163 const BColor
&c1
, const BColor
&c2
);
This page took 0.043697 seconds and 3 git commands to generate.