1 #include <lib/base/init.h>
2 #include <lib/base/init_num.h>
3 #include <lib/gdi/accel.h>
4 #include <lib/base/eerror.h>
5 #include <lib/gdi/esize.h>
6 #include <lib/gdi/epoint.h>
7 #include <lib/gdi/erect.h>
8 #include <lib/gdi/gpixmap.h>
10 gAccel *gAccel::instance;
12 extern int ati_accel_init(void);
13 extern void ati_accel_close(void);
14 extern void ati_accel_blit(
15 int src_addr, int src_width, int src_height, int src_stride,
16 int dst_addr, int dst_width, int dst_height, int dst_stride,
17 int src_x, int src_y, int width, int height,
18 int dst_x, int dst_y);
19 extern void ati_accel_fill(
20 int dst_addr, int dst_width, int dst_height, int dst_stride,
21 int x, int y, int width, int height,
27 m_accel_phys_addr = 0;
29 m_accel_allocation = 0;
45 gAccel *gAccel::getInstance()
50 void gAccel::setAccelMemorySpace(void *addr, int phys_addr, int size)
52 if (m_accel_allocation)
53 delete[] m_accel_allocation;
55 m_accel_size = size >> 12;
57 m_accel_allocation = new int[m_accel_size];
58 memset(m_accel_allocation, 0, sizeof(int)*m_accel_size);
61 m_accel_phys_addr = phys_addr;
64 int gAccel::blit(gSurface *dst, const gSurface *src, const ePoint &p, const eRect &area, int flags)
68 src->data_phys, src->x, src->y, src->stride,
69 dst->data_phys, dst->x, dst->y, dst->stride,
70 area.left(), area.top(), area.width(), area.height(),
77 int gAccel::fill(gSurface *dst, const eRect &area, unsigned long col)
81 dst->data_phys, dst->x, dst->y, dst->stride,
82 area.left(), area.top(), area.width(), area.height(),
89 int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
91 if ((!size) || (!m_accel_allocation))
93 eDebug("size: %d, alloc %p", size, m_accel_allocation);
99 size += 4095; size >>= 12;
102 for (i=0; i < m_accel_size - size; ++i)
105 for (a=0; a<size; ++a)
106 if (m_accel_allocation[i+a])
110 m_accel_allocation[i+a] = size;
111 for (a=1; a<size; ++a)
112 m_accel_allocation[i+a] = -1;
113 addr = ((unsigned char*)m_accel_addr) + (i << 12);
114 phys_addr = m_accel_phys_addr + (i << 12);
121 void gAccel::accelFree(int phys_addr)
123 phys_addr -= m_accel_phys_addr;
126 int size = m_accel_allocation[phys_addr];
131 m_accel_allocation[phys_addr++] = 0;
134 eAutoInitP0<gAccel> init_gAccel(eAutoInitNumbers::graphic-2, "graphics acceleration manager");