From b887d75af86b430552cc28ea5e37bf58bd557d4b Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Thu, 11 May 2006 00:13:26 +0000 Subject: [PATCH] use rgb values whenever possible --- lib/gdi/gpixmap.cpp | 32 ++++++++++++++++++++++++++++++++ lib/gdi/gpixmap.h | 9 ++++++++- lib/gdi/grc.cpp | 30 +++++++++++++++++++++++------- lib/gdi/grc.h | 4 +++- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp index 3ebd9a02..c3d2cc31 100644 --- a/lib/gdi/gpixmap.cpp +++ b/lib/gdi/gpixmap.cpp @@ -175,6 +175,38 @@ void gPixmap::fill(const gRegion ®ion, const gColor &color) } } +void gPixmap::fill(const gRegion ®ion, const gRGB &color) +{ + unsigned int i; + for (i=0; ibpp == 32) + { + __u32 col; + + col = color.argb(); + col^=0xFF000000; + + if (surface->data_phys && gAccel::getInstance()) + if (!gAccel::getInstance()->fill(surface, area, col)) + continue; + + for (int y=area.top(); ydata)+y*surface->stride+area.left()*surface->bypp); + int x=area.width(); + while (x--) + *dst++=col; + } + } else + eWarning("couldn't rgbfill %d bpp", surface->bpp); + } +} + void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag) { for (unsigned int i=0; ix, surface->y); } - + inline bool needClut() const { return surface && surface->bpp <= 8; } private: #ifndef SWIG friend class gDC; void fill(const gRegion &clip, const gColor &color); + void fill(const gRegion &clip, const gRGB &color); void blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flags=0); diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 19a32b62..a9bac4af 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -506,18 +506,24 @@ void gDC::exec(gOpcode *o) { case gOpcode::setBackgroundColor: m_background_color = o->parm.setColor->color; + m_background_color_rgb = getRGB(m_background_color); delete o->parm.setColor; break; case gOpcode::setForegroundColor: m_foreground_color = o->parm.setColor->color; + m_background_color_rgb = getRGB(m_foreground_color); delete o->parm.setColor; break; case gOpcode::setBackgroundColorRGB: - m_background_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color); + if (m_pixmap->needClut()) + m_background_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color); + m_background_color_rgb = o->parm.setColorRGB->color; delete o->parm.setColorRGB; break; case gOpcode::setForegroundColorRGB: - m_foreground_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color); + if (m_pixmap->needClut()) + m_foreground_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color); + m_foreground_color_rgb = o->parm.setColorRGB->color; delete o->parm.setColorRGB; break; case gOpcode::setFont: @@ -549,13 +555,14 @@ void gDC::exec(gOpcode *o) int correction = vcentered_top - bbox.top(); offset += ePoint(0, correction); } - para->blit(*this, offset, getRGB(m_background_color), getRGB(m_foreground_color)); + + para->blit(*this, offset, m_background_color_rgb, m_foreground_color_rgb); delete o->parm.renderText; break; } case gOpcode::renderPara: { - o->parm.renderPara->textpara->blit(*this, o->parm.renderPara->offset + m_current_offset, getRGB(m_background_color), getRGB(m_foreground_color)); + o->parm.renderPara->textpara->blit(*this, o->parm.renderPara->offset + m_current_offset, m_background_color_rgb, m_foreground_color_rgb); o->parm.renderPara->textpara->Release(); delete o->parm.renderPara; break; @@ -565,7 +572,10 @@ void gDC::exec(gOpcode *o) eRect area = o->parm.fill->area; area.moveBy(m_current_offset); gRegion clip = m_current_clip & area; - m_pixmap->fill(clip, m_foreground_color); + if (m_pixmap->needClut()) + m_pixmap->fill(clip, m_foreground_color); + else + m_pixmap->fill(clip, m_foreground_color_rgb); delete o->parm.fill; break; } @@ -573,12 +583,18 @@ void gDC::exec(gOpcode *o) { o->parm.fillRegion->region.moveBy(m_current_offset); gRegion clip = m_current_clip & o->parm.fillRegion->region; - m_pixmap->fill(clip, m_foreground_color); + if (m_pixmap->needClut()) + m_pixmap->fill(clip, m_foreground_color); + else + m_pixmap->fill(clip, m_foreground_color_rgb); delete o->parm.fillRegion; break; } case gOpcode::clear: - m_pixmap->fill(m_current_clip, m_background_color); + if (m_pixmap->needClut()) + m_pixmap->fill(m_current_clip, m_background_color); + else + m_pixmap->fill(m_current_clip, m_background_color_rgb); delete o->parm.fill; break; case gOpcode::blit: diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index a5974972..58371e79 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -1,6 +1,7 @@ #ifndef __grc_h #define __grc_h +// #define SYNC_PAINT /* gPainter ist die high-level version. die highlevel daten werden zu low level opcodes ueber die gRC-queue geschickt und landen beim gDC der hardwarespezifisch ist, meist aber auf einen @@ -185,7 +186,7 @@ class gPainter public: gPainter(gDC *dc, eRect rect=eRect()); virtual ~gPainter(); - + void setBackgroundColor(const gColor &color); void setForegroundColor(const gColor &color); @@ -252,6 +253,7 @@ protected: ePtr m_pixmap; gColor m_foreground_color, m_background_color; + gRGB m_foreground_color_rgb, m_background_color_rgb; ePtr m_current_font; ePoint m_current_offset; -- 2.30.2