gl/viv-fb: transform screen coordinate to viewport coordinate
authorHaihua Hu <jared.hu@nxp.com>
Mon, 11 Sep 2017 08:00:24 +0000 (16:00 +0800)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:30 +0000 (19:32 +0000)
In y direction, screen coordinate are opposite to viewport coordinate.

https://bugzilla.gnome.org/show_bug.cgi?id=787394

gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c

index f6b2391..8515dc8 100644 (file)
@@ -215,15 +215,28 @@ _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;