mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 03:56:16 +00:00
gl/caopengllayer: use public GstGLContext instead of Cocoa-specific one
Allows keeping the GstGLCAOpenGLLayer public but not the winsys-specific context/display/window.
This commit is contained in:
parent
9c20be77e7
commit
a3ce46a454
4 changed files with 12 additions and 16 deletions
|
@ -331,7 +331,7 @@ _create_layer (gpointer data)
|
||||||
|
|
||||||
if (!ca_sink->layer) {
|
if (!ca_sink->layer) {
|
||||||
layer = [[NSClassFromString(@"GstGLCAOpenGLLayer") alloc]
|
layer = [[NSClassFromString(@"GstGLCAOpenGLLayer") alloc]
|
||||||
initWithGstGLContext:GST_GL_CONTEXT_COCOA (ca_sink->context)];
|
initWithGstGLContext:ca_sink->context];
|
||||||
|
|
||||||
ca_sink->layer = (__bridge_retained gpointer)layer;
|
ca_sink->layer = (__bridge_retained gpointer)layer;
|
||||||
[layer setDrawCallback:(GstGLWindowCB)gst_ca_opengl_layer_sink_on_draw
|
[layer setDrawCallback:(GstGLWindowCB)gst_ca_opengl_layer_sink_on_draw
|
||||||
|
|
|
@ -51,10 +51,6 @@
|
||||||
#include <gst/gl/egl/gstglcontext_egl.h>
|
#include <gst/gl/egl/gstglcontext_egl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_CGL && defined (HAVE_QT_MAC)
|
|
||||||
#include <gst/gl/cocoa/gstgldisplay_cocoa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT qt_gl_utils_debug
|
#define GST_CAT_DEFAULT qt_gl_utils_debug
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
|
|
||||||
|
@ -126,7 +122,7 @@ gst_qt_get_gl_display ()
|
||||||
|
|
||||||
#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_CGL && defined (HAVE_QT_MAC)
|
#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_CGL && defined (HAVE_QT_MAC)
|
||||||
if (QString::fromUtf8 ("cocoa") == app->platformName())
|
if (QString::fromUtf8 ("cocoa") == app->platformName())
|
||||||
display = (GstGLDisplay *) gst_gl_display_cocoa_new ();
|
display = (GstGLDisplay *) gst_gl_display_new ();
|
||||||
#endif
|
#endif
|
||||||
#if GST_GL_HAVE_WINDOW_EAGL && GST_GL_HAVE_PLATFORM_EAGL && defined (HAVE_QT_IOS)
|
#if GST_GL_HAVE_WINDOW_EAGL && GST_GL_HAVE_PLATFORM_EAGL && defined (HAVE_QT_IOS)
|
||||||
if (QString::fromUtf8 ("ios") == app->platformName())
|
if (QString::fromUtf8 ("ios") == app->platformName())
|
||||||
|
|
|
@ -25,13 +25,11 @@
|
||||||
#include <gst/gl/gl.h>
|
#include <gst/gl/gl.h>
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#include <gst/gl/cocoa/gstglcontext_cocoa.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@interface GstGLCAOpenGLLayer : CAOpenGLLayer {
|
@interface GstGLCAOpenGLLayer : CAOpenGLLayer {
|
||||||
@public
|
@public
|
||||||
GstGLContextCocoa *gst_gl_context;
|
GstGLContext *gst_gl_context;
|
||||||
CGLContextObj gl_context;
|
CGLContextObj gl_context;
|
||||||
|
|
||||||
@private
|
@private
|
||||||
|
@ -53,7 +51,7 @@ G_BEGIN_DECLS
|
||||||
- (void) setDrawCallback:(GstGLWindowCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
|
- (void) setDrawCallback:(GstGLWindowCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
|
||||||
- (void) setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
|
- (void) setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
|
||||||
- (void) queueResize;
|
- (void) queueResize;
|
||||||
- (id) initWithGstGLContext: (GstGLContextCocoa *)context;
|
- (id) initWithGstGLContext: (GstGLContext *)context;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -62,7 +62,9 @@ _context_ready (gpointer data)
|
||||||
g_atomic_int_set (&ca_layer->can_draw, 1);
|
g_atomic_int_set (&ca_layer->can_draw, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithGstGLContext:(GstGLContextCocoa *)parent_gl_context {
|
- (id)initWithGstGLContext:(GstGLContext *)parent_gl_context {
|
||||||
|
g_return_val_if_fail (GST_IS_GL_CONTEXT_COCOA (parent_gl_context), nil);
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
_init_debug();
|
_init_debug();
|
||||||
|
@ -72,7 +74,7 @@ _context_ready (gpointer data)
|
||||||
self->gst_gl_context = parent_gl_context;
|
self->gst_gl_context = parent_gl_context;
|
||||||
self.needsDisplayOnBoundsChange = YES;
|
self.needsDisplayOnBoundsChange = YES;
|
||||||
|
|
||||||
gst_gl_window_send_message_async (GST_GL_CONTEXT (parent_gl_context)->window,
|
gst_gl_window_send_message_async (parent_gl_context->window,
|
||||||
(GstGLWindowCB) _context_ready, (__bridge_retained gpointer)self, (GDestroyNotify)CFRelease);
|
(GstGLWindowCB) _context_ready, (__bridge_retained gpointer)self, (GDestroyNotify)CFRelease);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -82,7 +84,7 @@ _context_ready (gpointer data)
|
||||||
CGLPixelFormatObj fmt = NULL;
|
CGLPixelFormatObj fmt = NULL;
|
||||||
|
|
||||||
if (self->gst_gl_context)
|
if (self->gst_gl_context)
|
||||||
fmt = gst_gl_context_cocoa_get_pixel_format (self->gst_gl_context);
|
fmt = gst_gl_context_cocoa_get_pixel_format (GST_GL_CONTEXT_COCOA (self->gst_gl_context));
|
||||||
|
|
||||||
if (!fmt) {
|
if (!fmt) {
|
||||||
CGLPixelFormatAttribute attribs[] = {
|
CGLPixelFormatAttribute attribs[] = {
|
||||||
|
@ -111,7 +113,7 @@ _context_ready (gpointer data)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (self->gst_gl_context)
|
if (self->gst_gl_context)
|
||||||
external_context = (CGLContextObj) gst_gl_context_get_gl_context (GST_GL_CONTEXT (self->gst_gl_context));
|
external_context = (CGLContextObj) gst_gl_context_get_gl_context (self->gst_gl_context);
|
||||||
|
|
||||||
GST_INFO ("attempting to create CGLContext for CAOpenGLLayer with "
|
GST_INFO ("attempting to create CGLContext for CAOpenGLLayer with "
|
||||||
"share context %p", external_context);
|
"share context %p", external_context);
|
||||||
|
@ -130,7 +132,7 @@ _context_ready (gpointer data)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
display = gst_gl_context_get_display (GST_GL_CONTEXT (self->gst_gl_context));
|
display = gst_gl_context_get_display (self->gst_gl_context);
|
||||||
self->draw_context = gst_gl_context_new_wrapped (display,
|
self->draw_context = gst_gl_context_new_wrapped (display,
|
||||||
(guintptr) self->gl_context, GST_GL_PLATFORM_CGL,
|
(guintptr) self->gl_context, GST_GL_PLATFORM_CGL,
|
||||||
gst_gl_context_get_current_gl_api (GST_GL_PLATFORM_CGL, NULL, NULL));
|
gst_gl_context_get_current_gl_api (GST_GL_PLATFORM_CGL, NULL, NULL));
|
||||||
|
@ -142,7 +144,7 @@ _context_ready (gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_gl_context_activate (self->draw_context, TRUE);
|
gst_gl_context_activate (self->draw_context, TRUE);
|
||||||
gst_gl_context_set_shared_with (self->draw_context, GST_GL_CONTEXT (self->gst_gl_context));
|
gst_gl_context_set_shared_with (self->draw_context, self->gst_gl_context);
|
||||||
if (!gst_gl_context_fill_info (self->draw_context, &error)) {
|
if (!gst_gl_context_fill_info (self->draw_context, &error)) {
|
||||||
GST_ERROR ("failed to fill wrapped context information: %s", error->message);
|
GST_ERROR ("failed to fill wrapped context information: %s", error->message);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue