5 gPainter ist die high-level version. die highlevel daten werden zu low level opcodes ueber
6 die gRC-queue geschickt und landen beim gDC der hardwarespezifisch ist, meist aber auf einen
7 gPixmap aufsetzt (und damit unbeschleunigt ist).
15 #include <lib/base/elock.h>
16 #include <lib/base/message.h>
17 #include <lib/gdi/erect.h>
18 #include <lib/gdi/gpixmap.h>
19 #include <lib/gdi/region.h>
20 #include <lib/gdi/gfont.h>
33 fill, fillRegion, clear,
44 setBackgroundColorRGB,
45 setForegroundColorRGB,
49 setClip, addClip, popClip,
139 /* gRC is the singleton which controls the fifo and dispatches commands */
140 class gRC: public iObject, public Object
144 friend class gPainter;
145 static gRC *instance;
148 static void *thread_wrapper(void *ptr);
149 pthread_t the_thread;
150 pthread_mutex_t mutex;
155 gOpcode queue[MAXSIZE];
158 eFixedMessagePump<int> m_notify_pump;
159 void recv_notify(const int &i);
164 void submit(const gOpcode &o);
166 Signal0<void> notify;
168 static gRC *getInstance();
171 /* gPainter is the user frontend, which in turn sends commands through gRC */
179 void begin(const eRect &rect);
182 gPainter(gDC *dc, eRect rect=eRect());
185 void setBackgroundColor(const gColor &color);
186 void setForegroundColor(const gColor &color);
188 void setBackgroundColor(const gRGB &color);
189 void setForegroundColor(const gRGB &color);
191 void setFont(gFont *font);
192 /* flags only THESE: */
195 // todo, make mask. you cannot align both right AND center AND block ;)
196 RT_HALIGN_LEFT = 0, /* default */
198 RT_HALIGN_CENTER = 2,
201 RT_VALIGN_TOP = 0, /* default */
202 RT_VALIGN_CENTER = 8,
203 RT_VALIGN_BOTTOM = 16,
207 void renderText(const eRect &position, const std::string &string, int flags=0);
209 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
211 void fill(const eRect &area);
212 void fill(const gRegion &area);
221 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
223 void setPalette(gRGB *colors, int start=0, int len=256);
224 void setPalette(gPixmap *source);
225 void mergePalette(gPixmap *target);
227 void line(ePoint start, ePoint end);
229 void setOffset(ePoint abs);
230 void moveOffset(ePoint rel);
233 void resetClip(const gRegion &clip);
234 void clip(const gRegion &clip);
244 class gDC: public iObject
248 ePtr<gPixmap> m_pixmap;
250 gColor m_foreground_color, m_background_color;
251 ePtr<gFont> m_current_font;
252 ePoint m_current_offset;
254 std::stack<gRegion> m_clip_stack;
255 gRegion m_current_clip;
258 virtual void exec(gOpcode *opcode);
259 gDC(gPixmap *pixmap);
262 gRegion &getClip() { return m_current_clip; }
263 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
264 gRGB getRGB(gColor col);
265 virtual eSize size() { return m_pixmap->size(); }