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).
19 #include <lib/base/elock.h>
20 #include <lib/base/message.h>
21 #include <lib/gdi/erect.h>
22 #include <lib/gdi/gpixmap.h>
23 #include <lib/gdi/region.h>
24 #include <lib/gdi/gfont.h>
37 fill, fillRegion, clear,
48 setBackgroundColorRGB,
49 setForegroundColorRGB,
53 setClip, addClip, popClip,
143 /* gRC is the singleton which controls the fifo and dispatches commands */
144 class gRC: public iObject, public Object
148 friend class gPainter;
149 static gRC *instance;
152 static void *thread_wrapper(void *ptr);
153 pthread_t the_thread;
154 pthread_mutex_t mutex;
159 gOpcode queue[MAXSIZE];
162 eFixedMessagePump<int> m_notify_pump;
163 void recv_notify(const int &i);
168 void submit(const gOpcode &o);
170 Signal0<void> notify;
172 static gRC *getInstance();
175 /* gPainter is the user frontend, which in turn sends commands through gRC */
183 void begin(const eRect &rect);
186 gPainter(gDC *dc, eRect rect=eRect());
189 void setBackgroundColor(const gColor &color);
190 void setForegroundColor(const gColor &color);
192 void setBackgroundColor(const gRGB &color);
193 void setForegroundColor(const gRGB &color);
195 void setFont(gFont *font);
196 /* flags only THESE: */
199 // todo, make mask. you cannot align both right AND center AND block ;)
200 RT_HALIGN_LEFT = 0, /* default */
202 RT_HALIGN_CENTER = 2,
205 RT_VALIGN_TOP = 0, /* default */
206 RT_VALIGN_CENTER = 8,
207 RT_VALIGN_BOTTOM = 16,
211 void renderText(const eRect &position, const std::string &string, int flags=0);
213 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
215 void fill(const eRect &area);
216 void fill(const gRegion &area);
225 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
227 void setPalette(gRGB *colors, int start=0, int len=256);
228 void setPalette(gPixmap *source);
229 void mergePalette(gPixmap *target);
231 void line(ePoint start, ePoint end);
233 void setOffset(ePoint abs);
234 void moveOffset(ePoint rel);
237 void resetClip(const gRegion &clip);
238 void clip(const gRegion &clip);
248 class gDC: public iObject
252 ePtr<gPixmap> m_pixmap;
254 gColor m_foreground_color, m_background_color;
255 gRGB m_foreground_color_rgb, m_background_color_rgb;
256 ePtr<gFont> m_current_font;
257 ePoint m_current_offset;
259 std::stack<gRegion> m_clip_stack;
260 gRegion m_current_clip;
263 virtual void exec(gOpcode *opcode);
264 gDC(gPixmap *pixmap);
267 gRegion &getClip() { return m_current_clip; }
268 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
269 gRGB getRGB(gColor col);
270 virtual eSize size() { return m_pixmap->size(); }
271 virtual int islocked() { return 0; }