2 #include <lib/base/init.h>
3 #include <lib/base/init_num.h>
4 #include <lib/gdi/accel.h>
5 #include <lib/base/eerror.h>
6 #include <lib/gdi/esize.h>
7 #include <lib/gdi/epoint.h>
8 #include <lib/gdi/erect.h>
9 #include <lib/gdi/gpixmap.h>
11 gAccel *gAccel::instance;
13 extern int ati_accel_init(void);
14 extern void ati_accel_close(void);
15 extern void ati_accel_blit(
16 int src_addr, int src_width, int src_height, int src_stride,
17 int dst_addr, int dst_width, int dst_height, int dst_stride,
18 int src_x, int src_y, int width, int height,
19 int dst_x, int dst_y);
20 extern void ati_accel_fill(
21 int dst_addr, int dst_width, int dst_height, int dst_stride,
22 int x, int y, int width, int height,
28 m_accel_phys_addr = 0;
30 m_accel_allocation = 0;
46 gAccel *gAccel::getInstance()
51 void gAccel::setAccelMemorySpace(void *addr, int phys_addr, int size)
53 if (m_accel_allocation)
54 delete[] m_accel_allocation;
56 m_accel_size = size >> 12;
58 m_accel_allocation = new int[m_accel_size];
59 memset(m_accel_allocation, 0, sizeof(int)*m_accel_size);
62 m_accel_phys_addr = phys_addr;
65 int gAccel::blit(gSurface *dst, const gSurface *src, const ePoint &p, const eRect &area, int flags)
69 src->data_phys, src->x, src->y, src->stride,
70 dst->data_phys, dst->x, dst->y, dst->stride,
71 area.left(), area.top(), area.width(), area.height(),
78 int gAccel::fill(gSurface *dst, const eRect &area, unsigned long col)
82 dst->data_phys, dst->x, dst->y, dst->stride,
83 area.left(), area.top(), area.width(), area.height(),
90 int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
92 if ((!size) || (!m_accel_allocation))
94 eDebug("size: %d, alloc %p", size, m_accel_allocation);
100 size += 4095; size >>= 12;
103 for (i=0; i < m_accel_size - size; ++i)
106 for (a=0; a<size; ++a)
107 if (m_accel_allocation[i+a])
111 m_accel_allocation[i+a] = size;
112 for (a=1; a<size; ++a)
113 m_accel_allocation[i+a] = -1;
114 addr = ((unsigned char*)m_accel_addr) + (i << 12);
115 phys_addr = m_accel_phys_addr + (i << 12);
122 void gAccel::accelFree(int phys_addr)
124 phys_addr -= m_accel_phys_addr;
127 int size = m_accel_allocation[phys_addr];
132 m_accel_allocation[phys_addr++] = 0;
135 eAutoInitP0<gAccel> init_gAccel(eAutoInitNumbers::graphic-2, "graphics acceleration manager");