Skip to content

Commit

Permalink
Rename and move rarch_viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 14, 2015
1 parent b777f01 commit 64446ef
Show file tree
Hide file tree
Showing 28 changed files with 99 additions and 77 deletions.
13 changes: 2 additions & 11 deletions general.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "core_options.h"
#include "core_info.h"
#include <retro_miscellaneous.h>
#include "gfx/video_viewport.h"

#include "playlist.h"

Expand Down Expand Up @@ -83,16 +84,6 @@ enum sound_mode_enums
SOUND_MODE_LAST
};

typedef struct rarch_viewport
{
int x;
int y;
unsigned width;
unsigned height;
unsigned full_width;
unsigned full_height;
} rarch_viewport_t;

struct defaults
{
char menu_config_dir[PATH_MAX_LENGTH];
Expand Down Expand Up @@ -705,7 +696,7 @@ struct global

struct
{
rarch_viewport_t custom_vp;
video_viewport_t custom_vp;
} viewports;

unsigned gamma_correction;
Expand Down
12 changes: 7 additions & 5 deletions gfx/d3d/d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
{
if (g_settings.video.scale_integer)
{
struct rarch_viewport vp = {0};
struct video_viewport vp = {0};
video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, keep);
d3d_set_viewport(d3d, vp.x, vp.y, vp.width, vp.height);
}
Expand All @@ -359,10 +359,12 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
{
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
const rarch_viewport_t &custom =
const video_viewport_t &custom =
g_extern.console.screen.viewports.custom_vp;
d3d_set_viewport(d3d, custom.x, custom.y,
custom.width, custom.height);

if (custom)
d3d_set_viewport(d3d, custom.x, custom.y,
custom.width, custom.height);
}
else
{
Expand Down Expand Up @@ -639,7 +641,7 @@ static bool d3d_construct(d3d_video_t *d3d,
return true;
}

static void d3d_viewport_info(void *data, struct rarch_viewport *vp)
static void d3d_viewport_info(void *data, struct video_viewport *vp)
{
d3d_video_t *d3d = (d3d_video_t*)data;

Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/exynos_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ static void exynos_gfx_set_rotation(void *data, unsigned rotation)
vid->menu_rotation = rotation;
}

static void exynos_gfx_viewport_info(void *data, struct rarch_viewport *vp)
static void exynos_gfx_viewport_info(void *data, struct video_viewport *vp)
{
struct exynos_video *vid = (struct exynos_video*)data;

Expand Down
7 changes: 3 additions & 4 deletions gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ void gl_set_viewport(gl_t *gl, unsigned width,
#if defined(HAVE_MENU)
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
const struct rarch_viewport *custom =
(const struct rarch_viewport*)
&g_extern.console.screen.viewports.custom_vp;
const struct video_viewport *custom = &g_extern.console.screen.viewports.custom_vp;

/* GL has bottom-left origin viewport. */
x = custom->x;
Expand Down Expand Up @@ -2624,10 +2622,11 @@ static bool gl_set_shader(void *data,
#endif
}

static void gl_viewport_info(void *data, struct rarch_viewport *vp)
static void gl_viewport_info(void *data, struct video_viewport *vp)
{
unsigned top_y, top_dist;
gl_t *gl = (gl_t*)data;

*vp = gl->vp;
vp->full_width = gl->win_width;
vp->full_height = gl->win_height;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/gx_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ static void gx_apply_state_changes(void *data)
gx->should_resize = true;
}

static void gx_viewport_info(void *data, struct rarch_viewport *vp)
static void gx_viewport_info(void *data, struct video_viewport *vp)
{
gx_video_t *gx = (gx_video_t*)data;
*vp = gx->vp;
Expand Down
4 changes: 3 additions & 1 deletion gfx/drivers/gx_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef _GX_VIDEO_H__
#define _GX_VIDEO_H__

#include "../video_viewport.h"

struct gx_overlay_data
{
GXTexObj tex;
Expand All @@ -34,7 +36,7 @@ typedef struct gx_video
bool rgb32;
uint32_t *menu_data; /* FIXME: Should be const uint16_t*. */
bool menu_texture_enable;
rarch_viewport_t vp;
video_viewport_t vp;
unsigned scale;
#ifdef HAVE_OVERLAY
struct gx_overlay_data *overlay;
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers/nullgfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "../../general.h"
#include "../../driver.h"
#include "../video_viewport.h"

static void *null_gfx_init(const video_info_t *video,
const input_driver_t **input, void **input_data)
Expand Down Expand Up @@ -94,7 +95,7 @@ static void null_gfx_set_rotation(void *data,
}

static void null_gfx_viewport_info(void *data,
struct rarch_viewport *vp)
struct video_viewport *vp)
{
(void)data;
(void)vp;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/omap_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ static bool omap_gfx_focus(void *data)
return true; /* fb device always has focus */
}

static void omap_gfx_viewport_info(void *data, struct rarch_viewport *vp)
static void omap_gfx_viewport_info(void *data, struct video_viewport *vp)
{
omap_video_t *vid = (omap_video_t*)data;

Expand Down
17 changes: 10 additions & 7 deletions gfx/drivers/psp1_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef struct psp1_video

psp1_menu_frame_t menu;

rarch_viewport_t vp;
video_viewport_t vp;

unsigned rotation;
bool vblank_not_reached;
Expand Down Expand Up @@ -715,13 +715,16 @@ static void psp_update_viewport(psp1_video_t* psp)
#if defined(HAVE_MENU)
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
const struct rarch_viewport *custom =
const struct video_viewport *custom =
&g_extern.console.screen.viewports.custom_vp;

x = custom->x;
y = custom->y;
width = custom->width;
height = custom->height;
if (custom)
{
x = custom->x;
y = custom->y;
width = custom->width;
height = custom->height;
}
}
else
#endif
Expand Down Expand Up @@ -828,7 +831,7 @@ static void psp_apply_state_changes(void *data)
psp->should_resize = true;
}

static void psp_viewport_info(void *data, struct rarch_viewport *vp)
static void psp_viewport_info(void *data, struct video_viewport *vp)
{
psp1_video_t *psp = (psp1_video_t*)data;

Expand Down
17 changes: 10 additions & 7 deletions gfx/drivers/sdl2_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ typedef struct _sdl2_video
uint8_t font_g;
uint8_t font_b;

struct rarch_viewport vp;
struct video_viewport vp;

video_info_t video;

Expand Down Expand Up @@ -274,12 +274,15 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
vid->video.force_aspect);
else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
const struct rarch_viewport *custom = &g_extern.console.screen.viewports.custom_vp;
const struct video_viewport *custom = &g_extern.console.screen.viewports.custom_vp;

vid->vp.x = custom->x;
vid->vp.y = custom->y;
vid->vp.width = custom->width;
vid->vp.height = custom->height;
if (custom)
{
vid->vp.x = custom->x;
vid->vp.y = custom->y;
vid->vp.width = custom->width;
vid->vp.height = custom->height;
}
}
else if (vid->video.force_aspect)
{
Expand Down Expand Up @@ -592,7 +595,7 @@ static void sdl2_gfx_set_rotation(void *data, unsigned rotation)
vid->rotation = 270 * rotation;
}

static void sdl2_gfx_viewport_info(void *data, struct rarch_viewport *vp)
static void sdl2_gfx_viewport_info(void *data, struct video_viewport *vp)
{
sdl2_video_t *vid = (sdl2_video_t*)data;
*vp = vid->vp;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/sdl_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static bool sdl_gfx_has_windowed(void *data)
return true;
}

static void sdl_gfx_viewport_info(void *data, struct rarch_viewport *vp)
static void sdl_gfx_viewport_info(void *data, struct video_viewport *vp)
{
sdl_video_t *vid = (sdl_video_t*)data;
vp->x = vp->y = 0;
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers/vg.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "../../performance.h"
#include "../font_renderer_driver.h"
#include "../../content.h"
#include "../gfx/video_viewport.h"

typedef struct
{
Expand Down Expand Up @@ -453,7 +454,7 @@ static void vg_set_rotation(void *data, unsigned rotation)
}

static void vg_viewport_info(void *data,
struct rarch_viewport *vp)
struct video_viewport *vp)
{
(void)data;
(void)vp;
Expand Down
4 changes: 3 additions & 1 deletion gfx/drivers/xenon360_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "../../driver.h"
#include "../../general.h"

#Include "../video_viewport.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
Expand Down Expand Up @@ -292,7 +294,7 @@ static void xenon360_gfx_set_rotation(void *data, unsigned rotation)
(void)rotation;
}

static void xenon360_gfx_viewport_info(void *data, struct rarch_viewport *vp)
static void xenon360_gfx_viewport_info(void *data, struct video_viewport *vp)
{
(void)data;
(void)vp;
Expand Down
6 changes: 3 additions & 3 deletions gfx/drivers/xvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct xv
unsigned width;
unsigned height;
bool keep_aspect;
struct rarch_viewport vp;
struct video_viewport vp;

uint8_t *ytable;
uint8_t *utable;
Expand Down Expand Up @@ -350,7 +350,7 @@ static bool adaptor_set_format(xv_t *xv, Display *dpy,
return false;
}

static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp,
static void calc_out_rect(bool keep_aspect, struct video_viewport *vp,
unsigned vp_width, unsigned vp_height)
{
vp->full_width = vp_width;
Expand Down Expand Up @@ -878,7 +878,7 @@ static void xv_free(void *data)
free(xv);
}

static void xv_viewport_info(void *data, struct rarch_viewport *vp)
static void xv_viewport_info(void *data, struct video_viewport *vp)
{
xv_t *xv = (xv_t*)data;
*vp = xv->vp;
Expand Down
2 changes: 1 addition & 1 deletion gfx/gl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ typedef struct gl

unsigned win_width;
unsigned win_height;
struct rarch_viewport vp;
struct video_viewport vp;
unsigned vp_out_width;
unsigned vp_out_height;
unsigned last_width[MAX_TEXTURES];
Expand Down
5 changes: 2 additions & 3 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "video_driver.h"
#include "video_thread_wrapper.h"
#include "video_pixel_converter.h"
#include "video_viewport.h"
#include "video_monitor.h"
#include "../general.h"
#include "../retroarch.h"
Expand Down Expand Up @@ -386,7 +385,7 @@ void uninit_video_input(void)
void init_video(void)
{
unsigned max_dim, scale, width, height;
rarch_viewport_t *custom_vp;
video_viewport_t *custom_vp = NULL;
const input_driver_t *tmp = NULL;
const struct retro_game_geometry *geom = NULL;
video_info_t video = {0};
Expand All @@ -409,7 +408,7 @@ void init_video(void)
video_viewport_set_config();

/* Update CUSTOM viewport. */
custom_vp = (rarch_viewport_t*)&g_extern.console.screen.viewports.custom_vp;
custom_vp = &g_extern.console.screen.viewports.custom_vp;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{
float default_aspect = aspectratio_lut[ASPECT_RATIO_CORE].value;
Expand Down
5 changes: 2 additions & 3 deletions gfx/video_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <gfx/scaler/scaler.h>
#include "video_filter.h"
#include "video_shader_parse.h"
#include "video_viewport.h"

#include "../libretro.h"
#include "../input/input_driver.h"
Expand All @@ -33,8 +34,6 @@
extern "C" {
#endif

struct rarch_viewport;

typedef struct video_info
{
unsigned width;
Expand Down Expand Up @@ -159,7 +158,7 @@ typedef struct video_driver
const char *ident;

void (*set_rotation)(void *data, unsigned rotation);
void (*viewport_info)(void *data, struct rarch_viewport *vp);
void (*viewport_info)(void *data, struct video_viewport *vp);

/* Reads out in BGR byte order (24bpp). */
bool (*read_viewport)(void *data, uint8_t *buffer);
Expand Down
7 changes: 4 additions & 3 deletions gfx/video_thread_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "video_thread_wrapper.h"
#include "video_viewport.h"
#include "../performance.h"
#include <file/dir_list.h>
#include <stdlib.h>
Expand Down Expand Up @@ -135,7 +136,7 @@ static void thread_loop(void *data)

case CMD_READ_VIEWPORT:
{
struct rarch_viewport vp = {0};
struct video_viewport vp = {0};

thr->driver->viewport_info(thr->driver_data, &vp);

Expand Down Expand Up @@ -306,7 +307,7 @@ static void thread_loop(void *data)
bool alive = false;
bool focus = false;
bool has_windowed = true;
struct rarch_viewport vp = {0};
struct video_viewport vp = {0};

slock_lock(thr->frame.lock);

Expand Down Expand Up @@ -591,7 +592,7 @@ static void thread_set_rotation(void *data, unsigned rotation)
*
* This means this value might not be correct, so viewport
* reads are not supported for now. */
static void thread_viewport_info(void *data, struct rarch_viewport *vp)
static void thread_viewport_info(void *data, struct video_viewport *vp)
{
thread_video_t *thr = (thread_video_t*)data;

Expand Down
Loading

0 comments on commit 64446ef

Please sign in to comment.