blit from system memory in PIO mode

git-svn-id: svn://kolibrios.org@1002 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2009-01-27 00:31:09 +00:00
parent 76bc83bd66
commit 80c71dc52a
18 changed files with 986 additions and 706 deletions

View File

@@ -10,20 +10,20 @@ static int _L1OutCode( clip_t *clip, int x, int y )
Verify that a point is inside or outside the active viewport. */
{
int flag;
int flag;
flag = 0;
if( x < clip->xmin ) {
flag = 0;
if( x < clip->xmin ) {
flag |= CLIP_LEFT;
} else if( x > clip->xmax ) {
} else if( x > clip->xmax ) {
flag |= CLIP_RIGHT;
}
if( y < clip->ymin ) {
}
if( y < clip->ymin ) {
flag |= CLIP_TOP;
} else if( y > clip->ymax ) {
} else if( y > clip->ymax ) {
flag |= CLIP_BOTTOM;
}
return( flag );
}
return( flag );
}
@@ -35,18 +35,18 @@ static void line_inter( int * x1, int* y1, int x2, int y2, int x )
NOTE : the signs of denom and ( x - *x1 ) cancel out during division
so make both of them positive before rounding. */
{
int numer;
int denom;
int numer;
int denom;
denom = abs( x2 - *x1 );
numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 );
if( numer > 0 ) {
denom = abs( x2 - *x1 );
numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 );
if( numer > 0 ) {
numer += denom; /* round to closest pixel */
} else {
} else {
numer -= denom;
}
*y1 += numer / ( denom << 1 );
*x1 = x;
}
*y1 += numer / ( denom << 1 );
*x1 = x;
}
@@ -57,39 +57,39 @@ int LineClip( clip_t *clip, int *x1, int *y1, int *x2, int *y2 )
viewport using the Cohen-Sutherland clipping algorithm. Return the
clipped coordinates and a decision drawing flag. */
{
int flag1;
int flag2;
int flag1;
int flag2;
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
if( flag1 & flag2 ) break; /* trivially outside */
if( flag1 == flag2 ) break; /* completely inside */
if( flag1 == 0 ) { /* first point inside */
if( flag2 & CLIP_TOP ) {
line_inter( y2, x2, *y1, *x1, clip->ymin );
} else if( flag2 & CLIP_BOTTOM ) {
line_inter( y2, x2, *y1, *x1, clip->ymax );
} else if( flag2 & CLIP_RIGHT ) {
line_inter( x2, y2, *x1, *y1, clip->xmax );
} else if( flag2 & CLIP_LEFT ) {
line_inter( x2, y2, *x1, *y1, clip->xmin );
}
flag2 = _L1OutCode( clip, *x2, *y2 );
if( flag2 & CLIP_TOP ) {
line_inter( y2, x2, *y1, *x1, clip->ymin );
} else if( flag2 & CLIP_BOTTOM ) {
line_inter( y2, x2, *y1, *x1, clip->ymax );
} else if( flag2 & CLIP_RIGHT ) {
line_inter( x2, y2, *x1, *y1, clip->xmax );
} else if( flag2 & CLIP_LEFT ) {
line_inter( x2, y2, *x1, *y1, clip->xmin );
}
flag2 = _L1OutCode( clip, *x2, *y2 );
} else { /* second point inside */
if( flag1 & CLIP_TOP ) {
line_inter( y1, x1, *y2, *x2, clip->ymin );
} else if( flag1 & CLIP_BOTTOM ) {
line_inter( y1, x1, *y2, *x2, clip->ymax );
} else if( flag1 & CLIP_RIGHT ) {
line_inter( x1, y1, *x2, *y2, clip->xmax );
} else if( flag1 & CLIP_LEFT ) {
line_inter( x1, y1, *x2, *y2, clip->xmin );
}
flag1 = _L1OutCode( clip, *x1, *y1 );
if( flag1 & CLIP_TOP ) {
line_inter( y1, x1, *y2, *x2, clip->ymin );
} else if( flag1 & CLIP_BOTTOM ) {
line_inter( y1, x1, *y2, *x2, clip->ymax );
} else if( flag1 & CLIP_RIGHT ) {
line_inter( x1, y1, *x2, *y2, clip->xmax );
} else if( flag1 & CLIP_LEFT ) {
line_inter( x1, y1, *x2, *y2, clip->xmin );
}
flag1 = _L1OutCode( clip, *x1, *y1 );
}
}
return( flag1 & flag2 );
}
return( flag1 & flag2 );
}
@@ -98,15 +98,15 @@ static void block_inter( clip_t *clip, int *x, int *y, int flag )
Find the intersection of a block with a boundary of the viewport. */
{
if( flag & CLIP_TOP ) {
if( flag & CLIP_TOP ) {
*y = clip->ymin;
} else if( flag & CLIP_BOTTOM ) {
} else if( flag & CLIP_BOTTOM ) {
*y = clip->ymax;
} else if( flag & CLIP_RIGHT ) {
} else if( flag & CLIP_RIGHT ) {
*x = clip->xmax;
} else if( flag & CLIP_LEFT ) {
} else if( flag & CLIP_LEFT ) {
*x = clip->xmin;
}
}
}
@@ -118,23 +118,23 @@ int BlockClip(clip_t *clip, int *x1, int *y1, int *x2, int* y2 )
clipping. Return the clipped coordinates and a decision drawing
flag ( 0 draw : 1 don't draw ). */
{
int flag1;
int flag2;
int flag1;
int flag2;
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
if( flag1 & flag2 ) break; /* trivially outside */
if( flag1 == flag2 ) break; /* completely inside */
if( flag1 == 0 ) {
block_inter( clip, x2, y2, flag2 );
flag2 = _L1OutCode( clip, *x2, *y2 );
block_inter( clip, x2, y2, flag2 );
flag2 = _L1OutCode( clip, *x2, *y2 );
} else {
block_inter( clip, x1, y1, flag1 );
flag1 = _L1OutCode( clip, *x1, *y1 );
block_inter( clip, x1, y1, flag1 );
flag1 = _L1OutCode( clip, *x1, *y1 );
}
}
return( flag1 & flag2 );
}
return( flag1 & flag2 );
}
@@ -142,39 +142,39 @@ int blit_clip(clip_t *dst_clip,int *dst_x,int *dst_y,
clip_t *src_clip,int *src_x, int *src_y,
int *w, int *h)
{
int sx0, sy0, sx1, sy1;
int sx0, sy0, sx1, sy1;
sx0 = *src_x;
sy0 = *src_y;
sx0 = *src_x;
sy0 = *src_y;
sx1 = sx0 + *w - 1;
sy1 = sy0 + *h - 1;
sx1 = sx0 + *w - 1;
sy1 = sy0 + *h - 1;
if( ! BlockClip( src_clip, &sx0, &sy0, &sx1, &sy1))
{
int dx0, dy0, dx1, dy1;
if( ! BlockClip( src_clip, &sx0, &sy0, &sx1, &sy1))
{
int dx0, dy0, dx1, dy1;
dx0 = *dst_x + sx0 - *src_x;
dy0 = *dst_y + sy0 - *src_y;
dx0 = *dst_x + sx0 - *src_x;
dy0 = *dst_y + sy0 - *src_y;
dx1 = dx0 + sx1 - sx0;
dy1 = dy0 + sy1 - sy0;
dx1 = dx0 + sx1 - sx0;
dy1 = dy0 + sy1 - sy0;
if( ! BlockClip( dst_clip, &dx0, &dy0, &dx1, &dy1))
{
*w = dx1 - dx0 + 1;
*h = dy1 - dy0 + 1;
if( ! BlockClip( dst_clip, &dx0, &dy0, &dx1, &dy1))
{
*w = dx1 - dx0 + 1;
*h = dy1 - dy0 + 1;
*src_x += dx0 - *dst_x;
*src_y += dy0 - *dst_y;
*src_x += dx0 - *dst_x;
*src_y += dy0 - *dst_y;
*dst_x = dx0;
*dst_y = dx0;
*dst_x = dx0;
*dst_y = dy0;
return 0;
};
};
return 1;
return 0;
};
}
return 1;
};

