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/estring.h>
16 #include <lib/base/erect.h>
17 #include <lib/system/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
.length()?strdup(text
.c_str()):0), 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
) { }
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
) { }
127 static void *thread_wrapper(void *ptr
);
130 static gRC
*instance
;
131 gOpcode queue
[MAXSIZE
];
132 pthread_t the_thread
;
133 pthread_mutex_t mutex
;
137 bool mustDraw() { return rp
!= wp
; }
141 void submit(const gOpcode
&o
)
145 pthread_mutex_lock(&mutex
);
147 if ( tmp
== MAXSIZE
)
151 pthread_mutex_unlock(&mutex
);
152 //printf("render buffer full...\n");
154 usleep(1000); // wait 1 msec
163 if (o
.opcode
==gOpcode::end
||o
.opcode
==gOpcode::shutdown
)
164 pthread_cond_signal(&cond
);
165 pthread_mutex_unlock(&mutex
);
170 static gRC
&getInstance();
178 virtual void exec(gOpcode
*opcode
)=0;
179 virtual gPixmap
&getPixmap()=0;
180 virtual eSize
getSize()=0;
181 virtual const eRect
&getClip()=0;
182 virtual gRGB
getRGB(gColor col
)=0;
184 virtual int islocked() { return 0; }
185 void lock() { dclock
.lock(1); }
186 void unlock() { dclock
.unlock(1); }
197 // std::stack<eRect, std::list<eRect> > cliparea;
198 std::stack
<eRect
> cliparea
;
200 gColor foregroundColor
, backgroundColor
;
202 void begin(const eRect
&rect
);
205 gPainter(gDC
&dc
, eRect rect
=eRect());
208 void setBackgroundColor(const gColor
&color
);
209 void setForegroundColor(const gColor
&color
);
211 void setFont(const gFont
&font
);
212 void renderText(const eRect
&position
, const std::string
&string
, int flags
=0);
213 void renderPara(eTextPara
¶
, ePoint offset
=ePoint(0, 0));
215 void fill(const eRect
&area
);
219 void gPainter::blit(gPixmap
&pixmap
, ePoint pos
, eRect clip
=eRect(), int flags
=0)
225 o
.opcode
=gOpcode::blit
;
227 clip
.moveBy(logicalZero
.x(), logicalZero
.y());
228 o
.parm
.blit
=new gOpcode::para::pblit(pixmap
.lock(), pos
, clip
);
233 void setPalette(gRGB
*colors
, int start
=0, int len
=256);
234 void mergePalette(gPixmap
&target
);
236 void line(ePoint start
, ePoint end
);
238 void setLogicalZero(ePoint abs
);
239 void moveLogicalZero(ePoint rel
);
240 void resetLogicalZero();
242 void clip(eRect clip
);
248 class gPixmapDC
: public gDC
254 void exec(gOpcode
*opcode
);
257 gPixmapDC(gPixmap
*pixmap
);
258 virtual ~gPixmapDC();
259 gPixmap
&getPixmap() { return *pixmap
; }
260 gRGB
getRGB(gColor col
);
261 const eRect
&getClip() { return clip
; }
262 virtual eSize
getSize() { return eSize(pixmap
->x
, pixmap
->y
); }