fix memleak
[enigma2.git] / lib / gdi / gpixmap.cpp
index c2c75e7a21e74a5266b06c8004b9129209bb19e1..96a3e9b0ac4d4af2529333814a7c00b96ebf71a0 100644 (file)
@@ -74,15 +74,8 @@ gSurfaceSystem::gSurfaceSystem(eSize size, int _bpp)
                bypp=(bpp+7)/8;
        }
        stride=x*bypp;
-       if (bpp==8)
-       {
-               clut.colors=256;
-               clut.data=new gRGB[clut.colors];
-       } else
-       {
-               clut.colors=0;
-               clut.data=0;
-       }
+       clut.colors=0;
+       clut.data=0;
        data=malloc(x*y*bypp);
 }
 
@@ -139,21 +132,21 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
 {
        for (unsigned int i=0; i<clip.rects.size(); ++i)
        {
-               eRect area=eRect(pos, src.getSize());
+               eRect area=eRect(pos, src.size());
                area&=clip.rects[i];
-               area&=eRect(ePoint(0, 0), getSize());
+               area&=eRect(ePoint(0, 0), size());
                if ((area.width()<0) || (area.height()<0))
                        continue;
 
                eRect srcarea=area;
                srcarea.moveBy(-pos.x(), -pos.y());
-
+               
                if ((surface->bpp == 8) && (src.surface->bpp==8))
                {
                        __u8 *srcptr=(__u8*)src.surface->data;
                        __u8 *dstptr=(__u8*)surface->data;
        
-                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
                        dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
                        for (int y=0; y<area.height(); y++)
                        {
@@ -193,7 +186,7 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
                                pal[i]^=0xFF000000;
                        }
        
-                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
                        dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
                        for (int y=0; y<area.height(); y++)
                        {
@@ -231,8 +224,10 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
 
 void gPixmap::mergePalette(const gPixmap &target)
 {
+       eDebug("merge palette! %p %p", surface, target.surface);
        if ((!surface->clut.colors) || (!target.surface->clut.colors))
                return;
+#if 0
        gColor *lookup=new gColor[surface->clut.colors];
 
        for (int i=0; i<surface->clut.colors; i++)
@@ -253,6 +248,7 @@ void gPixmap::mergePalette(const gPixmap &target)
        }
        
        delete [] lookup;
+#endif
 }
 
 static inline int sgn(int a)
@@ -385,6 +381,8 @@ gColor gPalette::findColor(const gRGB &rgb) const
                ttd+=td;
                if (ttd>=difference)
                        continue;
+               if (!ttd)
+                       return t;
                difference=ttd;
                best_choice=t;
        }