View File

@@ -558,29 +558,29 @@ int Blit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
int width, int height)
{
clip_t src_clip, dst_clip;
clip_t src_clip, dst_clip;
if( ( width <= 0 ) || ( height<=0 ) )
if( ( width <= 0 ) || ( height<=0 ) )
return ERR_PARAM;
/* if "hardware acceleration present" and
"destinastion is primary screen or local videomemory" and
"source is primary screen or local videomemory"
/* if "hardware acceleration present" and
"destinastion is primary screen or local videomemory"
*/
if( (srv_hw2d != 0) &&
( (dst_pixmap == (void*)-1) ||
( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) &&
if( (srv_hw2d != 0) &&
( (dst_pixmap == (void*)-1) ||
( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) /* &&
( (src_pixmap == (void*)-1) ||
( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) )
{
( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) */ )
{
ioctl_t io;
pxblit_t *blit = (pxblit_t*)&dst_pixmap;
if((int)dst_pixmap != -1)
blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle;
blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle;
if((int)src_pixmap != -1)
blit->src_pixmap = (pixmap_t*)src_pixmap->handle;
if( (int)src_pixmap != -1 &&
(src_pixmap->flags & PX_MEM_MASK) != PX_MEM_SYSTEM)
blit->src_pixmap = (pixmap_t*)src_pixmap->handle;
io.handle = srv_hw2d;
io.io_code = PX_BLIT;
@@ -590,83 +590,83 @@ int Blit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
io.out_size = 0;
return call_service(&io);
}
}
dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ;
src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ;
dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ;
src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ;
src_clip.xmin = 0;
src_clip.ymin = 0;
src_clip.xmax = src_pixmap->width-1;
src_clip.ymax = src_pixmap->height-1;
src_clip.xmin = 0;
src_clip.ymin = 0;
src_clip.xmax = src_pixmap->width-1;
src_clip.ymax = src_pixmap->height-1;
dst_clip.xmin = 0;
dst_clip.ymin = 0;
dst_clip.xmax = dst_pixmap->width-1;
dst_clip.ymax = dst_pixmap->height-1;
dst_clip.xmin = 0;
dst_clip.ymin = 0;
dst_clip.xmax = dst_pixmap->width-1;
dst_clip.ymax = dst_pixmap->height-1;
if( !blit_clip(&dst_clip, &dst_x, &dst_y,
&src_clip, &src_x, &src_y,
&width, &height) )
{
if( !blit_clip(&dst_clip, &dst_x, &dst_y,
&src_clip, &src_x, &src_y,
&width, &height) )
{
color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x];
color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x];
while( height-- )
{
int w = width;
color_t *tmp_src = src_addr;
color_t *tmp_dst = dst_addr;
int w = width;
color_t *tmp_src = src_addr;
color_t *tmp_dst = dst_addr;
src_addr += src_pixmap->pitch/4;
dst_addr += dst_pixmap->pitch/4;
src_addr += src_pixmap->pitch/4;
dst_addr += dst_pixmap->pitch/4;
while( w >= 8)
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
"movq 16(%0), %%mm2\n"
"movq 24(%0), %%mm3\n"
"movq %%mm0, (%1)\n"
"movq %%mm1, 8(%1)\n"
"movq %%mm2, 16(%1)\n"
"movq %%mm3, 24(%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0", "%mm1", "%mm2", "%mm3");
w -= 8;
tmp_src += 8;
tmp_dst += 8;
};
if( w >= 4 )
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
"movq %%mm0, (%1)\n"
"movq %%mm1, 8(%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0", "%mm1");
w -= 4;
tmp_src += 4;
tmp_dst += 4;
};
if( w >= 2 )
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq %%mm0, (%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0");
w -= 2;
tmp_src += 2;
tmp_dst += 2;
};
if( w )
*tmp_dst = *tmp_src;
while( w >= 8)
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
"movq 16(%0), %%mm2\n"
"movq 24(%0), %%mm3\n"
"movq %%mm0, (%1)\n"
"movq %%mm1, 8(%1)\n"
"movq %%mm2, 16(%1)\n"
"movq %%mm3, 24(%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0", "%mm1", "%mm2", "%mm3");
w -= 8;
tmp_src += 8;
tmp_dst += 8;
};
if( w >= 4 )
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
"movq %%mm0, (%1)\n"
"movq %%mm1, 8(%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0", "%mm1");
w -= 4;
tmp_src += 4;
tmp_dst += 4;
};
if( w >= 2 )
{
__asm__ __volatile__ (
"movq (%0), %%mm0\n"
"movq %%mm0, (%1)\n"
:: "r" (tmp_src), "r" (tmp_dst)
: "memory", "%mm0");
w -= 2;
tmp_src += 2;
tmp_dst += 2;
};
if( w )
*tmp_dst = *tmp_src;
};
};
return ERR_OK;
};
return ERR_OK;
};
int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
@@ -705,6 +705,9 @@ int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
return call_service(&io);
};
dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ;
src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ;
src_clip.xmin = 0;
src_clip.ymin = 0;
src_clip.xmax = src_pixmap->width-1;
@@ -722,8 +725,6 @@ int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
{
__m64 clr_key;
dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ;
src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ;
color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x];
color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x];
@@ -766,4 +767,106 @@ int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y,
return ERR_OK;
}
unsigned long long m_0080 = 0x0080008000800080ULL;
int BlitAlpha(pixmap_t *dst_pixmap, int dst_x, int dst_y,
pixmap_t *src_pixmap, int src_x, int src_y,
int width, int height, u32_t alpha)
{
clip_t src_clip, dst_clip;
if( (srv_hw2d != 0) &&
( (dst_pixmap == (void*)-1) ||
( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) &&
( (src_pixmap == (void*)-1) ||
( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) )
{
ioctl_t io;
pxblit_t *blit = (pxblit_t*)&dst_pixmap;
if((int)dst_pixmap != -1)
blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle;
if((int)src_pixmap != -1)
blit->src_pixmap = (pixmap_t*)src_pixmap->handle;
io.handle = srv_hw2d;
io.io_code = PX_BLIT_ALPHA;
io.input = blit;
io.inp_size = 9;
io.output = NULL;
io.out_size = 0;
return call_service(&io);
};
dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ;
src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ;
src_clip.xmin = 0;
src_clip.ymin = 0;
src_clip.xmax = src_pixmap->width-1;
src_clip.ymax = src_pixmap->height-1;
dst_clip.xmin = 0;
dst_clip.ymin = 0;
dst_clip.xmax = dst_pixmap->width-1;
dst_clip.ymax = dst_pixmap->height-1;
if( !blit_clip(&dst_clip, &dst_x, &dst_y,
&src_clip, &src_x, &src_y,
&width, &height) )
{
__m64 m_alpha;
__m64 m_one_alpha;
color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x];
color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x];
m_alpha = _mm_cvtsi32_si64((alpha << 16) | alpha);
m_alpha = _mm_unpacklo_pi32(m_alpha, m_alpha);
m_one_alpha = _mm_subs_pu16((__m64)0x00FF00FF00FF00FFULL, m_alpha);
while( height-- )
{
int w = width;
color_t *tmp_src = src_addr;
color_t *tmp_dst = dst_addr;
src_addr += src_pixmap->pitch/4;
dst_addr += dst_pixmap->pitch/4;
while( w-- )
{
__asm__ __volatile__ (
"movd (%0), %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"punpcklbw %%mm1, %%mm0 \n\t"
"pmullw %[clr_key], %%mm0 \n\t"
// "paddw %[m_0080], %%mm0 \n\t"
"movd (%1), %%mm2 \n\t"
"punpcklbw %%mm1, %%mm2 \n\t"
"pmullw %[m_one_alpha], %%mm2 \n\t"
// "paddw %[m_0080], %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"psrlw $8, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, (%1)"
:: "r" (tmp_src),
"r" (tmp_dst),
[clr_key] "y" (m_alpha),
[m_one_alpha] "y" (m_one_alpha)
:"memory","mm0", "mm1", "mm2");
tmp_src++;
tmp_dst++;
};
// if( w && (*tmp_src != alpha) )
// *tmp_dst = *tmp_src;
};
};
return ERR_OK;
}

