mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(vita2d_gfx.c) Cleanups
This commit is contained in:
parent
19d2649c61
commit
3a4963b474
@ -221,7 +221,8 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
|
||||
menu_driver_frame(video_info);
|
||||
#endif
|
||||
|
||||
if(vita->menu.texture){
|
||||
if(vita->menu.texture)
|
||||
{
|
||||
if (vita->fullscreen)
|
||||
vita2d_draw_texture_scale(vita->menu.texture,
|
||||
0, 0,
|
||||
@ -363,12 +364,13 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
|
||||
else if (vita->keep_aspect)
|
||||
{
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
if (vita->rotation == ORIENTATION_VERTICAL ||
|
||||
vita->rotation == ORIENTATION_FLIPPED_ROTATED){
|
||||
device_aspect = 1.0 / device_aspect;
|
||||
width = PSP_FB_HEIGHT;
|
||||
height = PSP_FB_WIDTH;
|
||||
}
|
||||
if ( (vita->rotation == ORIENTATION_VERTICAL ||)
|
||||
(vita->rotation == ORIENTATION_FLIPPED_ROTATED))
|
||||
{
|
||||
device_aspect = 1.0 / device_aspect;
|
||||
width = PSP_FB_HEIGHT;
|
||||
height = PSP_FB_WIDTH;
|
||||
}
|
||||
#if defined(HAVE_MENU)
|
||||
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
@ -409,11 +411,13 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
|
||||
height = (unsigned)roundf(2.0f * height * delta);
|
||||
}
|
||||
|
||||
if (vita->rotation == ORIENTATION_VERTICAL ||
|
||||
vita->rotation == ORIENTATION_FLIPPED_ROTATED){
|
||||
x = (PSP_FB_WIDTH - width) * 0.5f;
|
||||
y = (PSP_FB_HEIGHT - height) * 0.5f;
|
||||
}
|
||||
if ( (vita->rotation == ORIENTATION_VERTICAL) ||
|
||||
(vita->rotation == ORIENTATION_FLIPPED_ROTATED)
|
||||
)
|
||||
{
|
||||
x = (PSP_FB_WIDTH - width) * 0.5f;
|
||||
y = (PSP_FB_HEIGHT - height) * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
vita->vp.x = x;
|
||||
@ -440,12 +444,12 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width,
|
||||
{
|
||||
gfx_ctx_aspect_t aspect_data;
|
||||
unsigned width, height;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
float device_aspect = (float)viewport_width / viewport_height;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
float device_aspect = (float)viewport_width / viewport_height;
|
||||
struct video_ortho ortho = {0, 1, 1, 0, -1, 1};
|
||||
settings_t *settings = config_get_ptr();
|
||||
vita_video_t *vita = (vita_video_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
vita_video_t *vita = (vita_video_t*)data;
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
@ -528,15 +532,16 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width,
|
||||
vita->vp.height = viewport_height;
|
||||
}
|
||||
|
||||
/*vita->vp.x = (float)vita->vp.x;
|
||||
#if 0
|
||||
vita->vp.x = (float)vita->vp.x;
|
||||
vita->vp.y = (float)vita->vp.y;
|
||||
vita->vp.width = (float)vita->vp.width;
|
||||
vita->vp.height = (float)vita->vp.height;
|
||||
vita->vp.minDepth = 0.0f;
|
||||
vita->vp.maxDepth = 1.0f;*/
|
||||
vita->vp.maxDepth = 1.0f;
|
||||
|
||||
|
||||
//RARCH_LOG("Setting viewport @ %ux%u\n", viewport_width, viewport_height);
|
||||
RARCH_LOG("Setting viewport @ %ux%u\n", viewport_width, viewport_height);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vita2d_gfx_set_rotation(void *data,
|
||||
@ -574,8 +579,10 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth)
|
||||
|
||||
if (vita)
|
||||
{
|
||||
vita->tex_filter = smooth? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT;
|
||||
vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
|
||||
vita->tex_filter = smooth ?
|
||||
SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT;
|
||||
vita2d_texture_set_filters(vita->texture,vita->tex_filter,
|
||||
vita->tex_filter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -601,7 +608,9 @@ static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!vita)
|
||||
return;
|
||||
vita->keep_aspect = true;
|
||||
@ -637,18 +646,23 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||
if (rgb32)
|
||||
{
|
||||
vita->menu.texture = vita2d_create_empty_texture(width, height);
|
||||
RARCH_LOG("Creating Frame RGBA8 texture: w: %i h: %i\n", width, height);
|
||||
RARCH_LOG("Creating Frame RGBA8 texture: w: %i h: %i\n",
|
||||
width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
vita->menu.texture = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA);
|
||||
RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n", width, height);
|
||||
vita->menu.texture = vita2d_create_empty_texture_format(
|
||||
width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA);
|
||||
RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n",
|
||||
width, height);
|
||||
}
|
||||
vita->menu.width = width;
|
||||
vita->menu.height = height;
|
||||
}
|
||||
|
||||
vita2d_texture_set_filters(vita->menu.texture,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||
vita2d_texture_set_filters(vita->menu.texture,
|
||||
SCE_GXM_TEXTURE_FILTER_LINEAR,
|
||||
SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||
|
||||
tex_p = vita2d_texture_get_datap(vita->menu.texture);
|
||||
stride = vita2d_texture_get_stride(vita->menu.texture);
|
||||
@ -689,30 +703,40 @@ static uintptr_t vita_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
unsigned int stride, pitch, j;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
uint32_t *tex32 = NULL;
|
||||
const uint32_t *frame32 = NULL;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width,
|
||||
image->height,SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB);
|
||||
|
||||
if (!texture)
|
||||
return 0;
|
||||
|
||||
if(filter_type == TEXTURE_FILTER_MIPMAP_LINEAR ||
|
||||
filter_type == TEXTURE_FILTER_LINEAR)
|
||||
vita2d_texture_set_filters(texture,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||
if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) ||
|
||||
(filter_type == TEXTURE_FILTER_LINEAR))
|
||||
vita2d_texture_set_filters(texture,
|
||||
SCE_GXM_TEXTURE_FILTER_LINEAR,
|
||||
SCE_GXM_TEXTURE_FILTER_LINEAR);
|
||||
|
||||
stride = vita2d_texture_get_stride(texture);
|
||||
stride = vita2d_texture_get_stride(texture);
|
||||
stride /= 4;
|
||||
uint32_t *tex32 = vita2d_texture_get_datap(texture);
|
||||
const uint32_t *frame32 = image->pixels;
|
||||
pitch = image->width;
|
||||
|
||||
tex32 = vita2d_texture_get_datap(texture);
|
||||
frame32 = image->pixels;
|
||||
pitch = image->width;
|
||||
|
||||
for (j = 0; j < image->height; j++)
|
||||
memcpy_neon(&tex32[j*stride],&frame32[j*pitch],pitch*sizeof(uint32_t));
|
||||
memcpy_neon(
|
||||
&tex32[j*stride],
|
||||
&frame32[j*pitch],
|
||||
pitch * sizeof(uint32_t));
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
||||
static void vita_unload_texture(void *data, uintptr_t handle)
|
||||
{
|
||||
struct vita2d_texture *texture = (struct vita2d_texture*)handle;
|
||||
struct vita2d_texture *texture = (struct vita2d_texture*)handle;
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
@ -740,17 +764,19 @@ static bool vita_get_current_sw_framebuffer(void *data,
|
||||
if (!vita->texture || vita->width != framebuffer->width ||
|
||||
vita->height != framebuffer->height)
|
||||
{
|
||||
if(vita->texture){
|
||||
vita2d_wait_rendering_done();
|
||||
vita2d_free_texture(vita->texture);
|
||||
vita->texture = NULL;
|
||||
if(vita->texture)
|
||||
{
|
||||
vita2d_wait_rendering_done();
|
||||
vita2d_free_texture(vita->texture);
|
||||
vita->texture = NULL;
|
||||
}
|
||||
|
||||
|
||||
vita->width = framebuffer->width;
|
||||
vita->height = framebuffer->height;
|
||||
vita->texture = vita2d_create_empty_texture_format(vita->width, vita->height, vita->format);
|
||||
vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
|
||||
|
||||
vita->texture = vita2d_create_empty_texture_format(
|
||||
vita->width, vita->height, vita->format);
|
||||
vita2d_texture_set_filters(vita->texture,
|
||||
vita->tex_filter,vita->tex_filter);
|
||||
}
|
||||
|
||||
framebuffer->data = vita2d_texture_get_datap(vita->texture);
|
||||
|
Loading…
x
Reference in New Issue
Block a user