Add OVERLAY_IMAGE_TRANSFER_DESC_ITERATE and OVERLAY_IMAGE_TRANSFER_DESC_DONE

This commit is contained in:
twinaphex 2015-02-23 20:57:49 +01:00
parent d44ebefd49
commit 89685c5709
2 changed files with 37 additions and 20 deletions

View File

@ -364,32 +364,31 @@ static bool input_overlay_load_overlay(input_overlay_t *ol,
struct overlay *overlay, unsigned idx) struct overlay *overlay, unsigned idx)
{ {
size_t i; size_t i;
bool not_done = overlay->pos < overlay->size;
for (i = 0; i < overlay->size; i++) if (!not_done)
{ {
if (!input_overlay_load_desc(ol, &overlay->descs[i], idx, i, overlay->pos = 0;
ol->loading_status = OVERLAY_IMAGE_TRANSFER_DESC_DONE;
return true;
}
if (!input_overlay_load_desc(ol, &overlay->descs[overlay->pos], idx, overlay->pos,
overlay->image.width, overlay->image.height, overlay->image.width, overlay->image.height,
overlay->config.normalized, overlay->config.normalized,
overlay->config.alpha_mod, overlay->config.range_mod)) overlay->config.alpha_mod, overlay->config.range_mod))
{ {
RARCH_ERR("[Overlay]: Failed to load overlay descs for overlay #%u.\n", RARCH_ERR("[Overlay]: Failed to load overlay descs for overlay #%u.\n",
(unsigned)i); (unsigned)overlay->pos);
goto error; goto error;
} }
}
if (overlay->image.pixels) if (overlay->descs[overlay->pos].image.pixels)
overlay->load_images[overlay->load_images_size++] = overlay->image;
for (i = 0; i < overlay->size; i++)
{ {
if (!overlay->descs[i].image.pixels) overlay->descs[overlay->pos].image_index = overlay->load_images_size;
continue; overlay->load_images[overlay->load_images_size++] = overlay->descs[overlay->pos].image;
overlay->descs[i].image_index = overlay->load_images_size;
overlay->load_images[overlay->load_images_size++] = overlay->descs[i].image;
} }
overlay->pos++;
return true; return true;
@ -479,6 +478,16 @@ error:
return false; return false;
} }
static bool input_overlay_load_overlay_image_done(struct overlay *overlay)
{
if (overlay->image.pixels)
overlay->load_images[overlay->load_images_size++] = overlay->image;
overlay->pos = 0;
return true;
}
bool input_overlay_load_overlays_iterate(input_overlay_t *ol) bool input_overlay_load_overlays_iterate(input_overlay_t *ol)
{ {
bool not_done = true; bool not_done = true;
@ -507,13 +516,18 @@ bool input_overlay_load_overlays_iterate(input_overlay_t *ol)
ol->loading_status = OVERLAY_IMAGE_TRANSFER_DONE; ol->loading_status = OVERLAY_IMAGE_TRANSFER_DONE;
break; break;
case OVERLAY_IMAGE_TRANSFER_DONE: case OVERLAY_IMAGE_TRANSFER_DONE:
input_overlay_load_overlay_image_done(&ol->overlays[ol->pos]);
ol->loading_status = OVERLAY_IMAGE_TRANSFER_DESC_ITERATE;
break;
case OVERLAY_IMAGE_TRANSFER_DESC_ITERATE:
if (!input_overlay_load_overlay(ol, if (!input_overlay_load_overlay(ol,
ol->overlay_path, &ol->overlays[ol->pos], ol->pos)) ol->overlay_path, &ol->overlays[ol->pos], ol->pos))
{ {
RARCH_ERR("[Overlay]: Failed to load overlay #%u.\n", (unsigned)ol->pos); RARCH_ERR("[Overlay]: Failed to load overlay #%u.\n", (unsigned)ol->pos);
goto error; goto error;
} }
break;
case OVERLAY_IMAGE_TRANSFER_DESC_DONE:
ol->pos += 1; ol->pos += 1;
ol->loading_status = OVERLAY_IMAGE_TRANSFER_NONE; ol->loading_status = OVERLAY_IMAGE_TRANSFER_NONE;
break; break;

View File

@ -86,6 +86,8 @@ enum overlay_image_transfer_status
OVERLAY_IMAGE_TRANSFER_NONE = 0, OVERLAY_IMAGE_TRANSFER_NONE = 0,
OVERLAY_IMAGE_TRANSFER_BUSY, OVERLAY_IMAGE_TRANSFER_BUSY,
OVERLAY_IMAGE_TRANSFER_DONE, OVERLAY_IMAGE_TRANSFER_DONE,
OVERLAY_IMAGE_TRANSFER_DESC_ITERATE,
OVERLAY_IMAGE_TRANSFER_DESC_DONE,
OVERLAY_IMAGE_TRANSFER_ERROR, OVERLAY_IMAGE_TRANSFER_ERROR,
}; };
@ -121,6 +123,7 @@ struct overlay
{ {
struct overlay_desc *descs; struct overlay_desc *descs;
size_t size; size_t size;
size_t pos;
struct texture_image image; struct texture_image image;