mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(Video layout) move init_string and set_string to stdstring -
rename them - cleanup strcmp usage in video layout and other code cleanups
This commit is contained in:
parent
1bda81560e
commit
899c21257c
@ -24,6 +24,7 @@
|
||||
#include <file/file_path.h>
|
||||
#include <file/archive_file.h>
|
||||
#include <compat/strl.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "video_layout.h"
|
||||
#include "video_layout/view.h"
|
||||
@ -31,7 +32,7 @@
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
bool load(view_array_t *view_array, rxml_document_t *doc);
|
||||
bool video_layout_load_internal(view_array_t *view_array, rxml_document_t *doc);
|
||||
|
||||
typedef struct io
|
||||
{
|
||||
@ -66,24 +67,26 @@ video_layout_state_t;
|
||||
|
||||
static video_layout_state_t *video_layout_state = NULL;
|
||||
|
||||
void video_layout_init(void *video_driver_data, const video_layout_render_interface_t *render)
|
||||
void video_layout_init(void *video_driver_data,
|
||||
const video_layout_render_interface_t *render)
|
||||
{
|
||||
if (video_layout_state)
|
||||
video_layout_deinit();
|
||||
|
||||
video_layout_state = (video_layout_state_t*)calloc(1, sizeof(video_layout_state_t));
|
||||
video_layout_state = (video_layout_state_t*)
|
||||
calloc(1, sizeof(video_layout_state_t));
|
||||
video_layout_state->render_info.video_driver_data = video_driver_data;
|
||||
video_layout_state->render = render;
|
||||
video_layout_state->render = render;
|
||||
|
||||
vec_size((void**)&video_layout_state->images, sizeof(void*), 1);
|
||||
|
||||
video_layout_state->images[0] = NULL;
|
||||
video_layout_state->images[0] = NULL;
|
||||
video_layout_state->images_count = 1;
|
||||
}
|
||||
|
||||
void video_layout_deinit(void)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
if (!video_layout_state)
|
||||
return;
|
||||
@ -113,13 +116,12 @@ void video_layout_deinit(void)
|
||||
|
||||
int video_layout_io_assign(const char *name, int base_value)
|
||||
{
|
||||
int index;
|
||||
int index = video_layout_state->io_count;
|
||||
|
||||
index = video_layout_state->io_count;
|
||||
vec_size((void**)&video_layout_state->io,
|
||||
sizeof(io_t), ++video_layout_state->io_count);
|
||||
|
||||
vec_size((void**)&video_layout_state->io, sizeof(io_t), ++video_layout_state->io_count);
|
||||
|
||||
video_layout_state->io[index].name = init_string(name);
|
||||
video_layout_state->io[index].name = string_init(name);
|
||||
video_layout_state->io[index].base_value = base_value;
|
||||
video_layout_state->io[index].value = base_value;
|
||||
|
||||
@ -128,11 +130,11 @@ int video_layout_io_assign(const char *name, int base_value)
|
||||
|
||||
int video_layout_io_find(const char *name)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < video_layout_state->io_count; ++i)
|
||||
{
|
||||
if (strcmp(video_layout_state->io[i].name, name) == 0)
|
||||
if (string_is_equal(video_layout_state->io[i].name, name))
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -151,27 +153,26 @@ void video_layout_io_set(int index, int value)
|
||||
|
||||
bool video_layout_load(const char *path)
|
||||
{
|
||||
rxml_document_t *doc;
|
||||
rxml_document_t *doc = NULL;
|
||||
bool result;
|
||||
|
||||
if(!path || !strlen(path))
|
||||
if (!path || !strlen(path))
|
||||
return true;
|
||||
|
||||
video_layout_state->is_archive = path_is_compressed_file(path);
|
||||
|
||||
doc = NULL;
|
||||
|
||||
if(video_layout_state->is_archive)
|
||||
if (video_layout_state->is_archive)
|
||||
{
|
||||
void *buf;
|
||||
int64_t len;
|
||||
|
||||
char respath[PATH_MAX_LENGTH];
|
||||
|
||||
strlcpy(respath, path, sizeof(respath));
|
||||
strlcat(respath, "#", sizeof(respath));
|
||||
set_string(&video_layout_state->base_path, respath);
|
||||
string_set(&video_layout_state->base_path, respath);
|
||||
|
||||
strlcat(respath, "default.lay", sizeof(respath));
|
||||
|
||||
if (file_archive_compressed_read(respath, &buf, NULL, &len))
|
||||
{
|
||||
char *str;
|
||||
@ -188,7 +189,7 @@ bool video_layout_load(const char *path)
|
||||
{
|
||||
char respath[PATH_MAX_LENGTH];
|
||||
fill_pathname_basedir(respath, path, sizeof(respath));
|
||||
set_string(&video_layout_state->base_path, respath);
|
||||
string_set(&video_layout_state->base_path, respath);
|
||||
doc = rxml_load_document(path);
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ bool video_layout_load(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
result = load(&video_layout_state->view_array, doc);
|
||||
result = video_layout_load_internal(&video_layout_state->view_array, doc);
|
||||
rxml_free_document(doc);
|
||||
|
||||
video_layout_view_select(video_layout_view_index());
|
||||
@ -222,8 +223,8 @@ static int video_layout_load_image(const char *path)
|
||||
{
|
||||
void *buf;
|
||||
int64_t len;
|
||||
|
||||
char respath[PATH_MAX_LENGTH];
|
||||
|
||||
strlcpy(respath, video_layout_state->base_path, sizeof(respath));
|
||||
strlcat(respath, path, sizeof(respath));
|
||||
|
||||
@ -233,7 +234,8 @@ static int video_layout_load_image(const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!image_texture_load_buffer(&image, image_texture_get_type(path), buf, (size_t)len))
|
||||
if (!image_texture_load_buffer(&image,
|
||||
image_texture_get_type(path), buf, (size_t)len))
|
||||
{
|
||||
free(buf);
|
||||
|
||||
@ -246,6 +248,7 @@ static int video_layout_load_image(const char *path)
|
||||
else
|
||||
{
|
||||
char respath[PATH_MAX_LENGTH];
|
||||
|
||||
strlcpy(respath, video_layout_state->base_path, sizeof(respath));
|
||||
strlcat(respath, path, sizeof(respath));
|
||||
|
||||
@ -264,7 +267,8 @@ static int video_layout_load_image(const char *path)
|
||||
|
||||
index = video_layout_state->images_count;
|
||||
|
||||
vec_size((void**)&video_layout_state->images, sizeof(void*), ++video_layout_state->images_count);
|
||||
vec_size((void**)&video_layout_state->images,
|
||||
sizeof(void*), ++video_layout_state->images_count);
|
||||
|
||||
video_layout_state->images[index] = handle;
|
||||
|
||||
@ -283,11 +287,12 @@ const char *video_layout_view_name(int index)
|
||||
|
||||
int video_layout_view_select(int index)
|
||||
{
|
||||
index = MAX(0, MIN(index, video_layout_state->view_array.views_count - 1));
|
||||
|
||||
index = MAX(0,
|
||||
MIN(index, video_layout_state->view_array.views_count - 1));
|
||||
video_layout_state->view_index = index;
|
||||
video_layout_state->view = video_layout_state->view_array.views_count ?
|
||||
&video_layout_state->view_array.views[index] : NULL;
|
||||
video_layout_state->view = video_layout_state->view_array.views_count
|
||||
? &video_layout_state->view_array.views[index]
|
||||
: NULL;
|
||||
|
||||
video_layout_view_change();
|
||||
|
||||
@ -297,7 +302,8 @@ int video_layout_view_select(int index)
|
||||
int video_layout_view_cycle(void)
|
||||
{
|
||||
return video_layout_view_select(
|
||||
(video_layout_state->view_index + 1) % video_layout_state->view_array.views_count);
|
||||
(video_layout_state->view_index + 1)
|
||||
% video_layout_state->view_array.views_count);
|
||||
}
|
||||
|
||||
int video_layout_view_index(void)
|
||||
@ -322,16 +328,12 @@ bool video_layout_view_on_change(void)
|
||||
|
||||
void video_layout_view_fit_bounds(video_layout_bounds_t bounds)
|
||||
{
|
||||
view_t *view;
|
||||
float c, dx, dy;
|
||||
int i, j, k;
|
||||
|
||||
view = video_layout_state->view;
|
||||
|
||||
c = MIN(bounds.w / view->bounds.w, bounds.h / view->bounds.h);
|
||||
|
||||
dx = view->bounds.w * c;
|
||||
dy = view->bounds.h * c;
|
||||
unsigned i, j, k;
|
||||
view_t *view = video_layout_state->view;
|
||||
float c = MIN(bounds.w / view->bounds.w,
|
||||
bounds.h / view->bounds.h);
|
||||
float dx = view->bounds.w * c;
|
||||
float dy = view->bounds.h * c;
|
||||
|
||||
view->render_bounds.w = dx;
|
||||
view->render_bounds.h = dy;
|
||||
@ -340,13 +342,11 @@ void video_layout_view_fit_bounds(video_layout_bounds_t bounds)
|
||||
|
||||
for (i = 0; i < view->layers_count; ++i)
|
||||
{
|
||||
layer_t *layer;
|
||||
layer = &view->layers[i];
|
||||
layer_t *layer = &view->layers[i];
|
||||
|
||||
for (j = 0; j < layer->elements_count; ++j)
|
||||
{
|
||||
element_t *elem;
|
||||
elem = &layer->elements[j];
|
||||
element_t *elem = &layer->elements[j];
|
||||
|
||||
elem->render_bounds.x = elem->bounds.x * view->render_bounds.w + view->render_bounds.x;
|
||||
elem->render_bounds.y = elem->bounds.y * view->render_bounds.h + view->render_bounds.y;
|
||||
@ -355,8 +355,7 @@ void video_layout_view_fit_bounds(video_layout_bounds_t bounds)
|
||||
|
||||
for (k = 0; k < elem->components_count; ++k)
|
||||
{
|
||||
component_t *comp;
|
||||
comp = &elem->components[k];
|
||||
component_t *comp = &elem->components[k];
|
||||
|
||||
comp->render_bounds.x = comp->bounds.x * elem->render_bounds.w + elem->render_bounds.x;
|
||||
comp->render_bounds.y = comp->bounds.y * elem->render_bounds.h + elem->render_bounds.y;
|
||||
@ -377,103 +376,101 @@ int video_layout_layer_count(void)
|
||||
|
||||
void video_layout_layer_render(void *video_driver_frame_data, int index)
|
||||
{
|
||||
video_layout_render_info_t *info;
|
||||
const video_layout_render_interface_t *r;
|
||||
layer_t *layer;
|
||||
int i, j;
|
||||
|
||||
info = &video_layout_state->render_info;
|
||||
r = video_layout_state->render;
|
||||
layer = &video_layout_state->view->layers[index];
|
||||
unsigned i, j;
|
||||
video_layout_render_info_t *info = &video_layout_state->render_info;
|
||||
const video_layout_render_interface_t *r = video_layout_state->render;
|
||||
layer_t *layer =
|
||||
&video_layout_state->view->layers[index];
|
||||
|
||||
info->video_driver_frame_data = video_driver_frame_data;
|
||||
info->video_driver_frame_data = video_driver_frame_data;
|
||||
|
||||
r->layer_begin(info);
|
||||
|
||||
for (i = 0; i < layer->elements_count; ++i)
|
||||
{
|
||||
element_t *elem;
|
||||
elem = &layer->elements[i];
|
||||
element_t *elem = &layer->elements[i];
|
||||
|
||||
if (elem->o_bind != -1)
|
||||
elem->state = video_layout_state->io[elem->o_bind].value;
|
||||
|
||||
for (j = 0; j < elem->components_count; ++j)
|
||||
{
|
||||
component_t *comp;
|
||||
comp = &elem->components[j];
|
||||
component_t *comp = &elem->components[j];
|
||||
|
||||
if (comp->enabled_state != -1)
|
||||
{
|
||||
if(comp->enabled_state != elem->state)
|
||||
if (comp->enabled_state != elem->state)
|
||||
continue;
|
||||
}
|
||||
|
||||
info->bounds = comp->render_bounds;
|
||||
info->bounds = comp->render_bounds;
|
||||
info->orientation = comp->orientation;
|
||||
info->color = comp->color;
|
||||
info->color = comp->color;
|
||||
|
||||
switch (comp->type)
|
||||
{
|
||||
case VIDEO_LAYOUT_C_UNKNOWN:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_SCREEN:
|
||||
r->screen(info, comp->attr.screen.index);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_RECT:
|
||||
r->rect(info);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DISK:
|
||||
r->ellipse(info);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_IMAGE:
|
||||
if(!comp->attr.image.loaded)
|
||||
{
|
||||
comp->attr.image.image_idx = video_layout_load_image(comp->attr.image.file);
|
||||
if(comp->attr.image.alpha_file)
|
||||
comp->attr.image.alpha_idx = video_layout_load_image(comp->attr.image.alpha_file);
|
||||
comp->attr.image.loaded = true;
|
||||
}
|
||||
r->image(info,
|
||||
video_layout_state->images[comp->attr.image.image_idx],
|
||||
video_layout_state->images[comp->attr.image.alpha_idx]);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_TEXT:
|
||||
r->text(info, comp->attr.text.string);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_COUNTER:
|
||||
r->counter(info, MIN(elem->state, comp->attr.counter.max_state));
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
||||
r->led_dot(info, 1, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_H5:
|
||||
r->led_dot(info, 5, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_H8:
|
||||
r->led_dot(info, 8, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_7:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_7, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_8_GTS1:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_8_GTS1, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_14:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_14, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_14_SC:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_14_SC, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_16:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_16, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_16_SC:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_16_SC, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_REEL:
|
||||
/* not implemented */
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_UNKNOWN:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_SCREEN:
|
||||
r->screen(info, comp->attr.screen.index);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_RECT:
|
||||
r->rect(info);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DISK:
|
||||
r->ellipse(info);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_IMAGE:
|
||||
if (!comp->attr.image.loaded)
|
||||
{
|
||||
comp->attr.image.image_idx =
|
||||
video_layout_load_image(comp->attr.image.file);
|
||||
if (comp->attr.image.alpha_file)
|
||||
comp->attr.image.alpha_idx =
|
||||
video_layout_load_image(comp->attr.image.alpha_file);
|
||||
comp->attr.image.loaded = true;
|
||||
}
|
||||
r->image(info,
|
||||
video_layout_state->images[comp->attr.image.image_idx],
|
||||
video_layout_state->images[comp->attr.image.alpha_idx]);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_TEXT:
|
||||
r->text(info, comp->attr.text.string);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_COUNTER:
|
||||
r->counter(info, MIN(elem->state,
|
||||
comp->attr.counter.max_state));
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
||||
r->led_dot(info, 1, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_H5:
|
||||
r->led_dot(info, 5, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_H8:
|
||||
r->led_dot(info, 8, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_7:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_7, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_8_GTS1:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_8_GTS1, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_14:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_14, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_14_SC:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_14_SC, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_16:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_16, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_LED_16_SC:
|
||||
r->led_seg(info, VIDEO_LAYOUT_LED_16_SC, elem->state);
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_REEL:
|
||||
/* not implemented */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "component.h"
|
||||
|
||||
void component_init(component_t *comp, comp_type_t type)
|
||||
{
|
||||
comp->type = type;
|
||||
comp->bounds = make_bounds();
|
||||
comp->type = type;
|
||||
comp->bounds = make_bounds();
|
||||
comp->render_bounds = make_bounds_unit();
|
||||
comp->orientation = VIDEO_LAYOUT_ROT0;
|
||||
comp->color = make_color_white();
|
||||
comp->orientation = VIDEO_LAYOUT_ROT0;
|
||||
comp->color = make_color_white();
|
||||
comp->enabled_state = -1;
|
||||
|
||||
switch (comp->type)
|
||||
@ -23,20 +26,20 @@ void component_init(component_t *comp, comp_type_t type)
|
||||
case VIDEO_LAYOUT_C_DISK:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_IMAGE:
|
||||
comp->attr.image.file = NULL;
|
||||
comp->attr.image.alpha_file = NULL;
|
||||
comp->attr.image.image_idx = 0;
|
||||
comp->attr.image.alpha_idx = 0;
|
||||
comp->attr.image.loaded = false;
|
||||
comp->attr.image.file = NULL;
|
||||
comp->attr.image.alpha_file = NULL;
|
||||
comp->attr.image.image_idx = 0;
|
||||
comp->attr.image.alpha_idx = 0;
|
||||
comp->attr.image.loaded = false;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_TEXT:
|
||||
comp->attr.text.string = NULL;
|
||||
comp->attr.text.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
||||
comp->attr.text.string = NULL;
|
||||
comp->attr.text.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_COUNTER:
|
||||
comp->attr.counter.digits = 2;
|
||||
comp->attr.counter.digits = 2;
|
||||
comp->attr.counter.max_state = 999;
|
||||
comp->attr.counter.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
||||
comp->attr.counter.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
||||
break;
|
||||
@ -63,11 +66,11 @@ void component_init(component_t *comp, comp_type_t type)
|
||||
|
||||
void component_copy(component_t *comp, const component_t *src)
|
||||
{
|
||||
comp->type = src->type;
|
||||
comp->bounds = src->bounds;
|
||||
comp->type = src->type;
|
||||
comp->bounds = src->bounds;
|
||||
comp->render_bounds = src->render_bounds;
|
||||
comp->orientation = src->orientation;
|
||||
comp->color = src->color;
|
||||
comp->orientation = src->orientation;
|
||||
comp->color = src->color;
|
||||
comp->enabled_state = src->enabled_state;
|
||||
|
||||
switch (comp->type)
|
||||
@ -75,25 +78,25 @@ void component_copy(component_t *comp, const component_t *src)
|
||||
case VIDEO_LAYOUT_C_UNKNOWN:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_SCREEN:
|
||||
comp->attr.screen.index = src->attr.screen.index;
|
||||
comp->attr.screen.index = src->attr.screen.index;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_RECT:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_DISK:
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_IMAGE:
|
||||
comp->attr.image.file = init_string(src->attr.image.file);
|
||||
comp->attr.image.alpha_file = init_string(src->attr.image.alpha_file);
|
||||
comp->attr.image.image_idx = src->attr.image.image_idx;
|
||||
comp->attr.image.alpha_idx = src->attr.image.alpha_idx;
|
||||
comp->attr.image.loaded = src->attr.image.loaded;
|
||||
comp->attr.image.file = string_init(src->attr.image.file);
|
||||
comp->attr.image.alpha_file = string_init(src->attr.image.alpha_file);
|
||||
comp->attr.image.image_idx = src->attr.image.image_idx;
|
||||
comp->attr.image.alpha_idx = src->attr.image.alpha_idx;
|
||||
comp->attr.image.loaded = src->attr.image.loaded;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_TEXT:
|
||||
comp->attr.text.string = init_string(src->attr.text.string);
|
||||
comp->attr.text.align = src->attr.text.align;
|
||||
comp->attr.text.string = string_init(src->attr.text.string);
|
||||
comp->attr.text.align = src->attr.text.align;
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_COUNTER:
|
||||
comp->attr.counter.digits = src->attr.counter.digits;
|
||||
comp->attr.counter.digits = src->attr.counter.digits;
|
||||
comp->attr.counter.max_state = src->attr.counter.max_state;
|
||||
comp->attr.counter.align = src->attr.counter.align;
|
||||
break;
|
||||
|
@ -1,35 +1,37 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "element.h"
|
||||
|
||||
void element_init(element_t *elem, const char *name, int components_count)
|
||||
{
|
||||
elem->name = init_string(name);
|
||||
elem->state = -1;
|
||||
elem->o_bind = -1;
|
||||
elem->i_bind = -1;
|
||||
elem->i_mask = -1;
|
||||
elem->i_raw = false;
|
||||
elem->name = string_init(name);
|
||||
elem->state = -1;
|
||||
elem->o_bind = -1;
|
||||
elem->i_bind = -1;
|
||||
elem->i_mask = -1;
|
||||
elem->i_raw = false;
|
||||
|
||||
elem->bounds = make_bounds();
|
||||
elem->render_bounds = make_bounds_unit();
|
||||
elem->bounds = make_bounds();
|
||||
elem->render_bounds = make_bounds_unit();
|
||||
|
||||
elem->components = (component_t*)(components_count > 0 ?
|
||||
elem->components = (component_t*)(components_count > 0 ?
|
||||
calloc(components_count, sizeof(component_t)) : NULL);
|
||||
elem->components_count = components_count;
|
||||
}
|
||||
|
||||
void element_copy(element_t *elem, const element_t *src)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
elem->name = init_string(src->name);
|
||||
elem->state = src->state;
|
||||
elem->name = string_init(src->name);
|
||||
elem->state = src->state;
|
||||
|
||||
elem->bounds = src->bounds;
|
||||
elem->render_bounds = src->render_bounds;
|
||||
elem->bounds = src->bounds;
|
||||
elem->render_bounds = src->render_bounds;
|
||||
|
||||
elem->components = (component_t*)(src->components_count > 0 ?
|
||||
elem->components = (component_t*)(src->components_count > 0 ?
|
||||
calloc(src->components_count, sizeof(component_t)) : NULL);
|
||||
|
||||
for (i = 0; i < src->components_count; ++i)
|
||||
@ -49,24 +51,24 @@ void element_deinit(element_t *elem)
|
||||
free(elem->name);
|
||||
}
|
||||
|
||||
void element_apply_orientation(element_t *elem, video_layout_orientation_t orientation)
|
||||
void element_apply_orientation(element_t *elem,
|
||||
video_layout_orientation_t orientation)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < elem->components_count; ++i)
|
||||
{
|
||||
component_t *comp = &elem->components[i];
|
||||
component_t *comp = &elem->components[i];
|
||||
comp->orientation ^= orientation;
|
||||
|
||||
if (orientation & VIDEO_LAYOUT_SWAP_XY)
|
||||
{
|
||||
video_layout_bounds_t b;
|
||||
b = comp->bounds;
|
||||
video_layout_bounds_t b = comp->bounds;
|
||||
|
||||
comp->bounds.x = b.y;
|
||||
comp->bounds.y = b.x;
|
||||
comp->bounds.w = b.h;
|
||||
comp->bounds.h = b.w;
|
||||
comp->bounds.x = b.y;
|
||||
comp->bounds.y = b.x;
|
||||
comp->bounds.w = b.h;
|
||||
comp->bounds.h = b.w;
|
||||
}
|
||||
|
||||
if (orientation & VIDEO_LAYOUT_FLIP_X)
|
||||
|
@ -4,17 +4,6 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include "internal.h"
|
||||
|
||||
char *init_string(const char *src)
|
||||
{
|
||||
return src ? strdup(src) : NULL;
|
||||
}
|
||||
|
||||
void set_string(char **string, const char *src)
|
||||
{
|
||||
free(*string);
|
||||
*string = src ? strdup(src) : NULL;
|
||||
}
|
||||
|
||||
bool vec_size(void **target, size_t elem_size, int count)
|
||||
{
|
||||
const int seg = 4;
|
||||
@ -57,9 +46,7 @@ int get_int(const char *str)
|
||||
res = (int)hex;
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(str, "%i", &res);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
#ifndef VIDEO_LAYOUT_INTERNAL_H
|
||||
#define VIDEO_LAYOUT_INTERNAL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <boolean.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
char *init_string (const char *src);
|
||||
void set_string (char **string, const char *src);
|
||||
bool vec_size (void **target, size_t elem_size, int count);
|
||||
|
||||
bool is_decimal (const char *str);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <formats/rxml.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "../../verbosity.h"
|
||||
|
||||
@ -67,7 +68,7 @@ static comp_type_t comp_type_from_str(const char *s)
|
||||
|
||||
for (i = 2; i < ARRAY_SIZE(comp_type_str); ++i)
|
||||
{
|
||||
if (strcmp(s, comp_type_str[i]) == 0)
|
||||
if (string_is_equal(s, comp_type_str[i]))
|
||||
return (comp_type_t)(int)i;
|
||||
}
|
||||
|
||||
@ -136,31 +137,29 @@ static video_layout_orientation_t parse_orientation(scope_t *scope, rxml_node_t
|
||||
|
||||
if ((prop = scope_eval(scope, rxml_node_attrib(node, "rotate"))))
|
||||
{
|
||||
if (strcmp(prop, "90") == 0)
|
||||
if (string_is_equal(prop, "90"))
|
||||
result = VIDEO_LAYOUT_ROT90;
|
||||
|
||||
else if (strcmp(prop, "180") == 0)
|
||||
else if (string_is_equal(prop, "180"))
|
||||
result = VIDEO_LAYOUT_ROT180;
|
||||
|
||||
else if (strcmp(prop, "270") == 0)
|
||||
else if (string_is_equal(prop, "270"))
|
||||
result = VIDEO_LAYOUT_ROT270;
|
||||
}
|
||||
|
||||
if ((prop = scope_eval(scope, rxml_node_attrib(node, "swapxy"))))
|
||||
{
|
||||
if (strcmp(prop, "no") != 0)
|
||||
if (!string_is_equal(prop, "no"))
|
||||
result ^= VIDEO_LAYOUT_SWAP_XY;
|
||||
}
|
||||
|
||||
if ((prop = scope_eval(scope, rxml_node_attrib(node, "flipx"))))
|
||||
{
|
||||
if (strcmp(prop, "no") != 0)
|
||||
if (!string_is_equal(prop, "no"))
|
||||
result ^= VIDEO_LAYOUT_FLIP_X;
|
||||
}
|
||||
|
||||
if ((prop = scope_eval(scope, rxml_node_attrib(node, "flipy"))))
|
||||
{
|
||||
if (strcmp(prop, "no") != 0)
|
||||
if (!string_is_equal(prop, "no"))
|
||||
result ^= VIDEO_LAYOUT_FLIP_Y;
|
||||
}
|
||||
|
||||
@ -234,10 +233,9 @@ static bool load_component(scope_t *scope, component_t *comp, rxml_node_t *node)
|
||||
|
||||
for (n = node->children; n; n = n->next)
|
||||
{
|
||||
if (strcmp(n->name, "bounds") == 0)
|
||||
if (string_is_equal(n->name, "bounds"))
|
||||
comp->bounds = parse_bounds(scope, n);
|
||||
|
||||
else if (strcmp(n->name, "color") == 0)
|
||||
else if (string_is_equal(n->name, "color"))
|
||||
comp->color = parse_color(scope, n);
|
||||
}
|
||||
|
||||
@ -258,10 +256,10 @@ static bool load_component(scope_t *scope, component_t *comp, rxml_node_t *node)
|
||||
RARCH_LOG("video_layout: invalid component <%s />, missing 'file' attribute\n", node->name);
|
||||
result = false;
|
||||
}
|
||||
set_string(&comp->attr.image.file, scope_eval(scope, attr));
|
||||
string_set(&comp->attr.image.file, scope_eval(scope, attr));
|
||||
|
||||
if ((attr = rxml_node_attrib(node, "alphafile")))
|
||||
set_string(&comp->attr.image.alpha_file, scope_eval(scope, attr));
|
||||
string_set(&comp->attr.image.alpha_file, scope_eval(scope, attr));
|
||||
}
|
||||
break;
|
||||
case VIDEO_LAYOUT_C_TEXT:
|
||||
@ -271,7 +269,7 @@ static bool load_component(scope_t *scope, component_t *comp, rxml_node_t *node)
|
||||
RARCH_LOG("video_layout: invalid component <%s />, missing 'string' attribute\n", node->name);
|
||||
result = false;
|
||||
}
|
||||
set_string(&comp->attr.text.string, scope_eval(scope, attr));
|
||||
string_set(&comp->attr.text.string, scope_eval(scope, attr));
|
||||
|
||||
if ((attr = rxml_node_attrib(node, "align")))
|
||||
comp->attr.text.align = (video_layout_text_align_t)get_int(scope_eval(scope, attr));
|
||||
@ -463,17 +461,16 @@ static bool load_view(scope_t *scope, view_t *view, rxml_node_t *node, bool is_n
|
||||
video_layout_bounds_t n_bounds;
|
||||
video_layout_orientation_t n_orient;
|
||||
|
||||
if (strcmp(n->name, "param") == 0)
|
||||
if (string_is_equal(n->name, "param"))
|
||||
{
|
||||
if (!load_param(scope, n, true))
|
||||
result = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (strcmp(n->name, "bounds") == 0)
|
||||
else if (string_is_equal(n->name, "bounds"))
|
||||
{
|
||||
view->bounds = parse_bounds(scope, n);
|
||||
has_bounds = true;
|
||||
has_bounds = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -483,17 +480,15 @@ static bool load_view(scope_t *scope, view_t *view, rxml_node_t *node, bool is_n
|
||||
|
||||
for (o = n->children; o; o = o->next)
|
||||
{
|
||||
if (strcmp(o->name, "color") == 0)
|
||||
if (string_is_equal(o->name, "color"))
|
||||
n_color = parse_color(scope, o);
|
||||
|
||||
else if (strcmp(o->name, "bounds") == 0)
|
||||
else if (string_is_equal(o->name, "bounds"))
|
||||
n_bounds = parse_bounds(scope, o);
|
||||
|
||||
else if (strcmp(o->name, "orientation") == 0)
|
||||
else if (string_is_equal(o->name, "orientation"))
|
||||
n_orient = parse_orientation(scope, o);
|
||||
}
|
||||
|
||||
if (strcmp(n->name, "group") == 0)
|
||||
if (string_is_equal(n->name, "group"))
|
||||
{
|
||||
const char *ref;
|
||||
if ((ref = rxml_node_attrib(n, "ref")))
|
||||
@ -516,7 +511,7 @@ static bool load_view(scope_t *scope, view_t *view, rxml_node_t *node, bool is_n
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(n->name, "repeat") == 0)
|
||||
else if (string_is_equal(n->name, "repeat"))
|
||||
{
|
||||
const char *count_s;
|
||||
int count;
|
||||
@ -534,7 +529,7 @@ static bool load_view(scope_t *scope, view_t *view, rxml_node_t *node, bool is_n
|
||||
|
||||
for (o = n->children; o; o = o->next)
|
||||
{
|
||||
if (strcmp(o->name, "param") == 0)
|
||||
if (string_is_equal(o->name, "param"))
|
||||
{
|
||||
if (!load_param(scope, o, true))
|
||||
result = false;
|
||||
@ -561,13 +556,10 @@ static bool load_view(scope_t *scope, view_t *view, rxml_node_t *node, bool is_n
|
||||
|
||||
else /* element */
|
||||
{
|
||||
layer_t *layer;
|
||||
element_t *elem;
|
||||
layer_t *layer = view_emplace_layer(view, n->name);
|
||||
element_t *elem = layer_add_element(layer);
|
||||
|
||||
layer = view_emplace_layer(view, n->name);
|
||||
elem = layer_add_element(layer);
|
||||
|
||||
if (strcmp(n->name, "screen") == 0)
|
||||
if (string_is_equal(n->name, "screen"))
|
||||
{
|
||||
if (!load_screen(scope, elem, n))
|
||||
result = false;
|
||||
@ -649,43 +641,40 @@ static bool load_top_level(scope_t *scope, int *view_count, rxml_node_t *root)
|
||||
|
||||
for (node = root->children; node; node = node->next)
|
||||
{
|
||||
if (strcmp(node->name, "param") == 0)
|
||||
if (string_is_equal(node->name, "param"))
|
||||
{
|
||||
if (!load_param(scope, node, false))
|
||||
result = false;
|
||||
}
|
||||
|
||||
else if (strcmp(node->name, "element") == 0)
|
||||
else if (string_is_equal(node->name, "element"))
|
||||
{
|
||||
if (!load_element(scope, node))
|
||||
result = false;
|
||||
}
|
||||
|
||||
else if (strcmp(node->name, "group") == 0)
|
||||
else if (string_is_equal(node->name, "group"))
|
||||
{
|
||||
if (!load_group(scope, node))
|
||||
result = false;
|
||||
}
|
||||
|
||||
else if (strcmp(node->name, "view") == 0)
|
||||
else if (string_is_equal(node->name, "view"))
|
||||
++(*view_count);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool load_views(scope_t *scope, view_array_t *view_array, rxml_node_t *root)
|
||||
static bool load_views(scope_t *scope, view_array_t *view_array,
|
||||
rxml_node_t *root)
|
||||
{
|
||||
rxml_node_t *node;
|
||||
bool result = true;
|
||||
int i = 0;
|
||||
rxml_node_t *node = NULL;
|
||||
bool result = true;
|
||||
unsigned i = 0;
|
||||
|
||||
for (node = root->children; node; node = node->next)
|
||||
{
|
||||
if (strcmp(node->name, "view") == 0)
|
||||
if (string_is_equal(node->name, "view"))
|
||||
{
|
||||
view_t *view;
|
||||
view = &view_array->views[i];
|
||||
view_t *view = &view_array->views[i];
|
||||
|
||||
scope_push(scope);
|
||||
|
||||
@ -705,11 +694,11 @@ static bool load_views(scope_t *scope, view_array_t *view_array, rxml_node_t *ro
|
||||
return result;
|
||||
}
|
||||
|
||||
bool load(view_array_t *view_array, rxml_document_t *doc)
|
||||
bool video_layout_load_internal(view_array_t *view_array, rxml_document_t *doc)
|
||||
{
|
||||
bool result;
|
||||
scope_t scope;
|
||||
int view_count;
|
||||
bool result = true;
|
||||
rxml_node_t *root = rxml_root_node(doc);
|
||||
|
||||
if (strcmp(root->name, "mamelayout") ||
|
||||
@ -719,8 +708,6 @@ bool load(view_array_t *view_array, rxml_document_t *doc)
|
||||
return false;
|
||||
}
|
||||
|
||||
result = false;
|
||||
|
||||
scope_init(&scope);
|
||||
init_device_params(&scope);
|
||||
init_screen_params(&scope, 0);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "scope.h"
|
||||
|
||||
@ -43,7 +44,7 @@ static param_t *param_find(scope_t *scope, const char *name, int level)
|
||||
|
||||
while (param && param->level >= level)
|
||||
{
|
||||
if (strcmp(param->name, name) == 0)
|
||||
if (string_is_equal(param->name, name))
|
||||
return param;
|
||||
param = param->prev;
|
||||
}
|
||||
@ -140,7 +141,7 @@ void scope_repeat(scope_t *scope)
|
||||
sprintf(tmp, "%d", gen->value.val_int);
|
||||
}
|
||||
|
||||
set_string(¶m->value, tmp);
|
||||
string_set(¶m->value, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,8 +150,8 @@ void scope_repeat(scope_t *scope)
|
||||
void scope_param(scope_t *scope, const char *name, const char *value)
|
||||
{
|
||||
param_t *param;
|
||||
char *eval_name = init_string(scope_eval(scope, name));
|
||||
char *eval_value = init_string(scope_eval(scope, value));
|
||||
char *eval_name = string_init(scope_eval(scope, name));
|
||||
char *eval_value = string_init(scope_eval(scope, value));
|
||||
|
||||
if ((param = param_find(scope, eval_name, scope->level)))
|
||||
{
|
||||
@ -159,8 +160,8 @@ void scope_param(scope_t *scope, const char *name, const char *value)
|
||||
}
|
||||
else
|
||||
{
|
||||
param = (param_t*)malloc(sizeof(param_t));
|
||||
param->name = init_string(name);
|
||||
param = (param_t*)malloc(sizeof(param_t));
|
||||
param->name = string_init(name);
|
||||
param->value = eval_value;
|
||||
param->generator = NULL;
|
||||
param->level = scope->level;
|
||||
@ -171,13 +172,15 @@ void scope_param(scope_t *scope, const char *name, const char *value)
|
||||
free(eval_name);
|
||||
}
|
||||
|
||||
void scope_generator(scope_t *scope, const char *name, const char *start, const char *increment, const char *lshift, const char *rshift)
|
||||
void scope_generator(scope_t *scope, const char *name,
|
||||
const char *start, const char *increment,
|
||||
const char *lshift, const char *rshift)
|
||||
{
|
||||
char *e_val;
|
||||
char *e_inc;
|
||||
generator_t *gen;
|
||||
param_t *param;
|
||||
char *e_name = init_string(scope_eval(scope, name));
|
||||
char *e_name = string_init(scope_eval(scope, name));
|
||||
|
||||
if (param_find(scope, e_name, scope->level))
|
||||
{
|
||||
@ -185,39 +188,39 @@ void scope_generator(scope_t *scope, const char *name, const char *start, const
|
||||
return;
|
||||
}
|
||||
|
||||
e_val = init_string(scope_eval(scope, start));
|
||||
e_inc = init_string(scope_eval(scope, increment));
|
||||
e_val = string_init(scope_eval(scope, start));
|
||||
e_inc = string_init(scope_eval(scope, increment));
|
||||
|
||||
gen = (generator_t*)malloc(sizeof(generator_t));
|
||||
gen = (generator_t*)malloc(sizeof(generator_t));
|
||||
|
||||
param = (param_t*)malloc(sizeof(param_t));
|
||||
param->name = init_string(e_name);
|
||||
param->value = init_string(e_val);
|
||||
param = (param_t*)malloc(sizeof(param_t));
|
||||
param->name = string_init(e_name);
|
||||
param->value = string_init(e_val);
|
||||
param->generator = gen;
|
||||
param->level = scope->level;
|
||||
param->prev = scope->param;
|
||||
scope->param = param;
|
||||
param->level = scope->level;
|
||||
param->prev = scope->param;
|
||||
scope->param = param;
|
||||
|
||||
gen->is_decimal = is_decimal(e_val) | is_decimal(e_inc);
|
||||
gen->is_decimal = is_decimal(e_val) | is_decimal(e_inc);
|
||||
|
||||
if (gen->is_decimal)
|
||||
{
|
||||
gen->value.val_dec = get_dec(e_val);
|
||||
gen->value.val_dec = get_dec(e_val);
|
||||
gen->increment.val_dec = get_dec(e_inc);
|
||||
}
|
||||
else
|
||||
{
|
||||
gen->value.val_int = get_int(e_val);
|
||||
gen->value.val_int = get_int(e_val);
|
||||
gen->increment.val_int = get_int(e_inc);
|
||||
}
|
||||
|
||||
gen->shift = 0;
|
||||
gen->shift = 0;
|
||||
|
||||
if (lshift)
|
||||
gen->shift += get_int(scope_eval(scope, lshift));
|
||||
gen->shift += get_int(scope_eval(scope, lshift));
|
||||
|
||||
if (rshift)
|
||||
gen->shift -= get_int(scope_eval(scope, rshift));
|
||||
gen->shift -= get_int(scope_eval(scope, rshift));
|
||||
|
||||
free(e_inc);
|
||||
free(e_val);
|
||||
@ -234,12 +237,11 @@ const char *scope_eval(scope_t *scope, const char *src)
|
||||
return NULL;
|
||||
|
||||
scope->eval[0] = '\0';
|
||||
next = src;
|
||||
next = src;
|
||||
|
||||
while (next[0] != '\0')
|
||||
{
|
||||
const char* cur;
|
||||
cur = next;
|
||||
const char *cur = next;
|
||||
|
||||
if ((in_var = (next[0] == '~')))
|
||||
++cur;
|
||||
@ -248,8 +250,7 @@ const char *scope_eval(scope_t *scope, const char *src)
|
||||
|
||||
if (next && next != cur)
|
||||
{
|
||||
size_t len;
|
||||
len = next - cur;
|
||||
size_t len = next - cur;
|
||||
|
||||
if (in_var)
|
||||
{
|
||||
@ -267,9 +268,7 @@ const char *scope_eval(scope_t *scope, const char *src)
|
||||
++next;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncat(scope->eval, cur, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -287,7 +286,8 @@ element_t *scope_add_element(scope_t *scope)
|
||||
{
|
||||
element_t *elem;
|
||||
|
||||
vec_size((void**)&scope->elements, sizeof(element_t), ++scope->elements_count);
|
||||
vec_size((void**)&scope->elements,
|
||||
sizeof(element_t), ++scope->elements_count);
|
||||
|
||||
elem = &scope->elements[scope->elements_count - 1];
|
||||
element_init(elem, NULL, 0);
|
||||
@ -297,11 +297,11 @@ element_t *scope_add_element(scope_t *scope)
|
||||
|
||||
element_t *scope_find_element(scope_t *scope, const char *name)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < scope->elements_count; ++i)
|
||||
{
|
||||
if (strcmp(name, scope->elements[i].name) == 0)
|
||||
if (string_is_equal(name, scope->elements[i].name))
|
||||
return &scope->elements[i];
|
||||
}
|
||||
|
||||
@ -322,11 +322,11 @@ view_t *scope_add_group(scope_t *scope)
|
||||
|
||||
view_t *scope_find_group(scope_t *scope, const char *name)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < scope->groups_count; ++i)
|
||||
{
|
||||
if (strcmp(name, scope->groups[i].name) == 0)
|
||||
if (string_is_equal(name, scope->groups[i].name))
|
||||
return &scope->groups[i];
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "view.h"
|
||||
|
||||
void layer_init(layer_t *layer, const char *name)
|
||||
{
|
||||
layer->name = init_string(name);
|
||||
layer->blend = VIDEO_LAYOUT_BLEND_ALPHA;
|
||||
layer->elements = NULL;
|
||||
layer->name = string_init(name);
|
||||
layer->blend = VIDEO_LAYOUT_BLEND_ALPHA;
|
||||
layer->elements = NULL;
|
||||
layer->elements_count = 0;
|
||||
}
|
||||
|
||||
void layer_deinit(layer_t *layer)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < layer->elements_count; ++i)
|
||||
element_deinit(&layer->elements[i]);
|
||||
@ -37,7 +39,7 @@ element_t *layer_add_element(layer_t *layer)
|
||||
|
||||
void view_init(view_t *view, const char *name)
|
||||
{
|
||||
view->name = init_string(name);
|
||||
view->name = string_init(name);
|
||||
view->bounds = make_bounds();
|
||||
view->render_bounds = make_bounds_unit();
|
||||
view->layers = NULL;
|
||||
@ -48,7 +50,7 @@ void view_init(view_t *view, const char *name)
|
||||
|
||||
void view_deinit(view_t *view)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
free(view->screens);
|
||||
|
||||
@ -61,11 +63,11 @@ void view_deinit(view_t *view)
|
||||
|
||||
layer_t *view_find_layer(view_t *view, const char *name)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < view->layers_count; ++i)
|
||||
{
|
||||
if (strcmp(name, view->layers[i].name) == 0)
|
||||
if (string_is_equal(name, view->layers[i].name))
|
||||
return &view->layers[i];
|
||||
}
|
||||
|
||||
@ -91,7 +93,7 @@ void view_sort_layers(view_t *view)
|
||||
{
|
||||
layer_t sorted[6];
|
||||
layer_t *layer;
|
||||
int i = 0;
|
||||
unsigned i = 0;
|
||||
|
||||
/* retroarch frame *= screen's color */
|
||||
if ((layer = view_find_layer(view, "screen")))
|
||||
@ -143,7 +145,7 @@ void view_sort_layers(view_t *view)
|
||||
void view_normalize(view_t *view)
|
||||
{
|
||||
video_layout_bounds_t dim;
|
||||
int i, j;
|
||||
unsigned i, j;
|
||||
|
||||
if (bounds_valid(&view->bounds))
|
||||
{
|
||||
@ -167,9 +169,7 @@ void view_normalize(view_t *view)
|
||||
view->bounds.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dim = view->bounds = make_bounds_unit();
|
||||
}
|
||||
|
||||
for (i = 0; i < view->layers_count; ++i)
|
||||
{
|
||||
@ -182,13 +182,9 @@ void view_normalize(view_t *view)
|
||||
elem = &layer->elements[j];
|
||||
|
||||
if (bounds_valid(&elem->bounds))
|
||||
{
|
||||
bounds_scale(&elem->bounds, &dim);
|
||||
}
|
||||
else
|
||||
{
|
||||
elem->bounds = dim;
|
||||
}
|
||||
|
||||
elem->bounds.x -= dim.x;
|
||||
elem->bounds.y -= dim.y;
|
||||
@ -198,7 +194,7 @@ void view_normalize(view_t *view)
|
||||
|
||||
void view_count_screens(view_t *view)
|
||||
{
|
||||
int i, j, k;
|
||||
unsigned i, j, k;
|
||||
int idx = -1;
|
||||
|
||||
for (i = 0; i < view->layers_count; ++i)
|
||||
@ -224,7 +220,8 @@ void view_count_screens(view_t *view)
|
||||
|
||||
if ((++idx))
|
||||
{
|
||||
view->screens = (video_layout_bounds_t*)calloc(idx, sizeof(video_layout_bounds_t));
|
||||
view->screens = (video_layout_bounds_t*)
|
||||
calloc(idx, sizeof(video_layout_bounds_t));
|
||||
view->screens_count = idx;
|
||||
}
|
||||
}
|
||||
@ -238,7 +235,7 @@ void view_array_init(view_array_t *view_array, int views_count)
|
||||
|
||||
void view_array_deinit(view_array_t *view_array)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < view_array->views_count; ++i)
|
||||
view_deinit(&view_array->views[i]);
|
||||
@ -249,11 +246,11 @@ void view_array_deinit(view_array_t *view_array)
|
||||
|
||||
view_t *view_array_find(view_array_t *view_array, const char *name)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < view_array->views_count; ++i)
|
||||
{
|
||||
if (strcmp(name, view_array->views[i].name) == 0)
|
||||
if (string_is_equal(name, view_array->views[i].name))
|
||||
return &view_array->views[i];
|
||||
}
|
||||
return NULL;
|
||||
|
@ -146,6 +146,10 @@ unsigned string_to_unsigned(const char *str);
|
||||
* Returns 0 if string is invalid */
|
||||
unsigned string_hex_to_unsigned(const char *str);
|
||||
|
||||
char *string_init(const char *src);
|
||||
|
||||
void string_set(char **string, const char *src);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,18 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <encodings/utf.h>
|
||||
|
||||
char *string_init(const char *src)
|
||||
{
|
||||
return src ? strdup(src) : NULL;
|
||||
}
|
||||
|
||||
void string_set(char **string, const char *src)
|
||||
{
|
||||
free(*string);
|
||||
*string = src ? strdup(src) : NULL;
|
||||
}
|
||||
|
||||
|
||||
char *string_to_upper(char *s)
|
||||
{
|
||||
char *cs = (char *)s;
|
||||
|
Loading…
x
Reference in New Issue
Block a user