summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-09-29 09:33:42 +0300
committerSebastian Dröge <sebastian@centricular.com>2014-10-14 10:01:20 +0200
commit308e80742a01756dbc6ee4d09f1202c7c9ccfac9 (patch)
tree2eb4e4bbb3c41532e31583a45d48818363e295da
parent20fc76ef6b00d77821bdd2ae9bf452e63813e373 (diff)
downloadgstreamer-plugins-bad-308e80742a01756dbc6ee4d09f1202c7c9ccfac9.tar.gz
gl/cocoa: Update viewport according to the current clipping
We have to update the GL viewport if the NSView is only partially visible. Otherwise the content of the frame will be visibly offset.
-rw-r--r--gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m40
1 files changed, 28 insertions, 12 deletions
diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
index df481441a..f0333b94c 100644
--- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
+++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
@@ -83,6 +83,9 @@ struct _GstGLWindowCocoaPrivate
gboolean visible;
GMainContext *main_context;
GMainLoop *loop;
+
+ GLint viewport_dim[4];
+ NSRect bounds, visibleRect;
};
static void
@@ -505,7 +508,6 @@ struct resize
{
GstGLWindowCocoa * window;
NSRect bounds, visibleRect;
- NSSize frameSize;
};
static void
@@ -518,12 +520,29 @@ resize_cb (gpointer data)
NSOpenGLContext * glContext = (NSOpenGLContext *) gst_gl_context_get_gl_context (context);
if (g_main_loop_is_running (window_cocoa->priv->loop) && ![window_cocoa->priv->internal_win_id isClosed]) {
- /* FIXME: Need to adjust viewport for clipping here */
- if (window->resize) {
- window->resize (window->resize_data, resize_data->bounds.size.width, resize_data->bounds.size.height);
- }
+ const GstGLFuncs *gl;
[glContext update];
+
+ if (window_cocoa->priv->bounds.size.width != resize_data->bounds.size.width ||
+ window_cocoa->priv->bounds.size.height != resize_data->bounds.size.height ||
+ window_cocoa->priv->visibleRect.origin.x != resize_data->visibleRect.origin.x ||
+ window_cocoa->priv->visibleRect.origin.y != resize_data->visibleRect.origin.y) {
+ gl = context->gl_vtable;
+
+ if (window->resize) {
+ window->resize (window->resize_data, resize_data->bounds.size.width, resize_data->bounds.size.height);
+ gl->GetIntegerv (GL_VIEWPORT, window_cocoa->priv->viewport_dim);
+ }
+
+ gl->Viewport (window_cocoa->priv->viewport_dim[0] - resize_data->visibleRect.origin.x,
+ window_cocoa->priv->viewport_dim[1] - resize_data->visibleRect.origin.y,
+ window_cocoa->priv->viewport_dim[2], window_cocoa->priv->viewport_dim[3]);
+
+ window_cocoa->priv->visibleRect = resize_data->visibleRect;
+ window_cocoa->priv->bounds = resize_data->bounds;
+ }
+
GST_GL_WINDOW (window_cocoa)->draw (GST_GL_WINDOW (window_cocoa)->draw_data);
[glContext flushBuffer];
}
@@ -542,21 +561,18 @@ resize_cb (gpointer data)
if (window->resize) {
NSRect bounds = [self bounds];
NSRect visibleRect = [self visibleRect];
- NSSize frameSize = [self frame].size;
struct resize *resize_data = g_new (struct resize, 1);
- GST_DEBUG_OBJECT (window, "Window resized: bounds %lf %lf %lf %lf, "
- "visibleRect %lf %lf %lf %lf, frame size %lf %lf",
+ GST_DEBUG_OBJECT (window, "Window resized: bounds %lf %lf %lf %lf "
+ "visibleRect %lf %lf %lf %lf",
bounds.origin.x, bounds.origin.y,
bounds.size.width, bounds.size.height,
visibleRect.origin.x, visibleRect.origin.y,
- visibleRect.size.width, visibleRect.size.height,
- frameSize.width, frameSize.height);
+ visibleRect.size.width, visibleRect.size.height);
resize_data->window = window_cocoa;
resize_data->bounds = bounds;
resize_data->visibleRect = visibleRect;
- resize_data->frameSize = frameSize;
gst_gl_window_send_message_async (GST_GL_WINDOW (window_cocoa), (GstGLWindowCB) resize_cb, resize_data, (GDestroyNotify) g_free);
}
@@ -567,7 +583,7 @@ resize_cb (gpointer data)
}
- (BOOL) isFlipped {
- return YES;
+ return NO;
}
@end