anigif low usage if no gifs

This commit is contained in:
p.kosyh 2010-03-02 14:49:35 +00:00
parent 94d67b5d60
commit 2e051f5116
4 changed files with 19 additions and 5 deletions

View file

@ -551,7 +551,8 @@ static void anigif_do(void *data)
int counter_fn(int interval, void *p)
{
timer_counter ++;
push_user_event(anigif_do, NULL);
if (gfx_is_drawn_gifs())
push_user_event(anigif_do, NULL);
return interval;
}

View file

@ -162,7 +162,6 @@ static struct {
{"yellowgreen", 0x9acd32},
{NULL, 0x0},
};
int gfx_parse_color (
const char *spec,
color_t *def)
@ -247,6 +246,8 @@ typedef struct _anigif_t *anigif_t;
static anigif_t anim_gifs = NULL;
static int anigif_drawn_nr = 0;
static anigif_t anigif_find(anigif_t g)
{
anigif_t p;
@ -373,6 +374,8 @@ void gfx_free_image(img_t p)
if (!p)
return;
if ((ag = is_anigif(p))) {
if (ag->drawn)
anigif_drawn_nr --;
anigif_del(ag);
anigif_free(ag);
return;
@ -710,6 +713,8 @@ void gfx_draw(img_t p, int x, int y)
ag->clip = clip;
ag->x = x;
ag->y = y;
if (!ag->drawn)
anigif_drawn_nr ++;
ag->drawn = 1;
ag->active = 1;
gfx_free_image(ag->bg);
@ -733,9 +738,11 @@ void gfx_dispose_gif(img_t p)
{
anigif_t ag;
ag = is_anigif(p);
if (ag)
if (ag) {
if (ag->drawn)
anigif_drawn_nr --;
ag->drawn = 0;
}
}
void gfx_start_gif(img_t p)
@ -785,6 +792,11 @@ int gfx_frame_gif(img_t img)
return 1;
}
int gfx_is_drawn_gifs(void)
{
return anigif_drawn_nr;
}
void gfx_update_gif(img_t img)
{
anigif_t ag;

View file

@ -138,6 +138,7 @@ extern layout_t xref_layout(xref_t x);
typedef void (*update_fn)(int x, int y, int w, int h);
extern void xref_update(xref_t xref, int x, int y, clear_fn clear, update_fn update);
extern void gfx_start_gif(img_t img);
extern int gfx_is_drawn_gifs(void);
extern void gfx_stop_gif(img_t img);
extern int gfx_frame_gif(img_t img);
extern void gfx_del_timer(gtimer_t han);

View file

@ -66,7 +66,7 @@ int input(struct inp_event *inp, int wait)
SDL_ShowCursor(SDL_ENABLE);
}
}
return 0; //AGAIN;
return 0;
case SDL_USEREVENT: {
void (*p) (void*) = event.user.data1;
p(event.user.data2);