X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/3bad22d5566624804a73b3791980bab2d84c8266..8725e4a17b597e6af45f50b766948beaa7e52f28:/lib/gdi/gpixmap.cpp diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp index 1d2a4e39..f0f04d69 100644 --- a/lib/gdi/gpixmap.cpp +++ b/lib/gdi/gpixmap.cpp @@ -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); } @@ -105,7 +98,7 @@ void gPixmap::unlock() void gPixmap::fill(const gRegion ®ion, const gColor &color) { - int i; + unsigned int i; for (i=0; ibpp == 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; ybypp+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; yclut.colors) || (!target.surface->clut.colors)) return; + gColor *lookup=new gColor[surface->clut.colors]; for (int i=0; iclut.colors; i++) @@ -267,11 +261,27 @@ static inline int sgn(int a) void gPixmap::line(const gRegion &clip, ePoint start, ePoint dst, gColor color) { - __u8 *srf = (__u8*)surface->data; + __u8 *srf8 = 0; + __u32 *srf32 = 0; int stride = surface->stride; if (clip.rects.empty()) return; + + __u32 col; + if (surface->bpp == 8) + { + srf8 = (__u8*)surface->data; + } else if (surface->bpp == 32) + { + srf32 = (__u32*)surface->data; + + if (surface->clut.data && color < surface->clut.colors) + col=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b); + else + col=0x10101*color; + col^=0xFF000000; + } int xa = start.x(), ya = start.y(), xb = dst.x(), yb = dst.y(); int dx, dy, x, y, s1, s2, e, temp, swap, i; @@ -290,6 +300,7 @@ void gPixmap::line(const gRegion &clip, ePoint start, ePoint dst, gColor color) } else swap=0; e = 2*dy-dx; + int lasthit = 0; for(i=1; i<=dx; i++) { @@ -326,7 +337,11 @@ void gPixmap::line(const gRegion &clip, ePoint start, ePoint dst, gColor color) } while (!clip.rects[a].contains(x, y)); lasthit = a; } - srf[y * stride + x] = color; + + if (srf8) + srf8[y * stride + x] = color; + if (srf32) + srf32[y * stride/4 + x] = col; fail: while (e>=0) { @@ -364,6 +379,8 @@ gColor gPalette::findColor(const gRGB &rgb) const ttd+=td; if (ttd>=difference) continue; + if (!ttd) + return t; difference=ttd; best_choice=t; }