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/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,
135 /* gRC is the singleton which controls the fifo and dispatches commands */
136 class gRC: public iObject
140 static gRC *instance;
142 static void *thread_wrapper(void *ptr);
143 pthread_t the_thread;
146 queueRingBuffer<gOpcode> queue;
152 void submit(const gOpcode &o)
154 static int collected=0;
157 // if (o.opcode==gOpcode::end||o.opcode==gOpcode::shutdown)
159 queuelock.unlock(collected);
167 static gRC *getInstance();
170 /* gPainter is the user frontend, which in turn sends commands through gRC */
178 void begin(const eRect &rect);
181 gPainter(gDC *dc, eRect rect=eRect());
184 void setBackgroundColor(const gColor &color);
185 void setForegroundColor(const gColor &color);
187 void setBackgroundColor(const gRGB &color);
188 void setForegroundColor(const gRGB &color);
190 void setFont(gFont *font);
191 /* flags only THESE: */
194 // todo, make mask. you cannot align both right AND center AND block ;)
195 RT_HALIGN_LEFT = 0, /* default */
197 RT_HALIGN_CENTER = 2,
200 RT_VALIGN_TOP = 0, /* default */
201 RT_VALIGN_CENTER = 8,
202 RT_VALIGN_BOTTOM = 16,
206 void renderText(const eRect &position, const std::string &string, int flags=0);
208 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
210 void fill(const eRect &area);
211 void fill(const gRegion &area);
215 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
217 void setPalette(gRGB *colors, int start=0, int len=256);
218 void mergePalette(gPixmap *target);
220 void line(ePoint start, ePoint end);
222 void setOffset(ePoint abs);
223 void moveOffset(ePoint rel);
226 void resetClip(const gRegion &clip);
227 void clip(const gRegion &clip);
233 class gDC: public iObject
237 ePtr<gPixmap> m_pixmap;
239 gColor m_foreground_color, m_background_color;
240 ePtr<gFont> m_current_font;
241 ePoint m_current_offset;
243 std::stack<gRegion> m_clip_stack;
244 gRegion m_current_clip;
247 virtual void exec(gOpcode *opcode);
248 gDC(gPixmap *pixmap);
251 gRegion &getClip() { return m_current_clip; }
252 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
253 gRGB getRGB(gColor col);
254 virtual eSize size() { return m_pixmap->size(); }