just show hdd info when there is one
[enigma2.git] / lib / gdi / gpixmap.h
1 #ifndef __gpixmap_h
2 #define __gpixmap_h
3
4 #include <pthread.h>
5 #include <string>
6 #include <lib/base/object.h>
7 #include <lib/base/elock.h>
8 #include <lib/gdi/erect.h>
9 #include <lib/gdi/fb.h>
10
11 struct gColor
12 {
13         int color;
14         gColor(int color): color(color)
15         {
16         }
17         gColor(): color(0)
18         {
19         }
20         operator int() const { return color; }
21         bool operator==(const gColor &o) const { return o.color==color; }
22 };
23
24 struct gRGB
25 {
26         unsigned char b, g, r, a;
27         gRGB(int r, int g, int b, int a=0): b(b), g(g), r(r), a(a)
28         {
29         }
30         gRGB(unsigned long val): b(val&0xFF), g((val>>8)&0xFF), r((val>>16)&0xFF), a((val>>24)&0xFF)            // ARGB
31         {
32         }
33         gRGB(): b(0), g(0), r(0), a(0)
34         {
35         }
36         void operator=(unsigned long val)
37         {
38                 b = val&0xFF;
39                 g = (val>>8)&0xFF;
40                 r = (val>>16)&0xFF;
41                 a = (val>>24)&0xFF;
42         }
43         bool operator < (const gRGB &c) const
44         {
45                 if (b < c.b)
46                         return 1;
47                 if (b == c.b)
48                 {
49                         if (g < c.g)
50                                 return 1;
51                         if (g == c.g)
52                         {
53                                 if (r < c.r)
54                                         return 1;
55                                 if (r == c.r)
56                                         return a < c.a;
57                         }
58                 }
59                 return 0;
60         }
61         bool operator==(const gRGB &c) const
62         {
63                 return (b == c.b) && (g == c.g) && (r == c.r) && (a == c.a);
64         }
65 };
66
67 struct gPalette
68 {
69         int start, colors;
70         gRGB *data;
71         gColor findColor(const gRGB &rgb) const;
72 };
73
74 struct gLookup
75 {
76         int size;
77         gColor *lookup;
78         gLookup(int size, const gPalette &pal, const gRGB &start, const gRGB &end);
79         gLookup();
80         ~gLookup() { delete [] lookup; }
81         void build(int size, const gPalette &pal, const gRGB &start, const gRGB &end);
82 };
83
84 struct gSurface
85 {
86         int type;
87         int x, y, bpp, bypp, stride;
88         gPalette clut;
89         
90         void *data;
91         int data_phys;
92         int offset; // only for backbuffers
93
94         gSurface();
95         gSurface(eSize size, int bpp, int accel);
96         ~gSurface();
97 };
98
99 class gPixmap: public iObject
100 {
101 private:
102 DECLARE_REF(gPixmap);
103 private:
104         friend class gDC;
105         void fill(const gRegion &clip, const gColor &color);
106         
107         void blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flags=0);
108         
109         void mergePalette(const gPixmap &target);
110         void line(const gRegion &clip, ePoint start, ePoint end, gColor color);
111 public:
112         enum
113         {
114                 blitAlphaTest=1,
115                 blitAlphaBlend=2
116         };
117
118         gSurface *surface;
119         
120         eLock contentlock;
121         int final;
122         
123         gPixmap *lock();
124         void unlock();
125         
126         eSize size() const { return eSize(surface->x, surface->y); }
127         
128         gPixmap(gSurface *surface);
129         gPixmap(eSize, int bpp, int accel = 0);
130         virtual ~gPixmap();
131 };
132
133 TEMPLATE_TYPEDEF(ePtr<gPixmap>, gPixmapPtr);
134
135 #endif