anigif low usage if no gifs
This commit is contained in:
parent
94d67b5d60
commit
2e051f5116
|
@ -551,7 +551,8 @@ static void anigif_do(void *data)
|
||||||
int counter_fn(int interval, void *p)
|
int counter_fn(int interval, void *p)
|
||||||
{
|
{
|
||||||
timer_counter ++;
|
timer_counter ++;
|
||||||
push_user_event(anigif_do, NULL);
|
if (gfx_is_drawn_gifs())
|
||||||
|
push_user_event(anigif_do, NULL);
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,6 @@ static struct {
|
||||||
{"yellowgreen", 0x9acd32},
|
{"yellowgreen", 0x9acd32},
|
||||||
{NULL, 0x0},
|
{NULL, 0x0},
|
||||||
};
|
};
|
||||||
|
|
||||||
int gfx_parse_color (
|
int gfx_parse_color (
|
||||||
const char *spec,
|
const char *spec,
|
||||||
color_t *def)
|
color_t *def)
|
||||||
|
@ -247,6 +246,8 @@ typedef struct _anigif_t *anigif_t;
|
||||||
|
|
||||||
static anigif_t anim_gifs = NULL;
|
static anigif_t anim_gifs = NULL;
|
||||||
|
|
||||||
|
static int anigif_drawn_nr = 0;
|
||||||
|
|
||||||
static anigif_t anigif_find(anigif_t g)
|
static anigif_t anigif_find(anigif_t g)
|
||||||
{
|
{
|
||||||
anigif_t p;
|
anigif_t p;
|
||||||
|
@ -373,6 +374,8 @@ void gfx_free_image(img_t p)
|
||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
if ((ag = is_anigif(p))) {
|
if ((ag = is_anigif(p))) {
|
||||||
|
if (ag->drawn)
|
||||||
|
anigif_drawn_nr --;
|
||||||
anigif_del(ag);
|
anigif_del(ag);
|
||||||
anigif_free(ag);
|
anigif_free(ag);
|
||||||
return;
|
return;
|
||||||
|
@ -710,6 +713,8 @@ void gfx_draw(img_t p, int x, int y)
|
||||||
ag->clip = clip;
|
ag->clip = clip;
|
||||||
ag->x = x;
|
ag->x = x;
|
||||||
ag->y = y;
|
ag->y = y;
|
||||||
|
if (!ag->drawn)
|
||||||
|
anigif_drawn_nr ++;
|
||||||
ag->drawn = 1;
|
ag->drawn = 1;
|
||||||
ag->active = 1;
|
ag->active = 1;
|
||||||
gfx_free_image(ag->bg);
|
gfx_free_image(ag->bg);
|
||||||
|
@ -733,9 +738,11 @@ void gfx_dispose_gif(img_t p)
|
||||||
{
|
{
|
||||||
anigif_t ag;
|
anigif_t ag;
|
||||||
ag = is_anigif(p);
|
ag = is_anigif(p);
|
||||||
if (ag)
|
if (ag) {
|
||||||
|
if (ag->drawn)
|
||||||
|
anigif_drawn_nr --;
|
||||||
ag->drawn = 0;
|
ag->drawn = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_start_gif(img_t p)
|
void gfx_start_gif(img_t p)
|
||||||
|
@ -785,6 +792,11 @@ int gfx_frame_gif(img_t img)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gfx_is_drawn_gifs(void)
|
||||||
|
{
|
||||||
|
return anigif_drawn_nr;
|
||||||
|
}
|
||||||
|
|
||||||
void gfx_update_gif(img_t img)
|
void gfx_update_gif(img_t img)
|
||||||
{
|
{
|
||||||
anigif_t ag;
|
anigif_t ag;
|
||||||
|
|
|
@ -138,6 +138,7 @@ extern layout_t xref_layout(xref_t x);
|
||||||
typedef void (*update_fn)(int x, int y, int w, int h);
|
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 xref_update(xref_t xref, int x, int y, clear_fn clear, update_fn update);
|
||||||
extern void gfx_start_gif(img_t img);
|
extern void gfx_start_gif(img_t img);
|
||||||
|
extern int gfx_is_drawn_gifs(void);
|
||||||
extern void gfx_stop_gif(img_t img);
|
extern void gfx_stop_gif(img_t img);
|
||||||
extern int gfx_frame_gif(img_t img);
|
extern int gfx_frame_gif(img_t img);
|
||||||
extern void gfx_del_timer(gtimer_t han);
|
extern void gfx_del_timer(gtimer_t han);
|
||||||
|
|
|
@ -66,7 +66,7 @@ int input(struct inp_event *inp, int wait)
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; //AGAIN;
|
return 0;
|
||||||
case SDL_USEREVENT: {
|
case SDL_USEREVENT: {
|
||||||
void (*p) (void*) = event.user.data1;
|
void (*p) (void*) = event.user.data1;
|
||||||
p(event.user.data2);
|
p(event.user.data2);
|
||||||
|
|
Reference in a new issue