Support turbo2.
[vuplus_dvbapp] / lib / gdi / accel.cpp
index f1ffe19..bd1439f 100644 (file)
@@ -9,7 +9,7 @@
 #include <lib/gdi/gpixmap.h>
 
 gAccel *gAccel::instance;
-// #define BCM_ACCEL
+#define BCM_ACCEL
 
 #ifdef ATI_ACCEL
 extern int ati_accel_init(void);
@@ -28,10 +28,11 @@ extern void ati_accel_fill(
 extern int bcm_accel_init(void);
 extern void bcm_accel_close(void);
 extern void bcm_accel_blit(
-               int src_addr, int src_width, int src_height, int src_stride,
+               int src_addr, int src_width, int src_height, int src_stride, int src_format,
                int dst_addr, int dst_width, int dst_height, int dst_stride,
                int src_x, int src_y, int width, int height,
-               int dst_x, int dst_y, int dwidth, int dheight);
+               int dst_x, int dst_y, int dwidth, int dheight,
+               int pal_addr, int flags);
 extern void bcm_accel_fill(
                int dst_addr, int dst_width, int dst_height, int dst_stride,
                int x, int y, int width, int height,
@@ -50,7 +51,7 @@ gAccel::gAccel()
        ati_accel_init();
 #endif
 #ifdef BCM_ACCEL       
-       bcm_accel_init();
+       m_bcm_accel_state = bcm_accel_init();
 #endif
 }
 
@@ -95,12 +96,35 @@ int gAccel::blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect
        return 0;
 #endif
 #ifdef BCM_ACCEL
-       bcm_accel_blit(
-               src->data_phys, src->x, src->y, src->stride,
-               dst->data_phys, dst->x, dst->y, dst->stride, 
-               area.left(), area.top(), area.width(), area.height(),
-               p.x(), p.y(), p.width(), p.height());
-       return 0;
+       if (!m_bcm_accel_state)
+       {
+               if (flags & (gPixmap::blitAlphaTest|gPixmap::blitAlphaBlend)) /* unsupported flags */
+                       return -1;
+               unsigned long pal_addr = 0;
+               int src_format = 0;
+               if (src->bpp == 32)
+                       src_format = 0;
+               else if ((src->bpp == 8) && src->clut.data)
+               {
+                       src_format = 1;
+                       /* sync pal */
+                       int i;
+                       pal_addr = src->stride * src->y;
+                       unsigned long *pal = (unsigned long*)(((unsigned char*)src->data) + pal_addr);
+                       pal_addr += src->data_phys;
+                       for (i = 0; i < src->clut.colors; ++i)
+                               *pal++ = src->clut.data[i].argb() ^ 0xFF000000;
+               } else
+                       return -1; /* unsupported source format */
+
+               bcm_accel_blit(
+                       src->data_phys, src->x, src->y, src->stride, src_format,
+                       dst->data_phys, dst->x, dst->y, dst->stride, 
+                       area.left(), area.top(), area.width(), area.height(),
+                       p.x(), p.y(), p.width(), p.height(),
+                       pal_addr, flags);
+               return 0;
+       }
 #endif
        return -1;
 }
@@ -114,12 +138,14 @@ int gAccel::fill(gSurface *dst, const eRect &area, unsigned long col)
                col);
        return 0;
 #endif
-#if 0 // def BCM_ACCEL
-       bcm_accel_fill(
-               dst->data_phys, dst->x, dst->y, dst->stride, 
-               area.left(), area.top(), area.width(), area.height(),
-               col);
-       return 0;
+#ifdef BCM_ACCEL
+       if (!m_bcm_accel_state) {
+               bcm_accel_fill(
+                       dst->data_phys, dst->x, dst->y, dst->stride,
+                       area.left(), area.top(), area.width(), area.height(),
+                       col);
+               return 0;
+       }
 #endif
        return -1;
 }