View File

@@ -1,4 +1,6 @@
//#define KOLIBRI_PE
#include "types.h"
#include "system.h"
@@ -64,9 +66,9 @@ int __stdcall start(int state)
scrn_pixmap.width = scrnsize >> 16;
scrn_pixmap.height = scrnsize & 0xFFFF;
scrn_pixmap.format = PICT_a8r8g8b8;
scrn_pixmap.flags = 0;
scrn_pixmap.flags = PX_MEM_LOCAL;
scrn_pixmap.pitch = scrnpitch;
scrn_pixmap.mapped = (void*)0xFE000000;
scrn_pixmap.mapped = (void*)LFB_BASE;
br_slab.available = 256;
br_slab.start = brushes;
@@ -129,6 +131,7 @@ char szDrawRect[] = "DrawRect";
char szFillRect[] = "FillRect";
char szBlit[] = "Blit";
char szTransparentBlit[] = "TransparentBlit";
char szBlitAlpha[] = "BlitAlpha";
export_t EXPORTS[] __asm__("EXPORTS") =
@@ -155,6 +158,7 @@ export_t EXPORTS[] __asm__("EXPORTS") =
{ szFillRect, FillRect },
{ szBlit, Blit },
{ szTransparentBlit, TransparentBlit },
{ szBlitAlpha, BlitAlpha },
{ NULL, NULL },
};

