(mali) Convert to new egl common api

This commit is contained in:
Higor Eurípedes 2015-12-08 17:32:08 -03:00
parent 9e90efacbb
commit c2d4da4660
2 changed files with 37 additions and 16 deletions

View File

@ -29,18 +29,27 @@
#include "../common/egl_common.h" #include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
struct fbdev_window native_window; typedef struct {
static bool g_resize; egl_ctx_data_t egl;
static unsigned g_width, g_height;
fbdev_window native_window;
bool resize;
unsigned width, height;
} mali_ctx_data_t;
static void gfx_ctx_mali_fbdev_destroy(void *data) static void gfx_ctx_mali_fbdev_destroy(void *data)
{ {
int fb; int fb;
RFILE *fd; RFILE *fd;
mali_ctx_data_t *mali = (mali_ctx_data_t*)data;
if (mali)
{
egl_destroy(data); egl_destroy(data);
g_resize = false; mali->resize = false;
free(mali);
}
/* Clear framebuffer and set cursor on again */ /* Clear framebuffer and set cursor on again */
fd = retro_fopen("/dev/tty", RFILE_MODE_READ_WRITE, -1); fd = retro_fopen("/dev/tty", RFILE_MODE_READ_WRITE, -1);
@ -55,10 +64,10 @@ static void gfx_ctx_mali_fbdev_destroy(void *data)
static void gfx_ctx_mali_fbdev_get_video_size(void *data, static void gfx_ctx_mali_fbdev_get_video_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
(void)data; mali_ctx_data_t *mali = (mali_ctx_data_t*)data;
*width = g_width; *width = mali->width;
*height = g_height; *height = mali->height;
} }
static void *gfx_ctx_mali_fbdev_init(void *video_driver) static void *gfx_ctx_mali_fbdev_init(void *video_driver)
@ -76,19 +85,24 @@ static void *gfx_ctx_mali_fbdev_init(void *video_driver)
EGL_NONE EGL_NONE
}; };
mali_ctx_data_t *mali = (mali_ctx_data_t*)calloc(1, sizeof(*mali));
if (!mali)
return NULL;
egl_install_sighandlers(); egl_install_sighandlers();
/* Disable cursor blinking so it's not visible in RetroArch. */ /* Disable cursor blinking so it's not visible in RetroArch. */
system("setterm -cursor off"); system("setterm -cursor off");
if (!egl_init_context(EGL_DEFAULT_DISPLAY, if (!egl_init_context(mali, EGL_DEFAULT_DISPLAY,
&major, &minor, &n, attribs)) &major, &minor, &n, attribs))
{ {
egl_report_error(); egl_report_error();
goto error; goto error;
} }
return (void*)"mali"; return mali;
error: error:
RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError()); RARCH_ERR("[Mali fbdev]: EGL error: %d.\n", eglGetError());
@ -146,6 +160,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */
EGL_NONE EGL_NONE
}; };
mali_ctx_data_t *mali = (mali_ctx_data_t*)data;
RFILE *fd = retro_fopen("/dev/fb0", RFILE_MODE_READ_WRITE, -1); RFILE *fd = retro_fopen("/dev/fb0", RFILE_MODE_READ_WRITE, -1);
int fb = retro_get_fd(fd); int fb = retro_get_fd(fd);
@ -159,19 +174,19 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
width = vinfo.xres; width = vinfo.xres;
height = vinfo.yres; height = vinfo.yres;
g_width = width; mali->width = width;
g_height = height; mali->height = height;
native_window.width = vinfo.xres; mali->native_window.width = vinfo.xres;
native_window.height = vinfo.yres; mali->native_window.height = vinfo.yres;
if (!egl_create_context(attribs)) if (!egl_create_context(mali, attribs))
{ {
egl_report_error(); egl_report_error();
goto error; goto error;
} }
if (!egl_create_surface(&native_window)) if (!egl_create_surface(mali, &mali->native_window))
goto error; goto error;
return true; return true;

View File

@ -322,6 +322,12 @@ static void gfx_ctx_vc_destroy(void *data)
vc_ctx_data_t *vc = (vc_ctx_data_t*)data; vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
unsigned i; unsigned i;
if (!vc)
{
g_egl_inited = false;
return;
}
if (vc->egl.dpy) if (vc->egl.dpy)
{ {
for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++)