use rgb values whenever possible
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 11 May 2006 00:13:26 +0000 (00:13 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 11 May 2006 00:13:26 +0000 (00:13 +0000)
lib/gdi/gpixmap.cpp
lib/gdi/gpixmap.h
lib/gdi/grc.cpp
lib/gdi/grc.h

index 3ebd9a0..c3d2cc3 100644 (file)
@@ -175,6 +175,38 @@ void gPixmap::fill(const gRegion &region, const gColor &color)
        }
 }
 
+void gPixmap::fill(const gRegion &region, const gRGB &color)
+{
+       unsigned int i;
+       for (i=0; i<region.rects.size(); ++i)
+       {
+               const eRect &area = region.rects[i];
+               if ((area.height()<=0) || (area.width()<=0))
+                       continue;
+
+               if (surface->bpp == 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(); y<area.bottom(); y++)
+                       {
+                               __u32 *dst=(__u32*)(((__u8*)surface->data)+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; i<clip.rects.size(); ++i)
index 732ebf9..7158e26 100644 (file)
@@ -35,6 +35,12 @@ struct gRGB
        gRGB(): b(0), g(0), r(0), a(0)
        {
        }
+       
+       unsigned long argb() const
+       {
+               return (a<<24)|(r<<16)|(g<<8)|b;
+       }
+       
        void operator=(unsigned long val)
        {
                b = val&0xFF;
@@ -123,11 +129,12 @@ public:
        virtual ~gPixmap();
        
        eSize size() const { return eSize(surface->x, 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);
        
index 19a32b6..a9bac4a 100644 (file)
@@ -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:
index a597497..58371e7 100644 (file)
@@ -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<gPixmap> m_pixmap;
 
        gColor m_foreground_color, m_background_color;
+       gRGB m_foreground_color_rgb, m_background_color_rgb;
        ePtr<gFont> m_current_font;
        ePoint m_current_offset;