View File

@@ -151,6 +151,7 @@ typedef struct
int src_y;
int w;
int h;
color_t key;
}pxblit_t;
#define PX_CREATE 1

View File

@@ -126,6 +126,21 @@ macro Blit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h
add esp, 8*4
}
macro BlitAlpha dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, alpha
{
pushd alpha
pushd h
pushd w
pushd srcy
pushd srcx
pushd srcpix
pushd dsty
pushd dstx
pushd dstpix
call [imp_BlitAlpha]
add esp, 9*4
}
macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
{
pushd key
@@ -141,6 +156,25 @@ macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
add esp, 9*4
}
macro fix_cwd path
{
pushd path
push '/'
push path
call _strrchr
mov byte [eax], 0
mov eax, 30
mov ebx, 1
mov ecx, [esp+8]
int 0x40
add esp, 12
}
szPxlib db '/rd/1/lib/pixlib.obj',0
szStart db 'START',0
@@ -162,6 +196,7 @@ szDrawRect db 'DrawRect',0
szFillRect db 'FillRect',0
szBlit db 'Blit',0
szTransparentBlit db 'TransparentBlit',0
szBlitAlpha db 'BlitAlpha',0
align 4
@@ -186,6 +221,7 @@ imp_DrawRect dd szDrawRect
imp_FillRect dd szFillRect
imp_Blit dd szBlit
imp_TransparentBlit dd szTransparentBlit
imp_BlitAlpha dd szBlitAlpha
dd 0
@@ -257,4 +293,31 @@ load_pxlib:
xor eax, eax
ret
align 4
_strrchr:
push ebp
mov ebp, esp
push edi
mov edi, [8+ebp]
mov ecx, -1
xor al, al
cld
repne
scasb
not ecx
dec edi
mov al, [12+ebp]
std
repne
scasb
cld
jne .failure
lea eax, [edi+1]
pop edi
pop ebp
ret
.failure:
xor eax, eax
pop edi
pop ebp
ret

