+#include <cstdlib>
+#include <cstring>
#include <lib/gdi/gpixmap.h>
#include <lib/gdi/region.h>
#include <lib/gdi/accel.h>
stride += 63;
stride &=~63;
+ int pal_size = 0;
+ if (bpp == 8)
+ pal_size = 256 * 4;
+
if (gAccel::getInstance())
- eDebug("accel memory: %d", gAccel::getInstance()->accelAlloc(data, data_phys, y * stride));
+ eDebug("accel memory: %d", gAccel::getInstance()->accelAlloc(data, data_phys, y * stride + pal_size));
else
eDebug("no accel available");
}
for (i=0; i<region.rects.size(); ++i)
{
const eRect &area = region.rects[i];
- if ((area.height()<=0) || (area.width()<=0))
+ if (area.empty())
continue;
if (surface->bpp == 8)
else
col=0x10101*color;
- col^=0xFF000000;
-
+ col^=0xFF000000;
+
if (surface->data_phys && gAccel::getInstance())
if (!gAccel::getInstance()->fill(surface, area, col))
continue;
for (i=0; i<region.rects.size(); ++i)
{
const eRect &area = region.rects[i];
- if ((area.height()<=0) || (area.width()<=0))
+ if (area.empty())
continue;
if (surface->bpp == 32)
}
}
+#define FIX 0x10000
-void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag)
+void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, int flag)
{
+// eDebug("blit: -> %d.%d %d:%d -> %d.%d %d:%d, flags=%d",
+// _pos.x(), _pos.y(), _pos.width(), _pos.height(),
+// clip.extends.x(), clip.extends.y(), clip.extends.width(), clip.extends.height(),
+// flag);
+ eRect pos = _pos;
+
+// eDebug("source size: %d %d", src.size().width(), src.size().height());
+
+ if (!(flag & blitScale)) /* pos' size is valid only when scaling */
+ pos = eRect(pos.topLeft(), src.size());
+ else if (pos.size() == src.size()) /* no scaling required */
+ flag &= ~blitScale;
+
+ int scale_x = FIX, scale_y = FIX;
+
+ if (flag & blitScale)
+ {
+ ASSERT(src.size().width());
+ ASSERT(src.size().height());
+ scale_x = pos.size().width() * FIX / src.size().width();
+ scale_y = pos.size().height() * FIX / src.size().height();
+ }
+
+// eDebug("SCALE %x %x", scale_x, scale_y);
+
for (unsigned int i=0; i<clip.rects.size(); ++i)
{
- eRect area=eRect(pos, src.size());
+// eDebug("clip rect: %d %d %d %d", clip.rects[i].x(), clip.rects[i].y(), clip.rects[i].width(), clip.rects[i].height());
+ eRect area = pos; /* pos is the virtual (pre-clipping) area on the dest, which can be larger/smaller than src if scaling is enabled */
area&=clip.rects[i];
area&=eRect(ePoint(0, 0), size());
- if ((area.width()<0) || (area.height()<0))
+ if (area.empty())
continue;
- eRect srcarea=area;
+ eRect srcarea = area;
srcarea.moveBy(-pos.x(), -pos.y());
+// eDebug("srcarea before scale: %d %d %d %d",
+// srcarea.x(), srcarea.y(), srcarea.width(), srcarea.height());
+
+ if (flag & blitScale)
+ srcarea = eRect(srcarea.x() * FIX / scale_x, srcarea.y() * FIX / scale_y, srcarea.width() * FIX / scale_x, srcarea.height() * FIX / scale_y);
+
+// eDebug("srcarea after scale: %d %d %d %d",
+// srcarea.x(), srcarea.y(), srcarea.width(), srcarea.height());
+
if ((surface->data_phys && src.surface->data_phys) && (gAccel::getInstance()))
- if (!gAccel::getInstance()->blit(surface, src.surface, area.topLeft(), srcarea, flag))
+ if (!gAccel::getInstance()->blit(surface, src.surface, area, srcarea, flag))
continue;
+ if (flag & blitScale)
+ {
+ eWarning("unimplemented: scale on non-accel surfaces");
+ continue;
+ }
+
if ((surface->bpp == 8) && (src.surface->bpp==8))
{
__u8 *srcptr=(__u8*)src.surface->data;
dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
for (int y=0; y<area.height(); y++)
{
- if (flag & blitAlphaTest)
+ if (flag & (blitAlphaTest|blitAlphaBlend))
{
// no real alphatest yet
int width=area.width();
dstptr+=area.left()+area.top()*surface->stride/4;
for (int y=0; y<area.height(); y++)
{
- if (flag & (blitAlphaTest|blitAlphaBlend))
+ if (flag & blitAlphaTest)
{
int width=area.width();
unsigned long *src=(unsigned long*)srcptr;
}
}
+#undef FIX
+
void gPixmap::mergePalette(const gPixmap &target)
{
if ((!surface->clut.colors) || (!target.surface->clut.colors))