gl/viv-fb: transform screen coordinate to viewport coordinate

In y direction, screen coordinate are opposite to viewport coordinate.

https://bugzilla.gnome.org/show_bug.cgi?id=787394
This commit is contained in:
Haihua Hu 2017-09-11 16:00:24 +08:00 committed by Matthew Waters
parent 039c983a9f
commit b738774566

View file

@ -214,16 +214,29 @@ _free_set_render_rectangle (SetRenderRectangleData * render)
}
}
static void
_calculate_viewport_coordinates(GstGLWindowVivFBEGL * window_egl,
GstVideoRectangle * req, GstVideoRectangle * result)
{
result->x = req->x;
result->y = window_egl->window_height - (req->y + req->h);
result->w = req->w;
result->h = req->h;
}
static void
_set_render_rectangle (gpointer data)
{
SetRenderRectangleData *render = data;
GstGLWindow *window = GST_GL_WINDOW (render->window_egl);
GstGLWindowVivFBEGL *window_egl = render->window_egl;
GstGLWindow *window = GST_GL_WINDOW (window_egl);
GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
render->rect.x, render->rect.y, render->rect.w, render->rect.h);
render->window_egl->render_rectangle = render->rect;
_calculate_viewport_coordinates (window_egl, &render->rect,
&window_egl->render_rectangle);
gst_gl_window_resize (window, render->rect.w, render->rect.h);
window->queue_resize = TRUE;