mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
glwindow_cocoa: fix a leak of the GstNSView
This leak is also causing a leak of the GstGLCAOpenGLLayer which leaks the GstGLWrappedContext and the GstGLDisplay Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2736>
This commit is contained in:
parent
7db2a3cf11
commit
94e1ddad43
1 changed files with 12 additions and 15 deletions
|
@ -92,6 +92,7 @@ static gboolean gst_gl_window_cocoa_controls_viewport (GstGLWindow * window);
|
|||
struct _GstGLWindowCocoaPrivate
|
||||
{
|
||||
gpointer internal_win_id;
|
||||
gpointer internal_view;
|
||||
gpointer external_view;
|
||||
gboolean visible;
|
||||
gint preferred_width;
|
||||
|
@ -222,6 +223,7 @@ gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa)
|
|||
backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: window_cocoa];
|
||||
|
||||
priv->internal_win_id = (__bridge_retained gpointer)internal_win_id;
|
||||
priv->internal_view = (__bridge gpointer)glView;
|
||||
|
||||
GST_DEBUG ("NSWindow id: %"G_GUINTPTR_FORMAT, (guintptr) priv->internal_win_id);
|
||||
|
||||
|
@ -247,12 +249,15 @@ static void
|
|||
_close_window (gpointer * data)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (data);
|
||||
GstGLNSWindow *internal_win_id =
|
||||
(__bridge GstGLNSWindow *) window_cocoa->priv->internal_win_id;
|
||||
GstGLNSView *view =
|
||||
(__bridge GstGLNSView *) window_cocoa->priv->internal_view;
|
||||
|
||||
[view removeFromSuperview];
|
||||
|
||||
[[internal_win_id contentView] removeFromSuperview];
|
||||
CFBridgingRelease (window_cocoa->priv->internal_win_id);
|
||||
CFBridgingRelease (window_cocoa->priv->internal_view);
|
||||
window_cocoa->priv->internal_win_id = NULL;
|
||||
window_cocoa->priv->internal_view = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -293,8 +298,8 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
|
|||
(__bridge GstGLNSWindow *)window_cocoa->priv->internal_win_id;
|
||||
NSView *external_view =
|
||||
(__bridge NSView *)window_cocoa->priv->external_view;
|
||||
NSView *view = (__bridge NSView *)window_cocoa->priv->internal_view;
|
||||
|
||||
NSView *view = [internal_win_id contentView];
|
||||
[internal_win_id orderOut:internal_win_id];
|
||||
|
||||
[external_view addSubview: view];
|
||||
|
@ -350,15 +355,12 @@ static void
|
|||
gst_gl_window_cocoa_queue_resize (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
|
||||
GstGLNSView *view;
|
||||
GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
|
||||
GstGLNSView *view = (__bridge GstGLNSView *)priv->internal_view;
|
||||
|
||||
if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
|
||||
return;
|
||||
|
||||
view = (GstGLNSView *)[internal_win_id contentView];
|
||||
|
||||
[view->layer queueResize];
|
||||
}
|
||||
|
||||
|
@ -366,17 +368,14 @@ static void
|
|||
gst_gl_window_cocoa_draw (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
|
||||
GstGLNSView *view;
|
||||
GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
|
||||
GstGLNSView *view = (__bridge GstGLNSView *)priv->internal_view;
|
||||
|
||||
/* As the view is created asynchronously in the main thread we cannot know
|
||||
* exactly when it will be ready to draw to */
|
||||
if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
|
||||
return;
|
||||
|
||||
view = (GstGLNSView *)[internal_win_id contentView];
|
||||
|
||||
/* this redraws the GstGLCAOpenGLLayer which calls
|
||||
* gst_gl_window_cocoa_draw_thread(). Use an explicit CATransaction since we
|
||||
* don't know how often the main runloop is running.
|
||||
|
@ -545,9 +544,8 @@ static void
|
|||
_set_render_rectangle (gpointer data)
|
||||
{
|
||||
struct SetRenderRectangle *render = data;
|
||||
NSView *view;
|
||||
GstGLWindowCocoaPrivate *priv = render->window_cocoa->priv;
|
||||
GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)priv->internal_win_id;
|
||||
GstGLNSView *view = (__bridge GstGLNSView *)priv->internal_view;
|
||||
|
||||
GST_LOG_OBJECT (render->window_cocoa, "setting render rectangle %i,%i+%ix%i",
|
||||
render->rect.x, render->rect.y, render->rect.w, render->rect.h);
|
||||
|
@ -555,7 +553,6 @@ _set_render_rectangle (gpointer data)
|
|||
return;
|
||||
}
|
||||
|
||||
view = [internal_win_id contentView];
|
||||
NSRect newMainViewFrame = NSMakeRect(render->rect.x,
|
||||
render->rect.y,
|
||||
render->rect.w,
|
||||
|
|
Loading…
Reference in a new issue