mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
Style/indenting nits
This commit is contained in:
parent
641ba534e4
commit
6a3af98df6
@ -38,16 +38,19 @@ static const struct font_atlas *font_renderer_get_atlas(void *data)
|
||||
return &handle->atlas;
|
||||
}
|
||||
|
||||
static const struct font_glyph *font_renderer_get_glyph(void *data, uint32_t code)
|
||||
static const struct font_glyph *font_renderer_get_glyph(
|
||||
void *data, uint32_t code)
|
||||
{
|
||||
bm_renderer_t *handle = (bm_renderer_t*)data;
|
||||
return code < ATLAS_SIZE ? &handle->glyphs[code] : NULL;
|
||||
}
|
||||
|
||||
static void char_to_texture(bm_renderer_t *handle, uint8_t letter, unsigned atlas_x, unsigned atlas_y)
|
||||
static void char_to_texture(bm_renderer_t *handle, uint8_t letter,
|
||||
unsigned atlas_x, unsigned atlas_y)
|
||||
{
|
||||
unsigned y, x, xo, yo;
|
||||
uint8_t *target = handle->atlas.buffer + atlas_x + atlas_y * handle->atlas.width;
|
||||
uint8_t *target = handle->atlas.buffer + atlas_x +
|
||||
atlas_y * handle->atlas.width;
|
||||
|
||||
for (y = 0; y < FONT_HEIGHT; y++)
|
||||
{
|
||||
|
@ -27,7 +27,8 @@ static const d3d_font_renderer_t *d3d_font_backends[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
const d3d_font_renderer_t *d3d_font_init_first(void *data, const char *font_path, unsigned font_size)
|
||||
const d3d_font_renderer_t *d3d_font_init_first(void *data,
|
||||
const char *font_path, unsigned font_size)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < ARRAY_SIZE(d3d_font_backends); i++)
|
||||
|
@ -28,7 +28,8 @@ typedef struct d3d_font_renderer
|
||||
{
|
||||
bool (*init)(void *data, const char *font_path, unsigned font_size);
|
||||
void (*deinit)(void *data);
|
||||
void (*render_msg)(void *data, const char *msg, const struct font_params *params);
|
||||
void (*render_msg)(void *data, const char *msg,
|
||||
const struct font_params *params);
|
||||
const char *ident;
|
||||
} d3d_font_renderer_t;
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
#include "../gfx_common.h"
|
||||
#include "../../general.h"
|
||||
|
||||
static bool d3dfonts_w32_init_font(void *data, const char *font_path, unsigned font_size)
|
||||
static bool d3dfonts_w32_init_font(void *data,
|
||||
const char *font_path, unsigned font_size)
|
||||
{
|
||||
(void)font_path;
|
||||
|
||||
@ -49,7 +50,8 @@ static void d3dfonts_w32_deinit_font(void *data)
|
||||
d3d->font = NULL;
|
||||
}
|
||||
|
||||
static void d3dfonts_w32_render_msg(void *data, const char *msg, const struct font_params *params)
|
||||
static void d3dfonts_w32_render_msg(void *data, const char *msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
|
@ -30,7 +30,8 @@ static const font_renderer_driver_t *font_backends[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
bool font_renderer_create_default(const font_renderer_driver_t **driver, void **handle,
|
||||
bool font_renderer_create_default(
|
||||
const font_renderer_driver_t **driver, void **handle,
|
||||
const char *font_path, unsigned font_size)
|
||||
{
|
||||
unsigned i;
|
||||
@ -45,12 +46,14 @@ bool font_renderer_create_default(const font_renderer_driver_t **driver, void **
|
||||
*handle = font_backends[i]->init(path, font_size);
|
||||
if (*handle)
|
||||
{
|
||||
RARCH_LOG("Using font rendering backend: %s.\n", font_backends[i]->ident);
|
||||
RARCH_LOG("Using font rendering backend: %s.\n",
|
||||
font_backends[i]->ident);
|
||||
*driver = font_backends[i];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
RARCH_ERR("Failed to create rendering backend: %s.\n", font_backends[i]->ident);
|
||||
RARCH_ERR("Failed to create rendering backend: %s.\n",
|
||||
font_backends[i]->ident);
|
||||
}
|
||||
|
||||
*driver = NULL;
|
||||
|
@ -20,32 +20,36 @@
|
||||
#include <stdint.h>
|
||||
#include "../../boolean.h"
|
||||
|
||||
// All coordinates and offsets are top-left oriented.
|
||||
//
|
||||
// This is a texture-atlas approach which allows text to be drawn in a single draw call.
|
||||
// It is up to the code using this interface to actually generate proper vertex buffers and upload the atlas texture to GPU.
|
||||
/* All coordinates and offsets are top-left oriented.
|
||||
*
|
||||
* This is a texture-atlas approach which allows text to
|
||||
* be drawn in a single draw call.
|
||||
*
|
||||
* It is up to the code using this interface to actually
|
||||
* generate proper vertex buffers and upload the atlas texture to GPU. */
|
||||
|
||||
struct font_glyph
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
// Texel coordiate offset for top-left pixel of this glyph.
|
||||
/* Texel coordinate offset for top-left pixel of this glyph. */
|
||||
unsigned atlas_offset_x;
|
||||
unsigned atlas_offset_y;
|
||||
|
||||
// When drawing this glyph, apply an offset to current X/Y draw coordinate.
|
||||
/* When drawing this glyph, apply an offset to
|
||||
* current X/Y draw coordinate. */
|
||||
int draw_offset_x;
|
||||
int draw_offset_y;
|
||||
|
||||
// Advance X/Y draw coordinates after drawing this glyph.
|
||||
/* Advance X/Y draw coordinates after drawing this glyph. */
|
||||
int advance_x;
|
||||
int advance_y;
|
||||
};
|
||||
|
||||
struct font_atlas
|
||||
{
|
||||
uint8_t *buffer; // Alpha channel.
|
||||
uint8_t *buffer; /* Alpha channel. */
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
};
|
||||
@ -53,19 +57,25 @@ struct font_atlas
|
||||
typedef struct font_renderer_driver
|
||||
{
|
||||
void *(*init)(const char *font_path, float font_size);
|
||||
|
||||
const struct font_atlas *(*get_atlas)(void *data);
|
||||
const struct font_glyph *(*get_glyph)(void *data, uint32_t code); // Returns NULL if no glyph for this code is found.
|
||||
|
||||
/* Returns NULL if no glyph for this code is found. */
|
||||
const struct font_glyph *(*get_glyph)(void *data, uint32_t code);
|
||||
|
||||
void (*free)(void *data);
|
||||
|
||||
const char *(*get_default_font)(void);
|
||||
|
||||
const char *ident;
|
||||
} font_renderer_driver_t;
|
||||
|
||||
extern const font_renderer_driver_t ft_font_renderer;
|
||||
extern const font_renderer_driver_t bitmap_font_renderer;
|
||||
|
||||
// font_path can be NULL for default font.
|
||||
bool font_renderer_create_default(const font_renderer_driver_t **driver, void **handle, const char *font_path, unsigned font_size);
|
||||
/* font_path can be NULL for default font. */
|
||||
bool font_renderer_create_default(const font_renderer_driver_t **driver,
|
||||
void **handle, const char *font_path, unsigned font_size);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -87,7 +87,7 @@ static bool ft_renderer_create_atlas(ft_renderer_t *handle)
|
||||
FT_Render_Glyph(handle->face->glyph, FT_RENDER_MODE_NORMAL);
|
||||
FT_GlyphSlot slot = handle->face->glyph;
|
||||
|
||||
// Some glyphs can be blank.
|
||||
/* Some glyphs can be blank. */
|
||||
buffer[i] = (uint8_t*)calloc(slot->bitmap.rows * slot->bitmap.pitch, 1);
|
||||
|
||||
glyph->width = slot->bitmap.width;
|
||||
@ -100,7 +100,8 @@ static bool ft_renderer_create_atlas(ft_renderer_t *handle)
|
||||
glyph->draw_offset_y = -slot->bitmap_top;
|
||||
|
||||
if (buffer[i])
|
||||
memcpy(buffer[i], slot->bitmap.buffer, slot->bitmap.rows * pitches[i]);
|
||||
memcpy(buffer[i], slot->bitmap.buffer,
|
||||
slot->bitmap.rows * pitches[i]);
|
||||
max_width = max(max_width, (unsigned)slot->bitmap.width);
|
||||
max_height = max(max_height, (unsigned)slot->bitmap.rows);
|
||||
}
|
||||
@ -115,7 +116,7 @@ static bool ft_renderer_create_atlas(ft_renderer_t *handle)
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Blit our texture atlas.
|
||||
/* Blit our texture atlas. */
|
||||
for (i = 0; i < ATLAS_SIZE; i++)
|
||||
{
|
||||
unsigned r, c;
|
||||
@ -132,7 +133,8 @@ static bool ft_renderer_create_atlas(ft_renderer_t *handle)
|
||||
if (buffer[i])
|
||||
{
|
||||
const uint8_t *src = buffer[i];
|
||||
for (r = 0; r < handle->glyphs[i].height; r++, dst += handle->atlas.width, src += pitches[i])
|
||||
for (r = 0; r < handle->glyphs[i].height;
|
||||
r++, dst += handle->atlas.width, src += pitches[i])
|
||||
for (c = 0; c < handle->glyphs[i].width; c++)
|
||||
dst[c] = src[c];
|
||||
}
|
||||
@ -174,7 +176,8 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Not the cleanest way to do things for sure, but should hopefully work ... :)
|
||||
/* Not the cleanest way to do things for sure,
|
||||
* but should hopefully work ... */
|
||||
|
||||
static const char *font_paths[] = {
|
||||
#if defined(_WIN32)
|
||||
@ -190,10 +193,10 @@ static const char *font_paths[] = {
|
||||
"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf",
|
||||
"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
|
||||
#endif
|
||||
"osd-font.ttf", // Magic font to search for, useful for distribution.
|
||||
"osd-font.ttf", /* Magic font to search for, useful for distribution. */
|
||||
};
|
||||
|
||||
// Highly OS/platform dependent.
|
||||
/* Highly OS/platform dependent. */
|
||||
static const char *ft_renderer_get_default_font(void)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -36,7 +36,8 @@ static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||
|
||||
font->gl = (gl_t*)gl_data;
|
||||
|
||||
if (!font_renderer_create_default(&font->font_driver, &font->font_data, font_path, font_size))
|
||||
if (!font_renderer_create_default(&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't init font renderer.\n");
|
||||
free(font);
|
||||
@ -54,9 +55,12 @@ static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||
|
||||
unsigned width = next_pow2(atlas->width);
|
||||
unsigned height = next_pow2(atlas->height);
|
||||
// Ideally, we'd use single component textures, but the difference in ways to do that between core GL and GLES/legacy GL
|
||||
// is too great to bother going down that route.
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
/* Ideally, we'd use single component textures, but the
|
||||
* difference in ways to do that between core GL and GLES/legacy GL
|
||||
* is too great to bother going down that route. */
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
uint8_t *tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4);
|
||||
if (tmp_buffer)
|
||||
@ -71,7 +75,8 @@ static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||
*dst++ = 0xff;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width, atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width,
|
||||
atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer);
|
||||
free(tmp_buffer);
|
||||
}
|
||||
|
||||
@ -106,7 +111,8 @@ static void gl_free_font(void *data)
|
||||
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
|
||||
} while(0)
|
||||
|
||||
static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y)
|
||||
static void render_message(gl_raster_t *font, const char *msg, GLfloat scale,
|
||||
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y)
|
||||
{
|
||||
unsigned i;
|
||||
gl_t *gl = font->gl;
|
||||
@ -133,15 +139,16 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||
|
||||
while (msg_len_full)
|
||||
{
|
||||
// Rebind shaders so attrib cache gets reset.
|
||||
/* Rebind shaders so attrib cache gets reset. */
|
||||
if (gl->shader && gl->shader->use)
|
||||
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
||||
|
||||
for (i = 0; i < msg_len; i++)
|
||||
{
|
||||
const struct font_glyph *gly = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
|
||||
const struct font_glyph *gly =
|
||||
font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
|
||||
if (!gly)
|
||||
gly = font->font_driver->get_glyph(font->font_data, '?'); // Do something smarter here ...
|
||||
gly = font->font_driver->get_glyph(font->font_data, '?'); /* Do something smarter here ... */
|
||||
if (!gly)
|
||||
continue;
|
||||
|
||||
@ -152,13 +159,13 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||
int width = gly->width;
|
||||
int height = gly->height;
|
||||
|
||||
emit(0, 0, 1); // Bottom-left
|
||||
emit(1, 1, 1); // Bottom-right
|
||||
emit(2, 0, 0); // Top-left
|
||||
emit(0, 0, 1); /* Bottom-left */
|
||||
emit(1, 1, 1); /* Bottom-right */
|
||||
emit(2, 0, 0); /* Top-left */
|
||||
|
||||
emit(3, 1, 0); // Top-right
|
||||
emit(4, 0, 0); // Top-left
|
||||
emit(5, 1, 1); // Bottom-right
|
||||
emit(3, 1, 0); /* Top-right */
|
||||
emit(4, 0, 0); /* Top-left */
|
||||
emit(5, 1, 1); /* Bottom-right */
|
||||
#undef emit
|
||||
|
||||
delta_x += gly->advance_x;
|
||||
@ -177,7 +184,7 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||
msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
||||
}
|
||||
|
||||
// Post - Go back to old rendering path.
|
||||
/* Post - Go back to old rendering path. */
|
||||
gl->coords.vertex = gl->vertex_ptr;
|
||||
gl->coords.tex_coord = gl->tex_coords;
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
@ -185,7 +192,8 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||
}
|
||||
|
||||
static void gl_render_msg(void *data, const char *msg, const struct font_params *params)
|
||||
static void gl_render_msg(void *data, const char *msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
GLfloat x, y, scale, drop_mod;
|
||||
GLfloat color[4], color_dark[4];
|
||||
@ -213,7 +221,7 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||
color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f;
|
||||
color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
|
||||
|
||||
// If alpha is 0.0f, turn it into default 1.0f
|
||||
/* If alpha is 0.0f, turn it into default 1.0f */
|
||||
if (color[3] <= 0.0f)
|
||||
color[3] = 1.0f;
|
||||
}
|
||||
@ -234,7 +242,8 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||
drop_mod = 0.3f;
|
||||
}
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, full_screen, false);
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height,
|
||||
full_screen, false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
@ -247,7 +256,8 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||
color_dark[3] = color[3];
|
||||
|
||||
render_message(font, msg, scale, color_dark,
|
||||
x + scale * drop_x / gl->vp.width, y + scale * drop_y / gl->vp.height);
|
||||
x + scale * drop_x / gl->vp.width, y +
|
||||
scale * drop_y / gl->vp.height);
|
||||
}
|
||||
render_message(font, msg, scale, color, x, y);
|
||||
|
||||
|
@ -50,7 +50,7 @@ static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||
|
||||
DbgFontInit(&cfg);
|
||||
|
||||
// Doesn't need any state.
|
||||
/* Doesn't need any state. */
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
@ -60,7 +60,8 @@ static void gl_deinit_font(void *data)
|
||||
DbgFontExit();
|
||||
}
|
||||
|
||||
static void gl_render_msg(void *data, const char *msg, const struct font_params *params)
|
||||
static void gl_render_msg(void *data, const char *msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
(void)data;
|
||||
float x, y, scale;
|
||||
@ -87,7 +88,8 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||
DbgFontPrint(x, y, scale - 0.01f, WHITE, msg);
|
||||
|
||||
#ifdef SN_TARGET_PSP2
|
||||
/* FIXME - if we ever get around to this port, move this out to some better place */
|
||||
/* FIXME - if we ever get around to this port,
|
||||
* move this out to some better place */
|
||||
sceDbgFontFlush();
|
||||
#endif
|
||||
}
|
||||
|
@ -22,7 +22,8 @@
|
||||
static XFONT *debug_font;
|
||||
static D3DSurface *pFrontBuffer;
|
||||
|
||||
static bool xfonts_init_font(void *data, const char *font_path, unsigned font_size)
|
||||
static bool xfonts_init_font(void *data,
|
||||
const char *font_path, unsigned font_size)
|
||||
{
|
||||
(void)font_path;
|
||||
(void)font_size;
|
||||
@ -42,7 +43,8 @@ static void xfonts_deinit_font(void *data)
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void xfonts_render_msg(void *data, const char *msg, const struct font_params *params)
|
||||
static void xfonts_render_msg(void *data, const char *msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
wchar_t str[PATH_MAX];
|
||||
|
@ -105,7 +105,8 @@ typedef struct {
|
||||
|
||||
static Font_Locals_t s_FontLocals;
|
||||
|
||||
static HRESULT xdk360_video_font_create_shaders (void *data, xdk360_video_font_t * font)
|
||||
static HRESULT xdk360_video_font_create_shaders(
|
||||
void *data, xdk360_video_font_t * font)
|
||||
{
|
||||
HRESULT hr;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
@ -177,7 +178,8 @@ static HRESULT xdk360_video_font_create_shaders (void *data, xdk360_video_font_t
|
||||
return hr;
|
||||
}
|
||||
|
||||
static bool xdk_init_font(void *data, const char *font_path, unsigned font_size)
|
||||
static bool xdk_init_font(void *data,
|
||||
const char *font_path, unsigned font_size)
|
||||
{
|
||||
(void)font_size;
|
||||
|
||||
@ -221,7 +223,7 @@ static bool xdk_init_font(void *data, const char *font_path, unsigned font_size)
|
||||
|
||||
// Read the glyph attributes from the file
|
||||
font->m_dwNumGlyphs = ((const FontFileStrikesImage_t *)pData)->m_dwNumGlyphs;
|
||||
font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs; // Pointer
|
||||
font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -229,7 +231,7 @@ static bool xdk_init_font(void *data, const char *font_path, unsigned font_size)
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Create the vertex and pixel shaders for rendering the font
|
||||
/* Create the vertex and pixel shaders for rendering the font */
|
||||
if (FAILED(xdk360_video_font_create_shaders(d3d, font)))
|
||||
{
|
||||
RARCH_ERR( "Could not create font shaders.\n" );
|
||||
@ -247,7 +249,7 @@ static void xdk_deinit_font(void *data)
|
||||
{
|
||||
xdk360_video_font_t *font = &m_Font;
|
||||
|
||||
// Destroy the font
|
||||
/* Destroy the font */
|
||||
font->m_pFontTexture = NULL;
|
||||
font->m_dwNumGlyphs = 0L;
|
||||
font->m_Glyphs = NULL;
|
||||
@ -347,7 +349,8 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font, void *video_data
|
||||
volatile float * pVertex;
|
||||
|
||||
unsigned long dwNumChars = wcslen(strText);
|
||||
d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars, sizeof(XMFLOAT4), (void**)&pVertex);
|
||||
d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars,
|
||||
sizeof(XMFLOAT4), (void**)&pVertex);
|
||||
|
||||
// Draw four vertices for each glyph
|
||||
while (*strText)
|
||||
@ -435,7 +438,8 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font, void *video_data
|
||||
d3dr->EndVertices();
|
||||
}
|
||||
|
||||
static void xdk_render_msg(void *data, const char *str_msg, const struct font_params *params)
|
||||
static void xdk_render_msg(void *data, const char *str_msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
xdk360_video_font_t *font = &m_Font;
|
||||
|
151
gfx/gx/gx_gfx.c
151
gfx/gx/gx_gfx.c
@ -48,7 +48,7 @@ uint32_t g_orientation;
|
||||
|
||||
static struct
|
||||
{
|
||||
uint32_t *data; // needs to be resizable
|
||||
uint32_t *data; /* needs to be resizable. */
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
GXTexObj obj;
|
||||
@ -126,8 +126,10 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
|
||||
viHeightMultiplier = 1;
|
||||
viWidth = g_settings.video.viwidth;
|
||||
#if defined(HW_RVL)
|
||||
//if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
//viWidth = 704;
|
||||
#if 0
|
||||
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
viWidth = 704;
|
||||
#endif
|
||||
|
||||
progressive = CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable();
|
||||
switch (CONF_GetVideo())
|
||||
@ -208,7 +210,8 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
|
||||
gx_mode.viWidth = viWidth;
|
||||
gx_mode.viHeight = gx_mode.xfbHeight * viHeightMultiplier;
|
||||
gx_mode.viXOrigin = (max_width - gx_mode.viWidth) / 2;
|
||||
gx_mode.viYOrigin = (max_height - gx_mode.viHeight) / (2 * viHeightMultiplier);
|
||||
gx_mode.viYOrigin =
|
||||
(max_height - gx_mode.viHeight) / (2 * viHeightMultiplier);
|
||||
gx_mode.xfbMode = modetype == VI_INTERLACE ? VI_XFBMODE_DF : VI_XFBMODE_SF;
|
||||
gx_mode.field_rendering = GX_FALSE;
|
||||
gx_mode.aa = GX_FALSE;
|
||||
@ -259,17 +262,21 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
|
||||
(void)xfbHeight;
|
||||
GX_SetDispCopyDst(xfbWidth, xfbHeight);
|
||||
|
||||
GX_SetCopyFilter(gx_mode.aa, gx_mode.sample_pattern, (gx_mode.xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE,
|
||||
GX_SetCopyFilter(gx_mode.aa, gx_mode.sample_pattern,
|
||||
(gx_mode.xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE,
|
||||
gx_mode.vfilter);
|
||||
GXColor color = { 0, 0, 0, 0xff };
|
||||
GX_SetCopyClear(color, GX_MAX_Z24);
|
||||
GX_SetFieldMode(gx_mode.field_rendering, (gx_mode.viHeight == 2 * gx_mode.xfbHeight) ? GX_ENABLE : GX_DISABLE);
|
||||
GX_SetFieldMode(gx_mode.field_rendering,
|
||||
(gx_mode.viHeight == 2 * gx_mode.xfbHeight) ? GX_ENABLE : GX_DISABLE);
|
||||
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||
GX_InvalidateTexAll();
|
||||
GX_Flush();
|
||||
_CPU_ISR_Restore(level);
|
||||
|
||||
RARCH_LOG("GX Resolution: %dx%d (%s)\n", gx_mode.fbWidth, gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? "interlaced" : "progressive");
|
||||
RARCH_LOG("GX Resolution: %dx%d (%s)\n", gx_mode.fbWidth,
|
||||
gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE
|
||||
? "interlaced" : "progressive");
|
||||
|
||||
if (driver.menu)
|
||||
{
|
||||
@ -299,7 +306,7 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
|
||||
driver_set_monitor_refresh_rate(59.94f);
|
||||
}
|
||||
|
||||
// don't spam the queue when scrolling through resolutions
|
||||
/* Don't spam the queue when scrolling through resolutions. */
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
|
||||
g_current_framebuf = 0;
|
||||
@ -308,7 +315,9 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
|
||||
const char *gx_get_video_mode(void)
|
||||
{
|
||||
static char format[16];
|
||||
snprintf(format, sizeof(format), "%.3ux%.3u%c", gx_mode.fbWidth, gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? 'i' : 'p');
|
||||
snprintf(format, sizeof(format), "%.3ux%.3u%c",
|
||||
gx_mode.fbWidth, gx_mode.efbHeight,
|
||||
(gx_mode.viTVMode & 3) == VI_INTERLACE ? 'i' : 'p');
|
||||
return format;
|
||||
}
|
||||
|
||||
@ -317,7 +326,9 @@ static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
gx_video_t *gx = (gx_video_t*)driver.video_data;
|
||||
|
||||
if (aspect_ratio_idx == ASPECT_RATIO_SQUARE)
|
||||
gfx_set_square_pixel_viewport(g_extern.system.av_info.geometry.base_width, g_extern.system.av_info.geometry.base_height);
|
||||
gfx_set_square_pixel_viewport(
|
||||
g_extern.system.av_info.geometry.base_width,
|
||||
g_extern.system.av_info.geometry.base_height);
|
||||
else if (aspect_ratio_idx == ASPECT_RATIO_CORE)
|
||||
gfx_set_core_viewport();
|
||||
else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG)
|
||||
@ -337,7 +348,8 @@ static void setup_video_mode(void *data)
|
||||
unsigned i;
|
||||
if (!g_framebuf[0])
|
||||
for (i = 0; i < 2; i++)
|
||||
g_framebuf[i] = MEM_K0_TO_K1(memalign(32, 640 * 576 * VI_DISPLAY_PIX_SZ));
|
||||
g_framebuf[i] = MEM_K0_TO_K1(
|
||||
memalign(32, 640 * 576 * VI_DISPLAY_PIX_SZ));
|
||||
|
||||
g_current_framebuf = 0;
|
||||
g_draw_done = true;
|
||||
@ -368,9 +380,13 @@ static void init_texture(void *data, unsigned width, unsigned height)
|
||||
menu_h = driver.menu->height;
|
||||
}
|
||||
|
||||
__GX_InitTexObj(fb_ptr, g_tex.data, width, height, (gx->rgb32) ? GX_TF_RGBA8 : gx->menu_texture_enable ? GX_TF_RGB5A3 : GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
__GX_InitTexObj(fb_ptr, g_tex.data, width, height,
|
||||
(gx->rgb32) ? GX_TF_RGBA8 : gx->menu_texture_enable ?
|
||||
GX_TF_RGB5A3 : GX_TF_RGB565,
|
||||
GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
__GX_InitTexObjFilterMode(fb_ptr, g_filter, g_filter);
|
||||
__GX_InitTexObj(menu_ptr, menu_tex.data, menu_w, menu_h, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
__GX_InitTexObj(menu_ptr, menu_tex.data, menu_w, menu_h,
|
||||
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
__GX_InitTexObjFilterMode(menu_ptr, g_filter, g_filter);
|
||||
__GX_InvalidateTexAll(__gx);
|
||||
}
|
||||
@ -404,18 +420,23 @@ static void init_vtx(void *data, const video_info_t *video)
|
||||
|
||||
GX_SetNumTexGens(1);
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG,
|
||||
GX_SRC_VTX, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
GX_InvVtxCache();
|
||||
|
||||
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA,
|
||||
GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||
|
||||
if (gx->scale != video->input_scale || gx->rgb32 != video->rgb32)
|
||||
if (gx->scale != video->input_scale ||
|
||||
gx->rgb32 != video->rgb32)
|
||||
{
|
||||
RARCH_LOG("[GX] reallocate texture\n");
|
||||
free(g_tex.data);
|
||||
g_tex.data = memalign(32, RARCH_SCALE_BASE * RARCH_SCALE_BASE * video->input_scale * video->input_scale * (video->rgb32 ? 4 : 2));
|
||||
g_tex.data = memalign(32,
|
||||
RARCH_SCALE_BASE * RARCH_SCALE_BASE * video->input_scale *
|
||||
video->input_scale * (video->rgb32 ? 4 : 2));
|
||||
g_tex.width = g_tex.height = RARCH_SCALE_BASE * video->input_scale;
|
||||
|
||||
if (!g_tex.data)
|
||||
@ -425,7 +446,8 @@ static void init_vtx(void *data, const video_info_t *video)
|
||||
}
|
||||
}
|
||||
|
||||
DCFlushRange(g_tex.data, g_tex.width * g_tex.height * video->rgb32 ? 4 : 2);
|
||||
DCFlushRange(g_tex.data, g_tex.width *
|
||||
g_tex.height * video->rgb32 ? 4 : 2);
|
||||
|
||||
gx->rgb32 = video->rgb32;
|
||||
gx->scale = video->input_scale;
|
||||
@ -450,11 +472,13 @@ static void build_disp_list(void)
|
||||
display_list_size = GX_EndDispList();
|
||||
}
|
||||
|
||||
//#define TAKE_EFB_SCREENSHOT_ON_EXIT
|
||||
#if 0
|
||||
#define TAKE_EFB_SCREENSHOT_ON_EXIT
|
||||
#endif
|
||||
|
||||
#ifdef TAKE_EFB_SCREENSHOT_ON_EXIT
|
||||
|
||||
// Adapted from code by Crayon for GRRLIB (http://code.google.com/p/grrlib)
|
||||
/* Adapted from code by Crayon for GRRLIB (http://code.google.com/p/grrlib) */
|
||||
static void gx_efb_screenshot(void)
|
||||
{
|
||||
int x, y;
|
||||
@ -521,7 +545,8 @@ static void *gx_init(const video_info_t *video,
|
||||
static void update_texture_asm(const uint32_t *src, const uint32_t *dst,
|
||||
unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
register uint32_t tmp0, tmp1, tmp2, tmp3, line2, line2b, line3, line3b, line4, line4b, line5;
|
||||
register uint32_t tmp0, tmp1, tmp2, tmp3, line2, line2b,
|
||||
line3, line3b, line4, line4b, line5;
|
||||
|
||||
asm volatile (
|
||||
" srwi %[width], %[width], 2 \n"
|
||||
@ -631,8 +656,9 @@ static void convert_texture16(const uint32_t *_src, uint32_t *_dst,
|
||||
unsigned tmp_pitch = pitch >> 2;
|
||||
unsigned width2 = width >> 1;
|
||||
|
||||
// Texture data is 4x4 tiled @ 16bpp.
|
||||
// Use 32-bit to transfer more data per cycle.
|
||||
/* Texture data is 4x4 tiled @ 16bpp.
|
||||
* Use 32-bit to transfer more data per cycle.
|
||||
*/
|
||||
const uint32_t *src = _src;
|
||||
uint32_t *dst = _dst;
|
||||
for (unsigned i = 0; i < height; i += 4, dst += 4 * width2)
|
||||
@ -701,24 +727,27 @@ static void gx_resize(void *data)
|
||||
#endif
|
||||
GX_SetDispCopyGamma(g_extern.console.screen.gamma_correction);
|
||||
|
||||
if (gx->keep_aspect && gx_mode.efbHeight >= 480) // ingore this for custom resolutions
|
||||
if (gx->keep_aspect && gx_mode.efbHeight >= 480) /* ignore this for custom resolutions */
|
||||
{
|
||||
float desired_aspect = g_extern.system.aspect_ratio;
|
||||
if (desired_aspect == 0.0)
|
||||
desired_aspect = 1.0;
|
||||
#ifdef HW_RVL
|
||||
float device_aspect = CONF_GetAspectRatio() == CONF_ASPECT_4_3 ? 4.0 / 3.0 : 16.0 / 9.0;
|
||||
float device_aspect = CONF_GetAspectRatio() == CONF_ASPECT_4_3 ?
|
||||
4.0 / 3.0 : 16.0 / 9.0;
|
||||
#else
|
||||
float device_aspect = 4.0 / 3.0;
|
||||
#endif
|
||||
if (g_orientation == ORIENTATION_VERTICAL || g_orientation == ORIENTATION_FLIPPED_ROTATED)
|
||||
if (g_orientation == ORIENTATION_VERTICAL ||
|
||||
g_orientation == ORIENTATION_FLIPPED_ROTATED)
|
||||
desired_aspect = 1.0 / desired_aspect;
|
||||
float delta;
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
if (!g_extern.console.screen.viewports.custom_vp.width || !g_extern.console.screen.viewports.custom_vp.height)
|
||||
if (!g_extern.console.screen.viewports.custom_vp.width ||
|
||||
!g_extern.console.screen.viewports.custom_vp.height)
|
||||
{
|
||||
g_extern.console.screen.viewports.custom_vp.x = 0;
|
||||
g_extern.console.screen.viewports.custom_vp.y = 0;
|
||||
@ -736,8 +765,9 @@ static void gx_resize(void *data)
|
||||
{
|
||||
if (fabs(device_aspect - desired_aspect) < 0.0001)
|
||||
{
|
||||
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),
|
||||
// assume they are actually equal.
|
||||
/* If the aspect ratios of screen and desired aspect ratio
|
||||
* are sufficiently equal (floating point stuff),
|
||||
* assume they are actually equal. */
|
||||
}
|
||||
else if (device_aspect > desired_aspect)
|
||||
{
|
||||
@ -896,7 +926,7 @@ static bool gx_frame(void *data, const void *frame,
|
||||
return true;
|
||||
|
||||
if (!frame)
|
||||
width = height = 4; // draw a black square in the background
|
||||
width = height = 4; /* draw a black square in the background */
|
||||
|
||||
if(gx->should_resize)
|
||||
{
|
||||
@ -939,8 +969,10 @@ static bool gx_frame(void *data, const void *frame,
|
||||
|
||||
if (gx->menu_texture_enable && gx->menu_data)
|
||||
{
|
||||
convert_texture16(gx->menu_data, menu_tex.data, driver.menu->width, driver.menu->height, driver.menu->width * 2);
|
||||
DCFlushRange(menu_tex.data, driver.menu->width * driver.menu->height * 2);
|
||||
convert_texture16(gx->menu_data, menu_tex.data,
|
||||
driver.menu->width, driver.menu->height, driver.menu->width * 2);
|
||||
DCFlushRange(menu_tex.data,
|
||||
driver.menu->width * driver.menu->height * 2);
|
||||
}
|
||||
|
||||
__GX_InvalidateTexAll(__gx);
|
||||
@ -965,7 +997,8 @@ static bool gx_frame(void *data, const void *frame,
|
||||
|
||||
char fps_txt[128], fps_text_buf[128];
|
||||
bool fps_draw = g_settings.fps_show;
|
||||
gfx_get_fps(fps_txt, sizeof(fps_txt), fps_draw ? fps_text_buf : NULL, sizeof(fps_text_buf));
|
||||
gfx_get_fps(fps_txt, sizeof(fps_txt),
|
||||
fps_draw ? fps_text_buf : NULL, sizeof(fps_text_buf));
|
||||
|
||||
if (fps_draw)
|
||||
{
|
||||
@ -975,12 +1008,14 @@ static bool gx_frame(void *data, const void *frame,
|
||||
|
||||
gx_blit_line(x, y, fps_text_buf);
|
||||
y += FONT_HEIGHT * (gx->double_strike ? 1 : 2);
|
||||
snprintf(mem1_txt, sizeof(mem1_txt), "MEM1: %8d / %8d", SYSMEM1_SIZE - SYS_GetArena1Size(), SYSMEM1_SIZE);
|
||||
snprintf(mem1_txt, sizeof(mem1_txt), "MEM1: %8d / %8d",
|
||||
SYSMEM1_SIZE - SYS_GetArena1Size(), SYSMEM1_SIZE);
|
||||
gx_blit_line(x, y, mem1_txt);
|
||||
#ifdef HW_RVL
|
||||
y += FONT_HEIGHT * (gx->double_strike ? 1 : 2);
|
||||
char mem2_txt[128];
|
||||
snprintf(mem2_txt, sizeof(mem2_txt), "MEM2: %8d / %8d", gx_mem2_used(), gx_mem2_total());
|
||||
snprintf(mem2_txt, sizeof(mem2_txt), "MEM2: %8d / %8d",
|
||||
gx_mem2_used(), gx_mem2_total());
|
||||
gx_blit_line(x, y, mem2_txt);
|
||||
#endif
|
||||
}
|
||||
@ -1073,7 +1108,8 @@ static void gx_set_texture_enable(void *data, bool enable, bool full_screen)
|
||||
if (gx)
|
||||
{
|
||||
gx->menu_texture_enable = enable;
|
||||
// need to make sure the game texture is the right pixel format for menu overlay
|
||||
/* need to make sure the game texture is the right pixel
|
||||
* format for menu overlay. */
|
||||
gx->should_resize = true;
|
||||
}
|
||||
}
|
||||
@ -1124,10 +1160,13 @@ static bool gx_overlay_load(void *data, const struct texture_image *images, unsi
|
||||
for (i = 0; i < num_images; i++)
|
||||
{
|
||||
struct gx_overlay_data *o = (struct gx_overlay_data*)&gx->overlay[i];
|
||||
GX_InitTexObj(&o->tex, images[i].pixels, images[i].width, images[i].height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
GX_InitTexObj(&o->tex, images[i].pixels, images[i].width,
|
||||
images[i].height,
|
||||
GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
GX_InitTexObjFilterMode(&g_tex.obj, GX_LINEAR, GX_LINEAR);
|
||||
DCFlushRange(images[i].pixels, images[i].width * images[i].height * sizeof(uint32_t));
|
||||
gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); // Default. Stretch to whole screen.
|
||||
DCFlushRange(images[i].pixels, images[i].width *
|
||||
images[i].height * sizeof(uint32_t));
|
||||
gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); /* Default. Stretch to whole screen. */
|
||||
gx_overlay_vertex_geom(gx, i, 0, 0, 1, 1);
|
||||
gx->overlay[i].alpha_mod = 1.0f;
|
||||
}
|
||||
@ -1136,7 +1175,8 @@ static bool gx_overlay_load(void *data, const struct texture_image *images, unsi
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gx_overlay_tex_geom(void *data, unsigned image, float x, float y, float w, float h)
|
||||
static void gx_overlay_tex_geom(void *data, unsigned image,
|
||||
float x, float y, float w, float h)
|
||||
{
|
||||
gx_video_t *gx = (gx_video_t*)data;
|
||||
struct gx_overlay_data *o;
|
||||
@ -1159,18 +1199,19 @@ static void gx_overlay_tex_geom(void *data, unsigned image, float x, float y, fl
|
||||
}
|
||||
}
|
||||
|
||||
static void gx_overlay_vertex_geom(void *data, unsigned image, float x, float y, float w, float h)
|
||||
static void gx_overlay_vertex_geom(void *data, unsigned image,
|
||||
float x, float y, float w, float h)
|
||||
{
|
||||
gx_video_t *gx = (gx_video_t*)data;
|
||||
struct gx_overlay_data *o;
|
||||
|
||||
o = NULL;
|
||||
|
||||
// Flipped, so we preserve top-down semantics.
|
||||
/* Flipped, so we preserve top-down semantics. */
|
||||
y = 1.0f - y;
|
||||
h = -h;
|
||||
|
||||
// expand from 0 - 1 to -1 - 1
|
||||
/* expand from 0 - 1 to -1 - 1 */
|
||||
x = (x * 2.0f) - 1.0f;
|
||||
y = (y * 2.0f) - 1.0f;
|
||||
w = (w * 2.0f);
|
||||
@ -1224,21 +1265,29 @@ static void gx_render_overlay(void *data)
|
||||
GX_LoadTexObj(&gx->overlay[i].tex, GX_TEXMAP0);
|
||||
|
||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[0], gx->overlay[i].vertex_coord[1], -0.5);
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[0],
|
||||
gx->overlay[i].vertex_coord[1], -0.5);
|
||||
GX_Color4u8(255, 255, 255, (u8)(gx->overlay[i].alpha_mod * 255.0f));
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[0], gx->overlay[i].tex_coord[1]);
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[0],
|
||||
gx->overlay[i].tex_coord[1]);
|
||||
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[2], gx->overlay[i].vertex_coord[3], -0.5);
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[2],
|
||||
gx->overlay[i].vertex_coord[3], -0.5);
|
||||
GX_Color4u8(255, 255, 255, (u8)(gx->overlay[i].alpha_mod * 255.0f));
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[2], gx->overlay[i].tex_coord[3]);
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[2],
|
||||
gx->overlay[i].tex_coord[3]);
|
||||
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[4], gx->overlay[i].vertex_coord[5], -0.5);
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[4],
|
||||
gx->overlay[i].vertex_coord[5], -0.5);
|
||||
GX_Color4u8(255, 255, 255, (u8)(gx->overlay[i].alpha_mod * 255.0f));
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[4], gx->overlay[i].tex_coord[5]);
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[4],
|
||||
gx->overlay[i].tex_coord[5]);
|
||||
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[6], gx->overlay[i].vertex_coord[7], -0.5);
|
||||
GX_Position3f32(gx->overlay[i].vertex_coord[6],
|
||||
gx->overlay[i].vertex_coord[7], -0.5);
|
||||
GX_Color4u8(255, 255, 255, (u8)(gx->overlay[i].alpha_mod * 255.0f));
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[6], gx->overlay[i].tex_coord[7]);
|
||||
GX_TexCoord2f32(gx->overlay[i].tex_coord[6],
|
||||
gx->overlay[i].tex_coord[7]);
|
||||
GX_End();
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,6 @@
|
||||
#include <cell/codec.h>
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
Image decompression - structs
|
||||
********************************************************************************/
|
||||
|
||||
typedef struct CtrlMallocArg
|
||||
{
|
||||
uint32_t mallocCallCounts;
|
||||
@ -73,10 +69,6 @@ static int img_free(void *ptr, void *a)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Image decompression - libJPEG
|
||||
********************************************************************************/
|
||||
|
||||
static bool ps3_load_jpeg(const char *path, struct texture_image *out_img)
|
||||
{
|
||||
size_t img_size;
|
||||
@ -188,10 +180,6 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Image decompression - libPNG
|
||||
********************************************************************************/
|
||||
|
||||
static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
{
|
||||
size_t img_size;
|
||||
@ -269,16 +257,19 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
if (ret != CELL_OK)
|
||||
goto error;
|
||||
|
||||
img_size = outParam.output_width * outParam.output_height * sizeof(uint32_t);
|
||||
img_size = outParam.output_width *
|
||||
outParam.output_height * sizeof(uint32_t);
|
||||
out_img->pixels = (uint32_t*)malloc(img_size);
|
||||
memset(out_img->pixels, 0, img_size);
|
||||
|
||||
#ifdef __PSL1GHT__
|
||||
uint64_t output_bytes_per_line = outParam.output_width * 4;
|
||||
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &output_bytes_per_line, &dOutInfo);
|
||||
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)
|
||||
out_img->pixels, &output_bytes_per_line, &dOutInfo);
|
||||
#else
|
||||
dCtrlParam.output_bytes_per_line = outParam.output_width * 4;
|
||||
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &dCtrlParam, &dOutInfo);
|
||||
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)
|
||||
out_img->pixels, &dCtrlParam, &dOutInfo);
|
||||
#endif
|
||||
|
||||
if (ret != CELL_OK || dOutInfo.status != CELL_PNGDEC_DEC_STATUS_FINISH)
|
||||
|
@ -26,8 +26,10 @@
|
||||
#include "../../general.h"
|
||||
#include "../rpng/rpng.h"
|
||||
|
||||
static bool rpng_image_load_tga_shift(const char *path, struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
|
||||
static bool rpng_image_load_tga_shift(const char *path,
|
||||
struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift,
|
||||
unsigned g_shift, unsigned b_shift)
|
||||
{
|
||||
unsigned i;
|
||||
void *raw_buf = NULL;
|
||||
@ -40,7 +42,7 @@ static bool rpng_image_load_tga_shift(const char *path, struct texture_image *ou
|
||||
|
||||
uint8_t *buf = (uint8_t*)raw_buf;
|
||||
|
||||
if (buf[2] != 2) // Uncompressed RGB
|
||||
if (buf[2] != 2)
|
||||
{
|
||||
RARCH_ERR("TGA image is not uncompressed RGB.\n");
|
||||
free(buf);
|
||||
@ -80,7 +82,8 @@ static bool rpng_image_load_tga_shift(const char *path, struct texture_image *ou
|
||||
uint32_t r = tmp[i * 4 + 2];
|
||||
uint32_t a = tmp[i * 4 + 3];
|
||||
|
||||
out_img->pixels[i] = (a << a_shift) | (r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
out_img->pixels[i] = (a << a_shift) |
|
||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
}
|
||||
else if (bits == 24)
|
||||
@ -92,7 +95,8 @@ static bool rpng_image_load_tga_shift(const char *path, struct texture_image *ou
|
||||
uint32_t r = tmp[i * 3 + 2];
|
||||
uint32_t a = 0xff;
|
||||
|
||||
out_img->pixels[i] = (a << a_shift) | (r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
out_img->pixels[i] = (a << a_shift) |
|
||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -108,15 +112,19 @@ static bool rpng_image_load_tga_shift(const char *path, struct texture_image *ou
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool rpng_image_load_argb_shift(const char *path, struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
|
||||
static bool rpng_image_load_argb_shift(const char *path,
|
||||
struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift,
|
||||
unsigned g_shift, unsigned b_shift)
|
||||
{
|
||||
if (strstr(path, ".tga"))
|
||||
return rpng_image_load_tga_shift(path, out_img, a_shift, r_shift, g_shift, b_shift);
|
||||
return rpng_image_load_tga_shift(path, out_img,
|
||||
a_shift, r_shift, g_shift, b_shift);
|
||||
#ifdef HAVE_ZLIB
|
||||
else if (strstr(path, ".png"))
|
||||
{
|
||||
bool ret = rpng_load_image_argb(path, &out_img->pixels, &out_img->width, &out_img->height);
|
||||
bool ret = rpng_load_image_argb(path,
|
||||
&out_img->pixels, &out_img->width, &out_img->height);
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
@ -134,7 +142,8 @@ static bool rpng_image_load_argb_shift(const char *path, struct texture_image *o
|
||||
uint8_t r = (uint8_t)(col >> 16);
|
||||
uint8_t g = (uint8_t)(col >> 8);
|
||||
uint8_t b = (uint8_t)(col >> 0);
|
||||
pixels[i] = (a << a_shift) | (r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
pixels[i] = (a << a_shift) |
|
||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,8 +176,10 @@ static bool rpng_image_load_argb_shift(const char *path, struct texture_image *o
|
||||
|
||||
static bool rpng_gx_convert_texture32(struct texture_image *image)
|
||||
{
|
||||
// memory allocation in libogc is extremely primitive so try to avoid gaps in memory when converting
|
||||
// by copying over to temp buffer first then converting over into main buffer again
|
||||
/* Memory allocation in libogc is extremely primitive so try
|
||||
* to avoid gaps in memory when converting by copying over to
|
||||
* a temporary buffer first, then converting over into
|
||||
* main buffer again. */
|
||||
void *tmp = malloc(image->width * image->height * sizeof(uint32_t));
|
||||
|
||||
if (!tmp)
|
||||
@ -209,7 +220,7 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
// This interface "leak" is very ugly. FIXME: Fix this properly ...
|
||||
/* This interface "leak" is very ugly. FIXME: Fix this properly ... */
|
||||
if (driver.gfx_use_rgba)
|
||||
ret = rpng_image_load_argb_shift(path, out_img, 24, 0, 8, 16);
|
||||
else
|
||||
|
@ -35,8 +35,10 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
// create a vertex buffer for the quad that will display the texture
|
||||
if (FAILED(D3DDevice_CreateVertexBuffers(d3d->dev, 4 * sizeof(Vertex), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &out_img->vertex_buf, NULL)))
|
||||
/* create a vertex buffer for the quad that will display the texture */
|
||||
if (FAILED(D3DDevice_CreateVertexBuffers(d3d->dev, 4 * sizeof(Vertex),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX,
|
||||
D3DPOOL_MANAGED, &out_img->vertex_buf, NULL)))
|
||||
{
|
||||
RARCH_ERR("Error occurred during CreateVertexBuffer().\n");
|
||||
out_img->pixels->Release();
|
||||
|
Loading…
x
Reference in New Issue
Block a user