Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1001 → Rev 1002

/programs/develop/libraries/pixlib/clip.inc
170,11 → 170,11
*src_y += dy0 - *dst_y;
 
*dst_x = dx0;
*dst_y = dx0;
*dst_y = dy0;
 
return 0;
};
};
}
return 1;
};
 
/programs/develop/libraries/pixlib/draw.inc
564,14 → 564,13
return ERR_PARAM;
 
/* if "hardware acceleration present" and
"destinastion is primary screen or local videomemory" and
"source is primary screen or local videomemory"
"destinastion is primary screen or local videomemory"
*/
if( (srv_hw2d != 0) &&
( (dst_pixmap == (void*)-1) ||
( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) &&
( (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;
579,7 → 578,8
if((int)dst_pixmap != -1)
blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle;
 
if((int)src_pixmap != -1)
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;
705,6 → 705,9
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
{
__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
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;
}
/programs/develop/libraries/pixlib/pixlib.c
1,4 → 1,6
 
//#define KOLIBRI_PE
 
#include "types.h"
#include "system.h"
 
64,9 → 66,9
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 szFillRect[] = "FillRect";
char szBlit[] = "Blit";
char szTransparentBlit[] = "TransparentBlit";
char szBlitAlpha[] = "BlitAlpha";
 
 
export_t EXPORTS[] __asm__("EXPORTS") =
155,6 → 158,7
{ szFillRect, FillRect },
{ szBlit, Blit },
{ szTransparentBlit, TransparentBlit },
{ szBlitAlpha, BlitAlpha },
 
{ NULL, NULL },
};
/programs/develop/libraries/pixlib/pixlib.h
151,6 → 151,7
int src_y;
int w;
int h;
color_t key;
}pxblit_t;
 
#define PX_CREATE 1
/programs/develop/libraries/pixlib/pixlib.inc
126,6 → 126,21
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
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
szFillRect db 'FillRect',0
szBlit db 'Blit',0
szTransparentBlit db 'TransparentBlit',0
szBlitAlpha db 'BlitAlpha',0
 
align 4
 
186,6 → 221,7
imp_FillRect dd szFillRect
imp_Blit dd szBlit
imp_TransparentBlit dd szTransparentBlit
imp_BlitAlpha dd szBlitAlpha
 
dd 0
 
257,4 → 293,31
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
/programs/develop/libraries/pixlib/pixmap.inc
55,8 → 55,7
 
if (call_service(&io)==ERR_OK)
return pixmap;
else
{
else{
free_pixmap(pixmap) ;
return NULL;
}
71,8 → 70,7
pitch = ((width+8)&~8)*4;
raw = UserAlloc(pitch * height);
 
if (! raw)
{
if ( !raw ){
free_pixmap(pixmap);
return NULL;
};
/programs/develop/libraries/pixlib/system.h
18,7 → 18,13
 
///////////////////////////////////////////////////////////////////////////////
 
#ifdef KOLIBRI_PE
#define LFB_BASE 0xDF000000
#else
#define LFB_BASE 0xFE000000
#endif
 
 
void usleep(u32_t delay);
 
static int __attribute__ ((always_inline))