X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fgdi%2Fgrc.h;h=479317924d53f8887b9abb411cac1df165039d73;hb=3bad22d5566624804a73b3791980bab2d84c8266;hp=53cd4a8c5b566710029dc6a74f65702b5cb76ab6;hpb=d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5;p=vuplus_dvbapp diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 53cd4a8..4793179 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -13,10 +13,10 @@ #include #include -#include #include +#include #include - +#include class eTextPara; @@ -25,12 +25,11 @@ struct gOpcode { enum Opcode { - begin, - renderText, renderPara, + setFont, - fill, + fill, clear, blit, setPalette, @@ -38,100 +37,99 @@ struct gOpcode line, - clip, + setBackgroundColor, + setForegroundColor, + + setOffset, - flush, - end, + setClip, addClip, popClip, - shutdown + end,shutdown } opcode; + gDC *dc; union para { - struct pbegin + struct pfillRect { eRect area; - pbegin(const eRect &area): area(area) { } - } *begin; - - struct pfill - { - eRect area; - gColor color; - pfill(const eRect &area, gColor color): area(area), color(color) { } } *fill; struct prenderText { - gFont font; eRect area; eString text; - gRGB foregroundColor, backgroundColor; - prenderText(const gFont &font, const eRect &area, const eString &text, const gRGB &foregroundColor, const gRGB &backgroundColor): - font(font), area(area), text(text), foregroundColor(foregroundColor), backgroundColor(backgroundColor) { } + int flags; } *renderText; struct prenderPara { ePoint offset; eTextPara *textpara; - gRGB foregroundColor, backgroundColor; - prenderPara(const ePoint &offset, eTextPara *textpara, const gRGB &foregroundColor, const gRGB &backgroundColor) - : offset(offset), textpara(textpara), foregroundColor(foregroundColor), backgroundColor(backgroundColor) { } } *renderPara; + + struct psetFont + { + gFont *font; + } *setFont; struct psetPalette { gPalette *palette; - psetPalette(gPalette *palette): palette(palette) { } } *setPalette; struct pblit { - ePtr pixmap; + gPixmap *pixmap; ePoint position; + int flags; eRect clip; - pblit(gPixmap *pixmap, const ePoint &position, const eRect &clip) - : pixmap(pixmap), position(position), clip(clip) { } } *blit; struct pmergePalette { - ePtr target; - pmergePalette(gPixmap *target): target(target) { } + gPixmap *target; } *mergePalette; struct pline { ePoint start, end; - gColor color; - pline(const ePoint &start, const ePoint &end, gColor color): start(start), end(end), color(color) { } } *line; - struct pclip + struct psetClip { - eRect clip; - pclip(const eRect &clip): clip(clip) { } + gRegion region; } *clip; + + struct psetColor + { + gColor color; + } *setColor; + + struct psetOffset + { + ePoint value; + int rel; + } *setOffset; } parm; int flags; - - gDC *dc; }; -class gRC + /* gRC is the singleton which controls the fifo and dispatches commands */ +class gRC: public virtual iObject { +DECLARE_REF; +private: static gRC *instance; static void *thread_wrapper(void *ptr); pthread_t the_thread; void *thread(); - - eLock queuelock; - + queueRingBuffer queue; public: + eLock queuelock; gRC(); virtual ~gRC(); @@ -140,7 +138,7 @@ public: static int collected=0; queue.enqueue(o); collected++; - if (o.opcode==gOpcode::end) +// if (o.opcode==gOpcode::end||o.opcode==gOpcode::shutdown) { queuelock.unlock(collected); #ifdef SYNC_PAINT @@ -150,96 +148,74 @@ public: } } - static gRC &getInstance(); + static gRC *getInstance(); }; + /* gPainter is the user frontend, which in turn sends commands through gRC */ class gPainter { - gDC &dc; - gRC &rc; + ePtr m_dc; + ePtr m_rc; friend class gRC; gOpcode *beginptr; - /* paint states */ -// std::stack > cliparea; - std::stack cliparea; - gFont font; - gColor foregroundColor, backgroundColor; - ePoint logicalZero; void begin(const eRect &rect); void end(); public: - gPainter(gDC &dc, eRect rect=eRect()); + gPainter(gDC *dc, eRect rect=eRect()); virtual ~gPainter(); void setBackgroundColor(const gColor &color); void setForegroundColor(const gColor &color); - void setFont(const gFont &font); + void setFont(gFont *font); void renderText(const eRect &position, const std::string &string, int flags=0); - void renderPara(eTextPara ¶, ePoint offset=ePoint(0, 0)); + void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0)); void fill(const eRect &area); void clear(); - void gPainter::blit(gPixmap *pixmap, ePoint pos, eRect clip=eRect(), int flags=0) - { - gOpcode o; - o.dc=&dc; - o.opcode=gOpcode::blit; - pos+=logicalZero; - clip.moveBy(logicalZero.x(), logicalZero.y()); - o.parm.blit=new gOpcode::para::pblit(pixmap, pos, clip); - o.flags=flags; - rc.submit(o); - } + void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0); void setPalette(gRGB *colors, int start=0, int len=256); void mergePalette(gPixmap *target); void line(ePoint start, ePoint end); - void setLogicalZero(ePoint abs); - void moveLogicalZero(ePoint rel); - void resetLogicalZero(); + void setOffset(ePoint abs); + void moveOffset(ePoint rel); + void resetOffset(); - void clip(eRect clip); + void resetClip(const gRegion &clip); + void clip(const gRegion &clip); void clippop(); void flush(); }; -class gDC +class gDC: public iObject { +DECLARE_REF; protected: - eLock dclock; -public: - virtual void exec(gOpcode *opcode)=0; - virtual RESULT getPixmap(ePtr &)=0; - virtual eSize getSize()=0; - virtual const eRect &getClip()=0; - virtual gRGB getRGB(gColor col)=0; - virtual ~gDC(); - void lock() { dclock.lock(1); } - void unlock() { dclock.unlock(1); } -}; + ePtr m_pixmap; -class gPixmapDC: public gDC -{ -protected: - ePtr pixmap; - eRect clip; - - void exec(gOpcode *opcode); - gPixmapDC(); + gColor m_foreground_color, m_background_color; + ePtr m_current_font; + ePoint m_current_offset; + + std::stack m_clip_stack; + gRegion m_current_clip; + public: - gPixmapDC(gPixmap *pixmap); - virtual ~gPixmapDC(); - RESULT getPixmap(ePtr &ptr) { ptr = pixmap; return 0; } + virtual void exec(gOpcode *opcode); + gDC(gPixmap *pixmap); + gDC(); + virtual ~gDC(); + gRegion &getClip() { return m_current_clip; } + int getPixmap(ePtr &pm) { pm = m_pixmap; return 0; } gRGB getRGB(gColor col); - const eRect &getClip() { return clip; } - virtual eSize getSize() { return eSize(pixmap->x, pixmap->y); } + virtual eSize getSize() { return m_pixmap->getSize(); } }; #endif