mirror of https://code.videolan.org/videolan/vlc
opengl: assume the video area is the same as the "original" area
This commit is contained in:
parent
5b65b93eb1
commit
2b6405c7f4
|
@ -68,6 +68,7 @@ struct vlc_gl_sub_renderer
|
||||||
|
|
||||||
gl_region_t *regions;
|
gl_region_t *regions;
|
||||||
unsigned region_count;
|
unsigned region_count;
|
||||||
|
unsigned output_width, output_height;
|
||||||
|
|
||||||
GLuint program_id;
|
GLuint program_id;
|
||||||
struct {
|
struct {
|
||||||
|
@ -130,6 +131,8 @@ vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
|
||||||
sr->api = api;
|
sr->api = api;
|
||||||
sr->vt = vt;
|
sr->vt = vt;
|
||||||
sr->region_count = 0;
|
sr->region_count = 0;
|
||||||
|
sr->output_width = 0;
|
||||||
|
sr->output_height = 0;
|
||||||
sr->regions = NULL;
|
sr->regions = NULL;
|
||||||
|
|
||||||
static const char *const VERTEX_SHADER_SRC =
|
static const char *const VERTEX_SHADER_SRC =
|
||||||
|
@ -223,12 +226,23 @@ vlc_gl_sub_renderer_Delete(struct vlc_gl_sub_renderer *sr)
|
||||||
free(sr);
|
free(sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vlc_gl_sub_renderer_SetOutputSize(struct vlc_gl_sub_renderer *sr,
|
||||||
|
unsigned width, unsigned height)
|
||||||
|
{
|
||||||
|
sr->output_width = width;
|
||||||
|
sr->output_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
|
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
|
||||||
const vlc_render_subpicture *subpicture)
|
const vlc_render_subpicture *subpicture)
|
||||||
{
|
{
|
||||||
GL_ASSERT_NOERROR(sr->vt);
|
GL_ASSERT_NOERROR(sr->vt);
|
||||||
|
|
||||||
|
if (unlikely(sr->output_width == 0 || sr->output_height == 0))
|
||||||
|
return VLC_EINVAL;
|
||||||
|
|
||||||
const struct vlc_gl_interop *interop = sr->interop;
|
const struct vlc_gl_interop *interop = sr->interop;
|
||||||
|
|
||||||
int last_count = sr->region_count;
|
int last_count = sr->region_count;
|
||||||
|
@ -261,10 +275,10 @@ vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
|
||||||
glr->tex_height = 1.0;
|
glr->tex_height = 1.0;
|
||||||
}
|
}
|
||||||
glr->alpha = (float)r->i_alpha / 255;
|
glr->alpha = (float)r->i_alpha / 255;
|
||||||
glr->left = 2.0 * (r->place.x ) / subpicture->i_original_picture_width - 1.0;
|
glr->left = 2.0 * (r->place.x ) / sr->output_width - 1.0;
|
||||||
glr->top = -2.0 * (r->place.y ) / subpicture->i_original_picture_height + 1.0;
|
glr->top = -2.0 * (r->place.y ) / sr->output_height + 1.0;
|
||||||
glr->right = 2.0 * (r->place.x + r->place.width ) / subpicture->i_original_picture_width - 1.0;
|
glr->right = 2.0 * (r->place.x + r->place.width ) / sr->output_width - 1.0;
|
||||||
glr->bottom = -2.0 * (r->place.y + r->place.height) / subpicture->i_original_picture_height + 1.0;
|
glr->bottom = -2.0 * (r->place.y + r->place.height) / sr->output_height + 1.0;
|
||||||
|
|
||||||
glr->texture = 0;
|
glr->texture = 0;
|
||||||
/* Try to recycle the textures allocated by the previous
|
/* Try to recycle the textures allocated by the previous
|
||||||
|
|
|
@ -72,6 +72,13 @@ int
|
||||||
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
|
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
|
||||||
const struct vlc_render_subpicture *subpicture);
|
const struct vlc_render_subpicture *subpicture);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the output size
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
vlc_gl_sub_renderer_SetOutputSize(struct vlc_gl_sub_renderer *sr,
|
||||||
|
unsigned width, unsigned height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the prepared subpicture
|
* Draw the prepared subpicture
|
||||||
*
|
*
|
||||||
|
|
|
@ -358,6 +358,7 @@ void vout_display_opengl_SetOutputSize(vout_display_opengl_t *vgl,
|
||||||
/* The renderer, last filter in the chain, necessarily accepts the new
|
/* The renderer, last filter in the chain, necessarily accepts the new
|
||||||
* output size */
|
* output size */
|
||||||
assert(ret == VLC_SUCCESS);
|
assert(ret == VLC_SUCCESS);
|
||||||
|
vlc_gl_sub_renderer_SetOutputSize(vgl->sub_renderer, width, height);
|
||||||
(void) ret;
|
(void) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,8 @@ static void test_opengl_offscreen(
|
||||||
memcpy(&picture->p[0].p_pixels[0 * 4 + picture->p[0].i_pitch], blue, sizeof(blue));
|
memcpy(&picture->p[0].p_pixels[0 * 4 + picture->p[0].i_pitch], blue, sizeof(blue));
|
||||||
memcpy(&picture->p[0].p_pixels[1 * 4 + picture->p[0].i_pitch], white, sizeof(white));
|
memcpy(&picture->p[0].p_pixels[1 * 4 + picture->p[0].i_pitch], white, sizeof(white));
|
||||||
|
|
||||||
|
vlc_gl_sub_renderer_SetOutputSize(sr, 4, 4);
|
||||||
|
|
||||||
vlc_render_subpicture *subpicture = vlc_render_subpicture_New();
|
vlc_render_subpicture *subpicture = vlc_render_subpicture_New();
|
||||||
assert(subpicture != NULL);
|
assert(subpicture != NULL);
|
||||||
subpicture->i_original_picture_width = 4;
|
subpicture->i_original_picture_width = 4;
|
||||||
|
|
Loading…
Reference in New Issue