Преглед на файлове

* Optimise cucul_blit() by using memcpy() if there is no mask.

tags/v0.99.beta14
Sam Hocevar sam преди 19 години
родител
ревизия
1c7d39a015
променени са 1 файла, в които са добавени 24 реда и са изтрити 9 реда
  1. +24
    -9
      cucul/canvas.c

+ 24
- 9
cucul/canvas.c Целия файл

@@ -275,7 +275,7 @@ void cucul_blit(cucul_t *dst, int x, int y,
{ {
int i, j, starti, startj, endi, endj; int i, j, starti, startj, endi, endj;


if(src->width != mask->width || src->height != mask->height) if(mask && (src->width != mask->width || src->height != mask->height))
return; return;


starti = x < 0 ? -x : 0; starti = x < 0 ? -x : 0;
@@ -283,17 +283,32 @@ void cucul_blit(cucul_t *dst, int x, int y,
endi = (x + src->width >= dst->width) ? dst->width - x : src->width; endi = (x + src->width >= dst->width) ? dst->width - x : src->width;
endj = (y + src->height >= dst->height) ? dst->height - y : src->height; endj = (y + src->height >= dst->height) ? dst->height - y : src->height;


if(starti >= endi || startj >= endj)
return;

for(j = startj; j < endj; j++) for(j = startj; j < endj; j++)
{ {
for(i = starti; i < endi; i++) if(mask)
{ {
if(mask && mask->chars[j * src->width + i] == (uint32_t)' ') for(i = starti; i < endi; i++)
continue; {

if(mask->chars[j * src->width + i] == (uint32_t)' ')
dst->chars[(j + y) * dst->width + (i + x)] continue;
= src->chars[j * src->width + i]; dst->chars[(j + y) * dst->width + (i + x)]
dst->attr[(j + y) * dst->width + (i + x)] = src->chars[j * src->width + i];
= src->attr[j * src->width + i]; dst->attr[(j + y) * dst->width + (i + x)]
= src->attr[j * src->width + i];
}
}
else
{
memcpy(dst->chars + (j + y) * dst->width + starti + x,
src->chars + j * src->width + starti,
(endi - starti) * 4);
memcpy(dst->attr + (j + y) * dst->width + starti + x,
src->attr + j * src->width + starti,
(endi - starti) * 1);
} }
} }
} }


||||||
x
 
000:0
Зареждане…
Отказ
Запис