Add viewport_info callback to renderchain

This commit is contained in:
twinaphex 2015-11-11 01:43:58 +01:00
parent ebe0a4aa4a
commit 71c40f1bc8
5 changed files with 53 additions and 17 deletions

View File

@ -736,21 +736,12 @@ static bool d3d_construct(d3d_video_t *d3d,
static void d3d_viewport_info(void *data, struct video_viewport *vp)
{
unsigned width, height;
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d || !vp)
return;
if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info)
return false;
video_driver_get_size(&width, &height);
vp->x = d3d->final_viewport.X;
vp->y = d3d->final_viewport.Y;
vp->width = d3d->final_viewport.Width;
vp->height = d3d->final_viewport.Height;
vp->full_width = width;
vp->full_height = height;
d3d->renderchain_driver->viewport_info(d3d, vp);
}
static void d3d_set_rotation(void *data, unsigned rot)
@ -762,7 +753,6 @@ static void d3d_set_rotation(void *data, unsigned rot)
return;
d3d->dev_rotation = rot;
//d3d_set_projection(d3d, &ortho, true);
}
static void d3d_show_mouse(void *data, bool state)
@ -1299,6 +1289,7 @@ static bool d3d_process_shader(d3d_video_t *d3d)
#ifdef HAVE_OVERLAY
static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
{
struct video_viewport vp;
unsigned width, height;
void *verts;
unsigned i;
@ -1343,9 +1334,11 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
vert[i].r = vert[i].g = vert[i].b = 1.0f;
vert[i].a = overlay->alpha_mod;
}
d3d_viewport_info(d3d, &vp);
overlay_width = d3d->final_viewport.Width;
overlay_height = d3d->final_viewport.Height;
overlay_width = vp->Width;
overlay_height = vp->Height;
vert[0].x = overlay->vert_coords.x * overlay_width;
vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w)

View File

@ -1594,6 +1594,25 @@ end:
return ret;
}
static void cg_d3d9_renderchain_viewport_info(void *data, struct video_viewport *vp)
{
unsigned width, height;
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d || !vp)
return;
video_driver_get_size(&width, &height);
vp->x = d3d->final_viewport.X;
vp->y = d3d->final_viewport.Y;
vp->width = d3d->final_viewport.Width;
vp->height = d3d->final_viewport.Height;
vp->full_width = width;
vp->full_height = height;
}
renderchain_driver_t cg_d3d9_renderchain = {
cg_d3d9_renderchain_free,
cg_d3d9_renderchain_new,
@ -1609,5 +1628,6 @@ renderchain_driver_t cg_d3d9_renderchain = {
cg_d3d9_renderchain_convert_geometry,
cg_d3d9_renderchain_set_font_rect,
cg_d3d9_renderchain_read_viewport,
cg_d3d9_renderchain_viewport_info,
"cg_d3d9",
};

View File

@ -17,8 +17,9 @@
#ifndef __D3D_RENDER_CHAIN_H
#define __D3D_RENDER_CHAIN_H
#include "../video_state_tracker.h"
#include "../video_shader_parse.h"
#include "../video_state_tracker.h"
#include "../video_viewport.h"
#include "../../libretro.h"
#include "d3d_defines.h"
@ -68,6 +69,7 @@ typedef struct renderchain_driver
void *final_viewport);
void (*set_font_rect)(void *data, const struct font_params *params);
bool (*read_viewport)(void *data, uint8_t *buffer);
void (*viewport_info)(void *data, struct video_viewport *vp);
const char *ident;
} renderchain_driver_t;

View File

@ -146,5 +146,6 @@ renderchain_driver_t null_renderchain = {
null_renderchain_convert_geometry,
NULL,
NULL,
NULL,
"null",
};

View File

@ -461,6 +461,25 @@ static bool xdk_renderchain_reinit(void *data,
return true;
}
static void xdk_renderchain_viewport_info(void *data, struct video_viewport *vp)
{
unsigned width, height;
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d || !vp)
return;
video_driver_get_size(&width, &height);
vp->x = d3d->final_viewport.X;
vp->y = d3d->final_viewport.Y;
vp->width = d3d->final_viewport.Width;
vp->height = d3d->final_viewport.Height;
vp->full_width = width;
vp->full_height = height;
}
renderchain_driver_t xdk_renderchain = {
xdk_renderchain_free,
xdk_renderchain_new,
@ -476,5 +495,6 @@ renderchain_driver_t xdk_renderchain = {
xdk_renderchain_convert_geometry,
NULL,
NULL,
xdk_renderchain_viewport_info,
"xdk",
};