// for debugging use:
- #define SYNC_PAINT
+// #define SYNC_PAINT
#include <unistd.h>
#ifndef SYNC_PAINT
#include <pthread.h>
void gPainter::blit(gPixmap *pixmap, ePoint pos, const eRect &clip, int flags)
{
gOpcode o;
-
+
o.opcode=gOpcode::blit;
o.dc = m_dc.grabRef();
pixmap->AddRef();
void gPainter::flush()
{
+ gOpcode o;
+ o.opcode = gOpcode::flush;
+ o.dc = m_dc.grabRef();
+ m_rc->submit(o);
}
void gPainter::end()
case gOpcode::renderText:
{
ePtr<eTextPara> para = new eTextPara(o->parm.renderText->area);
+ int flags = o->parm.renderText->flags;
assert(m_current_font);
para->setFont(m_current_font);
- para->renderString(o->parm.renderText->text, o->parm.renderText->flags);
- para->blit(*this, m_current_offset, getRGB(m_background_color), getRGB(m_foreground_color));
+ para->renderString(o->parm.renderText->text, (flags & gPainter::RT_WRAP) ? RS_WRAP : 0);
+
+ if (flags & gPainter::RT_HALIGN_RIGHT)
+ para->realign(eTextPara::dirRight);
+ else if (flags & gPainter::RT_HALIGN_CENTER)
+ para->realign(eTextPara::dirCenter);
+ else if (flags & gPainter::RT_HALIGN_BLOCK)
+ para->realign(eTextPara::dirBlock);
+
+ ePoint offset = m_current_offset;
+
+ if (o->parm.renderText->flags & gPainter::RT_VALIGN_CENTER)
+ {
+ eRect bbox = para->getBoundBox();
+ offset += ePoint(0, (o->parm.renderText->area.height() - bbox.height()) / 2);
+ }
+ para->blit(*this, offset, getRGB(m_background_color), getRGB(m_foreground_color));
delete o->parm.renderText;
break;
}
case gOpcode::blit:
{
gRegion clip;
- if (!o->parm.blit->clip.valid())
+ // this code should be checked again but i'm too tired now
+
+ o->parm.blit->position += m_current_offset;
+
+ if (o->parm.blit->clip.valid())
{
clip.intersect(gRegion(o->parm.blit->clip), clip);
} else
clip = m_current_clip;
+
m_pixmap->blit(*o->parm.blit->pixmap, o->parm.blit->position, clip, o->parm.blit->flags);
o->parm.blit->pixmap->Release();
delete o->parm.blit;
m_current_offset = o->parm.setOffset->value;
delete o->parm.setOffset;
break;
+ case gOpcode::flush:
+ break;
default:
eFatal("illegal opcode %d. expect memory leak!", o->opcode);
}