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/ringbuffer.h>
16 #include <lib/base/elock.h>
17 #include <lib/base/message.h>
18 #include <lib/gdi/erect.h>
19 #include <lib/gdi/gpixmap.h>
20 #include <lib/gdi/region.h>
21 #include <lib/gdi/gfont.h>
34 fill, fillRegion, clear,
45 setBackgroundColorRGB,
46 setForegroundColorRGB,
50 setClip, addClip, popClip,
138 /* gRC is the singleton which controls the fifo and dispatches commands */
139 class gRC: public iObject, public Object
143 friend class gPainter;
144 static gRC *instance;
146 static void *thread_wrapper(void *ptr);
147 pthread_t the_thread;
150 queueRingBuffer<gOpcode> queue;
152 eFixedMessagePump<int> m_notify_pump;
153 void recv_notify(const int &i);
159 void submit(const gOpcode &o)
161 static int collected=0;
164 // if (o.opcode==gOpcode::end||o.opcode==gOpcode::shutdown)
166 queuelock.unlock(collected);
174 Signal0<void> notify;
176 static gRC *getInstance();
179 /* gPainter is the user frontend, which in turn sends commands through gRC */
187 void begin(const eRect &rect);
190 gPainter(gDC *dc, eRect rect=eRect());
193 void setBackgroundColor(const gColor &color);
194 void setForegroundColor(const gColor &color);
196 void setBackgroundColor(const gRGB &color);
197 void setForegroundColor(const gRGB &color);
199 void setFont(gFont *font);
200 /* flags only THESE: */
203 // todo, make mask. you cannot align both right AND center AND block ;)
204 RT_HALIGN_LEFT = 0, /* default */
206 RT_HALIGN_CENTER = 2,
209 RT_VALIGN_TOP = 0, /* default */
210 RT_VALIGN_CENTER = 8,
211 RT_VALIGN_BOTTOM = 16,
215 void renderText(const eRect &position, const std::string &string, int flags=0);
217 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
219 void fill(const eRect &area);
220 void fill(const gRegion &area);
224 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
226 void setPalette(gRGB *colors, int start=0, int len=256);
227 void setPalette(gPixmap *source);
228 void mergePalette(gPixmap *target);
230 void line(ePoint start, ePoint end);
232 void setOffset(ePoint abs);
233 void moveOffset(ePoint rel);
236 void resetClip(const gRegion &clip);
237 void clip(const gRegion &clip);
247 class gDC: public iObject
251 ePtr<gPixmap> m_pixmap;
253 gColor m_foreground_color, m_background_color;
254 ePtr<gFont> m_current_font;
255 ePoint m_current_offset;
257 std::stack<gRegion> m_clip_stack;
258 gRegion m_current_clip;
261 virtual void exec(gOpcode *opcode);
262 gDC(gPixmap *pixmap);
265 gRegion &getClip() { return m_current_clip; }
266 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
267 gRGB getRGB(gColor col);
268 virtual eSize size() { return m_pixmap->size(); }