Use struct texture_image instead of video_overlay_image.

This commit is contained in:
Themaister 2013-12-31 19:03:58 +01:00
parent 43f42b6439
commit 132c3c46f7
6 changed files with 24 additions and 38 deletions

View File

@ -24,6 +24,7 @@
#include <stdint.h>
#include "msvc/msvc_compat.h"
#include "gfx/scaler/scaler.h"
#include "gfx/image.h"
#include "input/overlay.h"
#ifdef HAVE_CONFIG_H
@ -409,17 +410,10 @@ typedef struct location_driver
struct rarch_viewport;
#ifdef HAVE_OVERLAY
struct video_overlay_image
{
const uint32_t *image;
unsigned width;
unsigned height;
};
typedef struct video_overlay_interface
{
void (*enable)(void *data, bool state);
bool (*load)(void *data, const struct video_overlay_image *images, unsigned num_images);
bool (*load)(void *data, const struct texture_image *images, unsigned num_images);
void (*tex_geom)(void *data, unsigned image, float x, float y, float w, float h);
void (*vertex_geom)(void *data, unsigned image, float x, float y, float w, float h);
void (*full_screen)(void *data, bool enable);

View File

@ -1051,7 +1051,7 @@ void D3DVideo::resize(unsigned new_width, unsigned new_height)
}
#ifdef HAVE_OVERLAY
bool D3DVideo::overlay_load(const video_overlay_image *images, unsigned num_images)
bool D3DVideo::overlay_load(const texture_image *images, unsigned num_images)
{
free_overlays();
overlays.resize(num_images);
@ -1075,7 +1075,7 @@ bool D3DVideo::overlay_load(const video_overlay_image *images, unsigned num_imag
if (SUCCEEDED(overlay.tex->LockRect(0, &d3dlr, nullptr, D3DLOCK_NOSYSLOCK)))
{
uint32_t *dst = static_cast<uint32_t*>(d3dlr.pBits);
const uint32_t *src = images[i].image;
const uint32_t *src = images[i].pixels;
unsigned pitch = d3dlr.Pitch >> 2;
for (unsigned y = 0; y < height; y++, dst += pitch, src += width)
std::memcpy(dst, src, width << 2);
@ -1392,7 +1392,7 @@ static void d3d9_get_poke_interface(void *data, const video_poke_interface_t **i
#endif
#ifdef HAVE_OVERLAY
static bool d3d9_overlay_load(void *data, const video_overlay_image *images, unsigned num_images)
static bool d3d9_overlay_load(void *data, const texture_image *images, unsigned num_images)
{
return reinterpret_cast<D3DVideo*>(data)->overlay_load(images, num_images);
}

View File

@ -77,7 +77,7 @@ class D3DVideo
void overlay_render(overlay_t &overlay);
#ifdef HAVE_OVERLAY
bool overlay_load(const video_overlay_image *images, unsigned num_images);
bool overlay_load(const texture_image *images, unsigned num_images);
void overlay_tex_geom(unsigned index, float x, float y, float w, float h);
void overlay_vertex_geom(unsigned index, float x, float y, float w, float h);
void overlay_enable(bool state);

View File

@ -2423,7 +2423,7 @@ static void gl_restart(void)
#ifdef HAVE_OVERLAY
static void gl_free_overlay(gl_t *gl);
static bool gl_overlay_load(void *data, const struct video_overlay_image *images, unsigned num_images)
static bool gl_overlay_load(void *data, const struct texture_image *images, unsigned num_images)
{
unsigned i;
gl_t *gl = (gl_t*)data;
@ -2448,7 +2448,7 @@ static bool gl_overlay_load(void *data, const struct video_overlay_image *images
glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(images[i].width * sizeof(uint32_t)));
glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
images[i].width, images[i].height, 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
RARCH_GL_FORMAT32, images[i].image);
RARCH_GL_FORMAT32, images[i].pixels);
gl_overlay_tex_geom(gl, i, 0, 0, 1, 1); // Default. Stretch to whole screen.
gl_overlay_vertex_geom(gl, i, 0, 0, 1, 1);

View File

@ -124,7 +124,7 @@ typedef struct thread_video
struct
{
const struct video_overlay_image *data;
const struct texture_image *data;
unsigned num;
} image;
@ -581,7 +581,7 @@ static void thread_overlay_enable(void *data, bool state)
thread_wait_reply(thr, CMD_OVERLAY_ENABLE);
}
static bool thread_overlay_load(void *data, const struct video_overlay_image *images, unsigned num_images)
static bool thread_overlay_load(void *data, const struct texture_image *images, unsigned num_images)
{
thread_video_t *thr = (thread_video_t*)data;
thr->cmd_data.image.data = images;

View File

@ -56,7 +56,7 @@ struct overlay_desc
unsigned next_index;
char next_index_name[64];
struct video_overlay_image image;
struct texture_image image;
unsigned image_index;
float alpha_mod;
@ -71,7 +71,7 @@ struct overlay
struct overlay_desc *descs;
size_t size;
struct video_overlay_image image;
struct texture_image image;
bool block_scale;
float mod_x, mod_y, mod_w, mod_h;
@ -83,7 +83,7 @@ struct overlay
char name[64];
struct video_overlay_image *load_images;
struct texture_image *load_images;
unsigned load_images_size;
};
@ -213,14 +213,14 @@ static void input_overlay_scale(struct overlay *overlay, float scale)
static void input_overlay_set_vertex_geom(input_overlay_t *ol)
{
size_t i;
if (ol->active->image.image)
if (ol->active->image.pixels)
ol->iface->vertex_geom(ol->iface_data, 0,
ol->active->mod_x, ol->active->mod_y, ol->active->mod_w, ol->active->mod_h);
for (i = 0; i < ol->active->size; i++)
{
struct overlay_desc *desc = &ol->active->descs[i];
if (desc->image.image)
if (desc->image.pixels)
ol->iface->vertex_geom(ol->iface_data, desc->image_index,
desc->mod_x, desc->mod_y, desc->mod_w, desc->mod_h);
}
@ -239,10 +239,10 @@ static void input_overlay_free_overlay(struct overlay *overlay)
{
size_t i;
for (i = 0; i < overlay->size; i++)
free((void*)overlay->descs[i].image.image);
free(overlay->descs[i].image.pixels);
free(overlay->load_images);
free(overlay->descs);
free((void*)overlay->image.image);
free(overlay->image.pixels);
}
static void input_overlay_free_overlays(input_overlay_t *ol)
@ -274,11 +274,7 @@ static bool input_overlay_load_desc(input_overlay_t *ol, config_file_t *conf, st
struct texture_image img = {0};
if (texture_image_load(path, &img))
{
desc->image.image = img.pixels;
desc->image.width = img.width;
desc->image.height = img.height;
}
desc->image = img;
}
char overlay_desc_normalized_key[64];
@ -425,11 +421,7 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
struct texture_image img = {0};
if (texture_image_load(overlay_resolved_path, &img))
{
overlay->image.image = img.pixels;
overlay->image.width = img.width;
overlay->image.height = img.height;
}
overlay->image = img;
else
{
RARCH_ERR("[Overlay]: Failed to load image: %s.\n", overlay_resolved_path);
@ -514,19 +506,19 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
}
// Precache load image array for simplicity.
overlay->load_images = (struct video_overlay_image*)calloc(1 + overlay->size, sizeof(struct video_overlay_image));
overlay->load_images = (struct texture_image*)calloc(1 + overlay->size, sizeof(struct texture_image));
if (!overlay->load_images)
{
RARCH_ERR("[Overlay]: Failed to allocate load_images.\n");
return false;
}
if (overlay->image.image)
if (overlay->image.pixels)
overlay->load_images[overlay->load_images_size++] = overlay->image;
for (i = 0; i < overlay->size; i++)
{
if (overlay->descs[i].image.image)
if (overlay->descs[i].image.pixels)
{
overlay->descs[i].image_index = overlay->load_images_size;
overlay->load_images[overlay->load_images_size++] = overlay->descs[i].image;
@ -799,7 +791,7 @@ void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, int16_t
static void input_overlay_update_desc_geom(input_overlay_t *ol, struct overlay_desc *desc)
{
if (desc->image.image && desc->movable)
if (desc->image.pixels && desc->movable)
{
ol->iface->vertex_geom(ol->iface_data, desc->image_index,
desc->mod_x + desc->delta_x, desc->mod_y + desc->delta_y,
@ -826,7 +818,7 @@ void input_overlay_post_poll(input_overlay_t *ol)
desc->range_x_mod = desc->range_x * desc->range_mod;
desc->range_y_mod = desc->range_y * desc->range_mod;
if (desc->image.image)
if (desc->image.pixels)
ol->iface->set_alpha(ol->iface_data, desc->image_index,
desc->alpha_mod * g_settings.input.overlay_opacity);
}