Sfoglia il codice sorgente

* src/event.c:

+ Make sure the mouse coordinates stay within the screen boundaries even
      if the window was resized.
  * src/bitmap.c:
    + Fixed a buffer underflow in the rendering routine that caused the bottom
      and rightmost pixels to be missed in certain conditions.
    + Minor speed optimisation.
tags/v0.99.beta14
Sam Hocevar sam 21 anni fa
parent
commit
a1ab99a862
2 ha cambiato i file con 29 aggiunte e 12 eliminazioni
  1. +23
    -12
      src/bitmap.c
  2. +6
    -0
      src/event.c

+ 23
- 12
src/bitmap.c Vedi File

@@ -456,7 +456,7 @@ void caca_draw_bitmap(int x1, int y1, int x2, int y2,
"####"
"????";

int x, y, w, h, pitch;
int x, y, w, h, pitch, deltax, deltay;

if(!bitmap || !pixels)
return;
@@ -475,6 +475,9 @@ void caca_draw_bitmap(int x1, int y1, int x2, int y2,
int tmp = y2; y2 = y1; y1 = tmp;
}

deltax = x2 - x1 + 1;
deltay = y2 - y1 + 1;

switch(_caca_dithering)
{
case CACA_DITHERING_NONE:
@@ -529,14 +532,19 @@ void caca_draw_bitmap(int x1, int y1, int x2, int y2,
/* First get RGB */
if(_caca_antialiasing == CACA_ANTIALIASING_PREFILTER)
{
fromx = ((x - x1) * (w - 1)) / (x2 - x1 + 1);
fromy = ((y - y1) * (h - 1)) / (y2 - y1 + 1);
tox = ((x - x1 + 1) * (w - 1)) / (x2 - x1 + 1);
toy = ((y - y1 + 1) * (h - 1)) / (y2 - y1 + 1);
fromx = (x - x1) * w / deltax;
fromy = (y - y1) * h / deltay;
tox = (x - x1 + 1) * w / deltax;
toy = (y - y1 + 1) * h / deltay;

/* We want at least one pixel */
if(tox == fromx) tox++;
if(toy == fromy) toy++;

dots = 0;

for(myx = fromx; myx <= tox; myx++)
for(myy = fromy; myy <= toy; myy++)
for(myx = fromx; myx < tox; myx++)
for(myy = fromy; myy < toy; myy++)
{
dots++;
get_rgba_default(bitmap, pixels, myx, myy, &r, &g, &b, &a);
@@ -550,11 +558,14 @@ void caca_draw_bitmap(int x1, int y1, int x2, int y2,
}
else
{
fromx = ((x - x1) * (w - 1)) / (x2 - x1 + 1);
fromy = ((y - y1) * (h - 1)) / (y2 - y1 + 1);
tox = ((x - x1 + 1) * (w - 1)) / (x2 - x1 + 1);
toy = ((y - y1 + 1) * (h - 1)) / (y2 - y1 + 1);

fromx = (x - x1) * w / deltax;
fromy = (y - y1) * h / deltay;
tox = (x - x1 + 1) * w / deltax;
toy = (y - y1 + 1) * h / deltay;

/* tox and toy can overflow the screen, but they cannot overflow
* when averaged with fromx and fromy because these are guaranteed
* to be within the pixel boundaries. */
myx = (fromx + tox) / 2;
myy = (fromy + toy) / 2;



+ 6
- 0
src/event.c Vedi File

@@ -143,6 +143,9 @@ unsigned int caca_wait_event(unsigned int event_mask)
*/
unsigned int caca_get_mouse_x(void)
{
if(mouse_x >= _caca_width)
mouse_x = _caca_width - 1;

return mouse_x;
}

@@ -157,6 +160,9 @@ unsigned int caca_get_mouse_x(void)
*/
unsigned int caca_get_mouse_y(void)
{
if(mouse_y >= _caca_height)
mouse_y = _caca_height - 1;

return mouse_y;
}



Caricamento…
Annulla
Salva