diff --git a/Makefile.common b/Makefile.common
index b58b09438d..5022527150 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -141,6 +141,7 @@ OBJ += frontend/frontend.o \
audio/audio_driver.o \
input/input_driver.o \
input/input_hid_driver.o \
+ gfx/video_common.o \
gfx/video_driver.o \
gfx/video_pixel_converter.o \
gfx/video_viewport.o \
diff --git a/gfx/drivers/gl_common.c b/gfx/drivers/gl_common.c
index ca2beefeaa..fa81ad4e3a 100644
--- a/gfx/drivers/gl_common.c
+++ b/gfx/drivers/gl_common.c
@@ -157,87 +157,3 @@ bool gl_load_luts(const struct video_shader *shader,
glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
-
-static INLINE bool realloc_checked(void **ptr, size_t size)
-{
- void *nptr;
-
- if (*ptr)
- nptr = realloc(*ptr, size);
- else
- nptr = malloc(size);
-
- if (nptr)
- *ptr = nptr;
-
- return *ptr == nptr;
-}
-
-bool gl_coord_array_add(gfx_coord_array_t *ca, const gfx_coords_t *coords, unsigned count)
-{
- size_t base_size, offset;
- bool success = false;
-
- count = min(count, coords->vertices);
-
- if (ca->coords.vertices + count >= ca->allocated)
- {
- unsigned alloc_size = next_pow2(ca->coords.vertices + count);
- size_t base_size = sizeof(GLfloat) * alloc_size;
-
- bool vert_ok = realloc_checked((void**)&ca->coords.vertex, 2 * base_size);
- bool color_ok = realloc_checked((void**)&ca->coords.color, 4 * base_size);
- bool tex_ok = realloc_checked((void**)&ca->coords.tex_coord, 2 * base_size);
- bool lut_ok = realloc_checked((void**)&ca->coords.lut_tex_coord, 2 * base_size);
-
- if (vert_ok && color_ok && tex_ok && lut_ok)
- {
- ca->allocated = alloc_size;
- success = true;
- }
- }
- else
- success = true;
-
- if (!success)
- {
- RARCH_WARN("Allocation failed.");
- return false;
- }
-
- base_size = count * sizeof(GLfloat);
- offset = ca->coords.vertices;
-
- /* XXX: i wish we used interlaced arrays so we could call memcpy only once */
- memcpy(ca->coords.vertex + offset * 2, coords->vertex, base_size * 2);
- memcpy(ca->coords.color + offset * 4, coords->color, base_size * 4);
- memcpy(ca->coords.tex_coord + offset * 2, coords->tex_coord, base_size * 2);
- memcpy(ca->coords.lut_tex_coord + offset * 2, coords->lut_tex_coord, base_size * 2);
-
- ca->coords.vertices += count;
-
- return true;
-}
-
-void gl_coord_array_free(gfx_coord_array_t *ca)
-{
- if (!ca->allocated)
- return;
-
- if (ca->coords.vertex)
- free(ca->coords.vertex);
- if (ca->coords.color)
- free(ca->coords.color);
- if (ca->coords.tex_coord)
- free(ca->coords.tex_coord);
- if (ca->coords.lut_tex_coord)
- free(ca->coords.lut_tex_coord);
-
- ca->coords.vertex = NULL;
- ca->coords.color = NULL;
- ca->coords.tex_coord = NULL;
- ca->coords.lut_tex_coord = NULL;
-
- ca->coords.vertices = 0;
- ca->allocated = 0;
-}
diff --git a/gfx/drivers/gl_common.h b/gfx/drivers/gl_common.h
index 067b0735c5..161aff5f8c 100644
--- a/gfx/drivers/gl_common.h
+++ b/gfx/drivers/gl_common.h
@@ -360,9 +360,6 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type)
return 0;
}
-bool gl_coord_array_add(gfx_coord_array_t *ca, const gfx_coords_t *coords, unsigned count);
-void gl_coord_array_free(gfx_coord_array_t *ca);
-
void gl_ff_vertex(const void *data);
void gl_ff_matrix(const void *data);
diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c
index de4ea93fa2..c52b720745 100644
--- a/gfx/drivers_font/gl_raster_font.c
+++ b/gfx/drivers_font/gl_raster_font.c
@@ -251,7 +251,7 @@ static void gl_raster_font_render_line(
coords.lut_tex_coord = font_lut_tex_coord;
if (font->block)
- gl_coord_array_add(&font->block->carr, &coords, coords.vertices);
+ gfx_coord_array_add(&font->block->carr, &coords, coords.vertices);
else
gl_raster_font_draw_vertices(gl, &coords);
diff --git a/gfx/video_common.c b/gfx/video_common.c
new file mode 100644
index 0000000000..76e4ea8914
--- /dev/null
+++ b/gfx/video_common.c
@@ -0,0 +1,103 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2015 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#include
+
+#include
+#include
+
+#include "video_common.h"
+
+static INLINE bool realloc_checked(void **ptr, size_t size)
+{
+ void *nptr;
+
+ if (*ptr)
+ nptr = realloc(*ptr, size);
+ else
+ nptr = malloc(size);
+
+ if (nptr)
+ *ptr = nptr;
+
+ return *ptr == nptr;
+}
+
+bool gfx_coord_array_add(gfx_coord_array_t *ca, const gfx_coords_t *coords, unsigned count)
+{
+ size_t base_size, offset;
+ bool success = false;
+
+ count = min(count, coords->vertices);
+
+ if (ca->coords.vertices + count >= ca->allocated)
+ {
+ unsigned alloc_size = next_pow2(ca->coords.vertices + count);
+ size_t base_size = sizeof(float) * alloc_size;
+
+ bool vert_ok = realloc_checked((void**)&ca->coords.vertex, 2 * base_size);
+ bool color_ok = realloc_checked((void**)&ca->coords.color, 4 * base_size);
+ bool tex_ok = realloc_checked((void**)&ca->coords.tex_coord, 2 * base_size);
+ bool lut_ok = realloc_checked((void**)&ca->coords.lut_tex_coord, 2 * base_size);
+
+ if (vert_ok && color_ok && tex_ok && lut_ok)
+ {
+ ca->allocated = alloc_size;
+ success = true;
+ }
+ }
+ else
+ success = true;
+
+ if (!success) /* Allocation failed. */
+ return false;
+
+ base_size = count * sizeof(float);
+ offset = ca->coords.vertices;
+
+ /* XXX: i wish we used interlaced arrays so we could call memcpy only once */
+ memcpy(ca->coords.vertex + offset * 2, coords->vertex, base_size * 2);
+ memcpy(ca->coords.color + offset * 4, coords->color, base_size * 4);
+ memcpy(ca->coords.tex_coord + offset * 2, coords->tex_coord, base_size * 2);
+ memcpy(ca->coords.lut_tex_coord + offset * 2, coords->lut_tex_coord, base_size * 2);
+
+ ca->coords.vertices += count;
+
+ return true;
+}
+
+void gfx_coord_array_free(gfx_coord_array_t *ca)
+{
+ if (!ca->allocated)
+ return;
+
+ if (ca->coords.vertex)
+ free(ca->coords.vertex);
+ if (ca->coords.color)
+ free(ca->coords.color);
+ if (ca->coords.tex_coord)
+ free(ca->coords.tex_coord);
+ if (ca->coords.lut_tex_coord)
+ free(ca->coords.lut_tex_coord);
+
+ ca->coords.vertex = NULL;
+ ca->coords.color = NULL;
+ ca->coords.tex_coord = NULL;
+ ca->coords.lut_tex_coord = NULL;
+
+ ca->coords.vertices = 0;
+ ca->allocated = 0;
+}
diff --git a/gfx/video_common.h b/gfx/video_common.h
index 751ea8efe2..6fe7c7de58 100644
--- a/gfx/video_common.h
+++ b/gfx/video_common.h
@@ -20,6 +20,8 @@
#include
#include
+#include
+
struct gfx_fbo_rect
{
unsigned img_width;
@@ -78,4 +80,9 @@ typedef struct gfx_raster_block
gfx_coord_array_t carr;
} gfx_font_raster_block_t;
+bool gfx_coord_array_add(gfx_coord_array_t *ca,
+ const gfx_coords_t *coords, unsigned count);
+
+void gfx_coord_array_free(gfx_coord_array_t *ca);
+
#endif
diff --git a/griffin/griffin.c b/griffin/griffin.c
index 7b78ff8da2..cd740d2b2a 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -505,6 +505,7 @@ AUDIO
DRIVERS
============================================================ */
#include "../gfx/video_driver.c"
+#include "../gfx/video_common.c"
#include "../gfx/video_pixel_converter.c"
#include "../gfx/video_viewport.c"
#include "../input/input_driver.c"
diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c
index 9243fe49d0..c326fb2503 100644
--- a/menu/drivers/glui.c
+++ b/menu/drivers/glui.c
@@ -577,7 +577,7 @@ static void glui_free(void *data)
if (!glui || !menu)
return;
- gl_coord_array_free(&glui->list_block.carr);
+ gfx_coord_array_free(&glui->list_block.carr);
gl = (gl_t*)video_driver_get_ptr(NULL);
diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c
index f544c4b11d..f2ac13de5f 100644
--- a/menu/drivers/xmb.c
+++ b/menu/drivers/xmb.c
@@ -1937,7 +1937,7 @@ static void xmb_free(void *data)
file_list_free(xmb->horizontal_list);
xmb->horizontal_list = NULL;
- gl_coord_array_free(&xmb->raster_block.carr);
+ gfx_coord_array_free(&xmb->raster_block.carr);
if (menu->userdata)
free(menu->userdata);