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).
14 #include <lib/base/estring.h>
15 #include <lib/base/ringbuffer.h>
16 #include <lib/gdi/erect.h>
17 #include <lib/base/elock.h>
18 #include <lib/gdi/gpixmap.h>
54 pbegin(const eRect &area): area(area) { }
61 pfill(const eRect &area, gColor color): area(area), color(color) { }
69 gRGB foregroundColor, backgroundColor;
70 prenderText(const gFont &font, const eRect &area, const eString &text, const gRGB &foregroundColor, const gRGB &backgroundColor):
71 font(font), area(area), text(text), foregroundColor(foregroundColor), backgroundColor(backgroundColor) { }
78 gRGB foregroundColor, backgroundColor;
79 prenderPara(const ePoint &offset, eTextPara *textpara, const gRGB &foregroundColor, const gRGB &backgroundColor)
80 : offset(offset), textpara(textpara), foregroundColor(foregroundColor), backgroundColor(backgroundColor) { }
86 psetPalette(gPalette *palette): palette(palette) { }
94 pblit(gPixmap *pixmap, const ePoint &position, const eRect &clip)
95 : pixmap(pixmap), position(position), clip(clip) { }
100 ePtr<gPixmap> target;
101 pmergePalette(gPixmap *target): target(target) { }
108 pline(const ePoint &start, const ePoint &end, gColor color): start(start), end(end), color(color) { }
114 pclip(const eRect &clip): clip(clip) { }
125 static gRC *instance;
127 static void *thread_wrapper(void *ptr);
128 pthread_t the_thread;
133 queueRingBuffer<gOpcode> queue;
138 void submit(const gOpcode &o)
140 static int collected=0;
143 if (o.opcode==gOpcode::end)
145 queuelock.unlock(collected);
153 static gRC &getInstance();
164 // std::stack<eRect, std::list<eRect> > cliparea;
165 std::stack<eRect> cliparea;
167 gColor foregroundColor, backgroundColor;
169 void begin(const eRect &rect);
172 gPainter(gDC &dc, eRect rect=eRect());
175 void setBackgroundColor(const gColor &color);
176 void setForegroundColor(const gColor &color);
178 void setFont(const gFont &font);
179 void renderText(const eRect &position, const std::string &string, int flags=0);
180 void renderPara(eTextPara ¶, ePoint offset=ePoint(0, 0));
182 void fill(const eRect &area);
186 void gPainter::blit(gPixmap *pixmap, ePoint pos, eRect clip=eRect(), int flags=0)
190 o.opcode=gOpcode::blit;
192 clip.moveBy(logicalZero.x(), logicalZero.y());
193 o.parm.blit=new gOpcode::para::pblit(pixmap, pos, clip);
198 void setPalette(gRGB *colors, int start=0, int len=256);
199 void mergePalette(gPixmap *target);
201 void line(ePoint start, ePoint end);
203 void setLogicalZero(ePoint abs);
204 void moveLogicalZero(ePoint rel);
205 void resetLogicalZero();
207 void clip(eRect clip);
218 virtual void exec(gOpcode *opcode)=0;
219 virtual RESULT getPixmap(ePtr<gPixmap> &)=0;
220 virtual eSize getSize()=0;
221 virtual const eRect &getClip()=0;
222 virtual gRGB getRGB(gColor col)=0;
224 void lock() { dclock.lock(1); }
225 void unlock() { dclock.unlock(1); }
228 class gPixmapDC: public gDC
231 ePtr<gPixmap> pixmap;
234 void exec(gOpcode *opcode);
237 gPixmapDC(gPixmap *pixmap);
238 virtual ~gPixmapDC();
239 RESULT getPixmap(ePtr<gPixmap> &ptr) { ptr = pixmap; return 0; }
240 gRGB getRGB(gColor col);
241 const eRect &getClip() { return clip; }
242 virtual eSize getSize() { return eSize(pixmap->x, pixmap->y); }