X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/aa4de06095cc1f7aba8f7da402d3717d696d5407..27a9db5f79a6b3fdda1fbfaa577b8260ac68b8da:/lib/gdi/gpixmap.cpp diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp index 1ecb83d3..e2960ad7 100644 --- a/lib/gdi/gpixmap.cpp +++ b/lib/gdi/gpixmap.cpp @@ -106,7 +106,7 @@ gSurface::gSurface(eSize size, int _bpp, int accel) clut.data = 0; if (!data) - data = malloc(y * stride); + data = new unsigned char [y * stride]; type = 1; } @@ -118,9 +118,9 @@ gSurface::~gSurface() if (data_phys) gAccel::getInstance()->accelFree(data_phys); else - free(data); + delete [] (unsigned char*)data; - delete[] clut.data; + delete [] clut.data; } } @@ -207,6 +207,54 @@ void gPixmap::fill(const gRegion ®ion, const gRGB &color) } } +static void blit_8i_to_32(__u32 *dst, __u8 *src, __u32 *pal, int width) +{ + while (width--) + *dst++=pal[*src++]; +} + +static void blit_8i_to_32_at(__u32 *dst, __u8 *src, __u32 *pal, int width) +{ + while (width--) + { + if (!(pal[*src]&0x80000000)) + { + src++; + dst++; + } else + *dst++=pal[*src++]; + } +} + + /* WARNING, this function is not endian safe! */ +static void blit_8i_to_32_ab(__u32 *dst, __u8 *src, __u32 *pal, int width) +{ + while (width--) + { +#define BLEND(x, y, a) (y + (((x-y) * a)>>8)) + __u32 srccol = pal[*src++]; + __u32 dstcol = *dst; + unsigned char sb = srccol & 0xFF; + unsigned char sg = (srccol >> 8) & 0xFF; + unsigned char sr = (srccol >> 16) & 0xFF; + unsigned char sa = (srccol >> 24) & 0xFF; + + unsigned char db = dstcol & 0xFF; + unsigned char dg = (dstcol >> 8) & 0xFF; + unsigned char dr = (dstcol >> 16) & 0xFF; + unsigned char da = (dstcol >> 24) & 0xFF; + + da = BLEND(0xFF, da, sa) & 0xFF; + dr = BLEND(sr, dr, sa) & 0xFF; + dg = BLEND(sg, dg, sa) & 0xFF; + db = BLEND(sb, db, sa) & 0xFF; + +#undef BLEND + *dst++ = db | (dg << 8) | (dr << 16) | (da << 24); + } +} + + void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag) { for (unsigned int i=0; idata_phys && src.surface->data_phys) && (gAccel::getInstance())) if (!gAccel::getInstance()->blit(surface, src.surface, area.topLeft(), srcarea, flag)) continue; - flag &= ~ blitAlphaBlend; - + if ((surface->bpp == 8) && (src.surface->bpp==8)) { __u8 *srcptr=(__u8*)src.surface->data; __u8 *dstptr=(__u8*)surface->data; - + srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride; dstptr+=area.left()*surface->bypp+area.top()*surface->stride; for (int y=0; ydata; __u32 *dstptr=(__u32*)surface->data; - + srcptr+=srcarea.left()+srcarea.top()*src.surface->stride/4; dstptr+=area.left()+area.top()*surface->stride/4; for (int y=0; ybypp+srcarea.top()*src.surface->stride; dstptr+=area.left()*surface->bypp+area.top()*surface->stride; for (int y=0; ystride; dstptr+=surface->stride; } } else - eFatal("cannot blit %dbpp from %dbpp", surface->bpp, src.surface->bpp); + eWarning("cannot blit %dbpp from %dbpp", surface->bpp, src.surface->bpp); } }