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