View File

@@ -23,17 +23,17 @@ static void free_pixmap(pixmap_t *pixmap)
pixmap_t* CreatePixmap(unsigned width, unsigned height, u32_t format, u32_t flags)
{
pixmap_t *pixmap;
pixmap_t *pixmap;
if( (width == 0) || ( width > 2048)||
(height == 0) || (height > 2048)||
(format != PICT_a8r8g8b8))
if( (width == 0) || ( width > 2048)||
(height == 0) || (height > 2048)||
(format != PICT_a8r8g8b8))
return NULL;
pixmap = alloc_pixmap();
pixmap = alloc_pixmap();
if( pixmap )
{
if( pixmap )
{
void *raw;
int pitch;
@@ -43,45 +43,43 @@ pixmap_t* CreatePixmap(unsigned width, unsigned height, u32_t format, u32_t flag
pixmap->flags = flags;
if( (srv_hw2d != 0) &&
( (flags & PX_MEM_MASK)==PX_MEM_LOCAL) )
( (flags & PX_MEM_MASK)==PX_MEM_LOCAL) )
{
ioctl_t io;
io.handle = srv_hw2d;
io.io_code = PX_CREATE;
io.input = pixmap;
io.inp_size = 7;
io.output = NULL;
io.out_size = 0;
ioctl_t io;
io.handle = srv_hw2d;
io.io_code = PX_CREATE;
io.input = pixmap;
io.inp_size = 7;
io.output = NULL;
io.out_size = 0;
if (call_service(&io)==ERR_OK)
return pixmap;
else
{
free_pixmap(pixmap) ;
return NULL;
}
if (call_service(&io)==ERR_OK)
return pixmap;
else{
free_pixmap(pixmap) ;
return NULL;
}
}
else
{
{
/*
Only system memory
*/
pixmap->flags &= ~PX_MEM_MASK;
pixmap->flags &= ~PX_MEM_MASK;
pitch = ((width+8)&~8)*4;
raw = UserAlloc(pitch * height);
pitch = ((width+8)&~8)*4;
raw = UserAlloc(pitch * height);
if (! raw)
{
free_pixmap(pixmap);
return NULL;
if ( !raw ){
free_pixmap(pixmap);
return NULL;
};
pixmap->pitch = pitch;
pixmap->mapped = raw;
};
pixmap->pitch = pitch;
pixmap->mapped = raw;
};
return pixmap;
};
return NULL;
return pixmap;
};
return NULL;
};
int DestroyPixmap( pixmap_t *pixmap)

View File

@@ -18,6 +18,12 @@ typedef struct
///////////////////////////////////////////////////////////////////////////////
#ifdef KOLIBRI_PE
#define LFB_BASE 0xDF000000
#else
#define LFB_BASE 0xFE000000
#endif
void usleep(u32_t delay);