mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
glwindow: remove width/height from _draw()
Depending on the platform, it was only ever implemented to 1) set a default surface size, 2) resize based on the video frame or 3) nothing. Instead, provide a set_preferred_size () that elements/applications can use to request a certain size which may be ignored for videooverlay/other cases.
This commit is contained in:
parent
4fc554054c
commit
ab48bb6f0f
14 changed files with 177 additions and 149 deletions
|
@ -1444,8 +1444,9 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
|
|||
/* Drawing is asynchronous: gst_gl_window_draw is not blocking
|
||||
* It means that it does not wait for stuff to be executed in other threads
|
||||
*/
|
||||
gst_gl_window_draw (window, GST_VIDEO_SINK_WIDTH (gl_sink),
|
||||
gst_gl_window_set_preferred_size (window, GST_VIDEO_SINK_WIDTH (gl_sink),
|
||||
GST_VIDEO_SINK_HEIGHT (gl_sink));
|
||||
gst_gl_window_draw (window);
|
||||
}
|
||||
alive = gst_gl_window_is_running (window);
|
||||
gst_object_unref (window);
|
||||
|
|
|
@ -44,8 +44,7 @@ static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
|
|||
window);
|
||||
static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static void gst_gl_window_android_egl_draw (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
static void gst_gl_window_android_egl_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_android_egl_run (GstGLWindow * window);
|
||||
static void gst_gl_window_android_egl_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_android_egl_send_message_async (GstGLWindow * window,
|
||||
|
@ -200,17 +199,10 @@ gst_gl_window_android_egl_get_window_handle (GstGLWindow * window)
|
|||
return (guintptr) window_egl->native_window;
|
||||
}
|
||||
|
||||
struct draw
|
||||
{
|
||||
GstGLWindowAndroidEGL *window;
|
||||
guint width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLWindowAndroidEGL *window_egl = draw_data->window;
|
||||
GstGLWindowAndroidEGL *window_egl = data;
|
||||
GstGLWindow *window = GST_GL_WINDOW (window_egl);
|
||||
GstGLContext *context = gst_gl_window_get_context (window);
|
||||
GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
|
||||
|
@ -242,16 +234,9 @@ draw_cb (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_android_egl_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_android_egl_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
||||
|
||||
draw_data.window = window_egl;
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
||||
static guintptr
|
||||
|
|
|
@ -32,9 +32,12 @@ G_BEGIN_DECLS
|
|||
|
||||
struct _GstGLContextCocoaPrivate
|
||||
{
|
||||
CGLContextObj gl_context;
|
||||
CGLPixelFormatObj pixel_format;
|
||||
CGLContextObj gl_context;
|
||||
CGLContextObj external_gl_context;
|
||||
|
||||
GstGLAPI context_api;
|
||||
|
||||
gint source_id;
|
||||
};
|
||||
|
||||
|
@ -46,8 +49,11 @@ struct _GstGLContextCocoaPrivate
|
|||
/* =============================================================*/
|
||||
|
||||
@interface GstGLCAOpenGLLayer : CAOpenGLLayer {
|
||||
@public
|
||||
GstGLContextCocoa *gst_gl_context;
|
||||
CGLContextObj gl_context;
|
||||
|
||||
@private
|
||||
gint expected_dims[4];
|
||||
}
|
||||
- (id)initWithGstGLContext:(GstGLContextCocoa *)context;
|
||||
|
@ -55,6 +61,7 @@ struct _GstGLContextCocoaPrivate
|
|||
@end
|
||||
|
||||
@interface GstGLNSView: NSView {
|
||||
@public
|
||||
GstGLWindowCocoa *window_cocoa;
|
||||
GstGLCAOpenGLLayer *layer;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
gl->Viewport (result.x, result.y, result.w, result.h);
|
||||
|
||||
if (window) {
|
||||
gst_gl_window_cocoa_draw_thread (GST_GL_WINDOW_COCOA (window), 320, 240);
|
||||
gst_gl_window_cocoa_draw_thread (GST_GL_WINDOW_COCOA (window));
|
||||
|
||||
gst_object_unref (window);
|
||||
}
|
||||
|
|
|
@ -60,8 +60,7 @@ GType gst_gl_window_cocoa_get_type (void);
|
|||
|
||||
GstGLWindowCocoa * gst_gl_window_cocoa_new (void);
|
||||
|
||||
void gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa,
|
||||
guint width, guint height);
|
||||
void gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -70,11 +70,13 @@ static void gst_gl_window_cocoa_close (GstGLWindow *window);
|
|||
static guintptr gst_gl_window_cocoa_get_window_handle (GstGLWindow * window);
|
||||
static void gst_gl_window_cocoa_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static void gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height);
|
||||
static void gst_gl_window_cocoa_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_cocoa_run (GstGLWindow * window);
|
||||
static void gst_gl_window_cocoa_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
|
||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
||||
static void gst_gl_window_cocoa_set_preferred_size (GstGLWindow * window,
|
||||
gint width, gint height);
|
||||
|
||||
struct _GstGLWindowCocoaPrivate
|
||||
{
|
||||
|
@ -83,6 +85,8 @@ struct _GstGLWindowCocoaPrivate
|
|||
gboolean visible;
|
||||
GMainContext *main_context;
|
||||
GMainLoop *loop;
|
||||
gint preferred_width;
|
||||
gint preferred_height;
|
||||
|
||||
GLint viewport_dim[4];
|
||||
};
|
||||
|
@ -108,12 +112,17 @@ gst_gl_window_cocoa_class_init (GstGLWindowCocoaClass * klass)
|
|||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_quit);
|
||||
window_class->send_message_async =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_send_message_async);
|
||||
window_class->set_preferred_size =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_set_preferred_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_cocoa_init (GstGLWindowCocoa * window)
|
||||
{
|
||||
window->priv = GST_GL_WINDOW_COCOA_GET_PRIVATE (window);
|
||||
|
||||
window->priv->preferred_width = 320;
|
||||
window->priv->preferred_height = 240;
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -212,7 +221,7 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa, guint width, guint height)
|
||||
gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa)
|
||||
{
|
||||
GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
|
||||
|
@ -235,8 +244,8 @@ gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa, guint width, gu
|
|||
|
||||
windowRect.origin.x += x;
|
||||
windowRect.origin.y += mainRect.size.height > y ? (mainRect.size.height - y) * 0.5 : y;
|
||||
windowRect.size.width = width;
|
||||
windowRect.size.height = height;
|
||||
windowRect.size.width = window_cocoa->priv->preferred_width;
|
||||
windowRect.size.height = window_cocoa->priv->preferred_height;
|
||||
|
||||
GST_DEBUG ("window rect: %d %d %d %d\n", (int) windowRect.origin.x,
|
||||
(int) windowRect.origin.y, (int) windowRect.size.width,
|
||||
|
@ -264,7 +273,7 @@ gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa, guint width, gu
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_cocoa_draw (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
|
||||
GstGLNSView *view = (GstGLNSView *)[window_cocoa->priv->internal_win_id contentView];
|
||||
|
@ -277,6 +286,16 @@ gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height)
|
|||
});
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_cocoa_set_preferred_size (GstGLWindow * window, gint width,
|
||||
gint height)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
|
||||
|
||||
window_cocoa->priv->preferred_width = width;
|
||||
window_cocoa->priv->preferred_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_cocoa_run (GstGLWindow * window)
|
||||
{
|
||||
|
@ -501,7 +520,7 @@ resize_cb (gpointer data)
|
|||
gl_layer = ((GstGLNSView *)[window_cocoa->priv->internal_win_id contentView])->layer;
|
||||
[gl_layer resize:resize_data->bounds];
|
||||
|
||||
gst_gl_window_draw (window, resize_data->bounds.size.width, resize_data->bounds.size.height);
|
||||
gst_gl_window_draw (window);
|
||||
}
|
||||
gst_object_unref (context);
|
||||
[pool release];
|
||||
|
|
|
@ -39,8 +39,9 @@ static guintptr gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow *
|
|||
window);
|
||||
static void gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static void gst_gl_window_dispmanx_egl_draw (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
static void gst_gl_window_dispmanx_set_preferred_size (GstGLWindow * window,
|
||||
gint width, gint height);
|
||||
static void gst_gl_window_dispmanx_egl_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_dispmanx_egl_run (GstGLWindow * window);
|
||||
static void gst_gl_window_dispmanx_egl_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_dispmanx_egl_send_message_async (GstGLWindow * window,
|
||||
|
@ -74,6 +75,8 @@ gst_gl_window_dispmanx_egl_class_init (GstGLWindowDispmanxEGLClass * klass)
|
|||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_open);
|
||||
window_class->get_display =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_display);
|
||||
window_class->set_preferred_size =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_preferred_size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -227,6 +230,15 @@ gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_dispmanx_set_preferred_size (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
||||
|
||||
window_egl->preferred_width = width;
|
||||
window_egl->preferred_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height)
|
||||
{
|
||||
|
@ -275,33 +287,27 @@ window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height)
|
|||
vc_dispmanx_update_submit_sync (dispman_update);
|
||||
|
||||
if (GST_GL_WINDOW (window_egl)->resize)
|
||||
GST_GL_WINDOW (window_egl)->resize (GST_GL_WINDOW (window_egl)->
|
||||
resize_data, width, height);
|
||||
GST_GL_WINDOW (window_egl)->
|
||||
resize (GST_GL_WINDOW (window_egl)->resize_data, width, height);
|
||||
}
|
||||
|
||||
window_egl->native.width = width;
|
||||
window_egl->native.height = height;
|
||||
}
|
||||
|
||||
struct draw
|
||||
{
|
||||
GstGLWindowDispmanxEGL *window;
|
||||
guint width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLWindowDispmanxEGL *window_egl = draw_data->window;
|
||||
GstGLWindowDispmanxEGL *window_egl = data;
|
||||
GstGLWindow *window = GST_GL_WINDOW (window_egl);
|
||||
GstGLContext *context = gst_gl_window_get_context (window);
|
||||
GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
|
||||
|
||||
if (window_egl->native.width != draw_data->width
|
||||
|| window_egl->native.height != draw_data->height) {
|
||||
if (window_egl->native.width != window_egl->preferred_width
|
||||
|| window_egl->native.height != window_egl->preferred_height) {
|
||||
GST_DEBUG ("dimensions don't match, attempting resize");
|
||||
window_resize (window_egl, draw_data->width, draw_data->height);
|
||||
window_resize (window_egl, window_egl->preferred_width,
|
||||
window_egl->preferred_height);
|
||||
}
|
||||
|
||||
if (window->draw)
|
||||
|
@ -313,16 +319,9 @@ draw_cb (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_dispmanx_egl_draw (GstGLWindow * window, guint width,
|
||||
guint height)
|
||||
gst_gl_window_dispmanx_egl_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
|
||||
draw_data.window = GST_GL_WINDOW_DISPMANX_EGL (window);
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
||||
static guintptr
|
||||
|
|
|
@ -48,6 +48,9 @@ struct _GstGLWindowDispmanxEGL {
|
|||
uint32_t dp_width;
|
||||
EGL_DISPMANX_WINDOW_T native;
|
||||
|
||||
gint preferred_width;
|
||||
gint preferred_height;
|
||||
|
||||
GMainContext *main_context;
|
||||
GMainLoop *loop;
|
||||
|
||||
|
|
|
@ -45,8 +45,9 @@ static guintptr gst_gl_window_eagl_get_display (GstGLWindow * window);
|
|||
static guintptr gst_gl_window_eagl_get_window_handle (GstGLWindow * window);
|
||||
static void gst_gl_window_eagl_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static void gst_gl_window_eagl_draw (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
static void gst_gl_window_eagl_set_preferred_size (GstGLWindow * window,
|
||||
gint width gint height);
|
||||
static void gst_gl_window_eagl_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_eagl_run (GstGLWindow * window);
|
||||
static void gst_gl_window_eagl_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
||||
|
@ -58,6 +59,7 @@ struct _GstGLWindowEaglPrivate
|
|||
{
|
||||
UIView *view;
|
||||
gint window_width, window_height;
|
||||
gint preferred_width, preferred_height;
|
||||
|
||||
GMainContext *main_context;
|
||||
GMainLoop *loop;
|
||||
|
@ -86,6 +88,8 @@ gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_send_message_async);
|
||||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_open);
|
||||
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_close);
|
||||
window_class->set_preferred_size =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_preferred_size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -215,17 +219,19 @@ gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
|||
(GSourceFunc) _run_message, message);
|
||||
}
|
||||
|
||||
struct draw
|
||||
static void
|
||||
gst_gl_window_eagl_set_preferred_size (GstGLWindow * window, gint width, gint height)
|
||||
{
|
||||
GstGLWindowEagl *window;
|
||||
guint width, height;
|
||||
};
|
||||
GstGLWdindowEagl *window_eagl = GST_GL_WINDOW_EAGL (window);
|
||||
|
||||
window_eagl->priv->preferred_width = width;
|
||||
window_eagl->priv->preferred_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLWindowEagl *window_eagl = draw_data->window;
|
||||
GstGLWindowEagl *window_eagl = data;
|
||||
GstGLWindow *window = GST_GL_WINDOW (window_eagl);
|
||||
GstGLContext *context = gst_gl_window_get_context (window);
|
||||
GstGLContextEagl *eagl_context = GST_GL_CONTEXT_EAGL (context);
|
||||
|
@ -238,12 +244,14 @@ draw_cb (gpointer data)
|
|||
eagl_layer = (CAEAGLLayer *)[window_eagl->priv->view layer];
|
||||
size = eagl_layer.frame.size;
|
||||
|
||||
if (window_eagl->priv->window_width != size.width || window_eagl->priv->window_height != size.height) {
|
||||
window_eagl->priv->window_width = size.width;
|
||||
window_eagl->priv->window_height = size.height;
|
||||
if (window_eagl->priv->window_width != window_eagl->priv->preferred_width ||
|
||||
window_eagl->priv->window_height != window_eagl->priv->preferred_height) {
|
||||
window_eagl->priv->window_width = window_eagl->priv->preferred_width;
|
||||
window_eagl->priv->window_height = window_eagl->priv->preferred_height;
|
||||
|
||||
if (window->resize)
|
||||
window->resize (window->resize_data, size.width, size.height);
|
||||
window->resize (window->resize_data, window_eagl->priv->preferred_width,
|
||||
window_eagl->priv->preferred_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,13 +268,7 @@ draw_cb (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_eagl_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_eagl_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
|
||||
draw_data.window = GST_GL_WINDOW_EAGL (window);
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
|
|
@ -316,15 +316,13 @@ gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle)
|
|||
/**
|
||||
* gst_gl_window_draw_unlocked:
|
||||
* @window: a #GstGLWindow
|
||||
* @width: requested width of the window
|
||||
* @height: requested height of the window
|
||||
*
|
||||
* Redraw the window contents. Implementations should invoke the draw callback.
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
void
|
||||
gst_gl_window_draw_unlocked (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_draw_unlocked (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowClass *window_class;
|
||||
|
||||
|
@ -332,21 +330,19 @@ gst_gl_window_draw_unlocked (GstGLWindow * window, guint width, guint height)
|
|||
window_class = GST_GL_WINDOW_GET_CLASS (window);
|
||||
g_return_if_fail (window_class->draw_unlocked != NULL);
|
||||
|
||||
window_class->draw_unlocked (window, width, height);
|
||||
window_class->draw_unlocked (window);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_window_draw:
|
||||
* @window: a #GstGLWindow
|
||||
* @width: requested width of the window
|
||||
* @height: requested height of the window
|
||||
*
|
||||
* Redraw the window contents. Implementations should invoke the draw callback.
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
void
|
||||
gst_gl_window_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_draw (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowClass *window_class;
|
||||
|
||||
|
@ -359,7 +355,30 @@ gst_gl_window_draw (GstGLWindow * window, guint width, guint height)
|
|||
return;
|
||||
}
|
||||
|
||||
window_class->draw (window, width, height);
|
||||
window_class->draw (window);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_window_set_preferred_size:
|
||||
* @window: a #GstGLWindow
|
||||
* @width: new preferred width
|
||||
* @height: new preferred height
|
||||
*
|
||||
* Set the preferred width and height of the window. Implementations are free
|
||||
* to ignore this information.
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
void
|
||||
gst_gl_window_set_preferred_size (GstGLWindow * window, gint width, gint height)
|
||||
{
|
||||
GstGLWindowClass *window_class;
|
||||
|
||||
g_return_if_fail (GST_GL_IS_WINDOW (window));
|
||||
window_class = GST_GL_WINDOW_GET_CLASS (window);
|
||||
|
||||
if (window_class->set_preferred_size)
|
||||
window_class->set_preferred_size (window, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -847,17 +866,10 @@ gst_gl_dummy_window_get_window_handle (GstGLWindow * window)
|
|||
return (guintptr) dummy->handle;
|
||||
}
|
||||
|
||||
struct draw
|
||||
{
|
||||
GstGLDummyWindow *window;
|
||||
guint width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLDummyWindow *dummy = draw_data->window;
|
||||
GstGLDummyWindow *dummy = data;
|
||||
GstGLWindow *window = GST_GL_WINDOW (dummy);
|
||||
GstGLContext *context = gst_gl_window_get_context (window);
|
||||
GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
|
||||
|
@ -871,15 +883,9 @@ draw_cb (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_dummy_window_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_dummy_window_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
|
||||
draw_data.window = (GstGLDummyWindow *) window;
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
||||
static guintptr
|
||||
|
|
|
@ -121,8 +121,8 @@ struct _GstGLWindowClass {
|
|||
guintptr (*get_display) (GstGLWindow *window);
|
||||
void (*set_window_handle) (GstGLWindow *window, guintptr id);
|
||||
guintptr (*get_window_handle) (GstGLWindow *window);
|
||||
void (*draw_unlocked) (GstGLWindow *window, guint width, guint height);
|
||||
void (*draw) (GstGLWindow *window, guint width, guint height);
|
||||
void (*draw_unlocked) (GstGLWindow *window);
|
||||
void (*draw) (GstGLWindow *window);
|
||||
void (*run) (GstGLWindow *window);
|
||||
void (*quit) (GstGLWindow *window);
|
||||
void (*send_message) (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
|
||||
|
@ -132,6 +132,7 @@ struct _GstGLWindowClass {
|
|||
void (*close) (GstGLWindow *window);
|
||||
void (*get_surface_dimensions) (GstGLWindow *window, guint *width, guint *height);
|
||||
void (*handle_events) (GstGLWindow *window, gboolean handle_events);
|
||||
void (*set_preferred_size) (GstGLWindow *window, gint width, gint height);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _reserved[GST_PADDING];
|
||||
|
@ -165,8 +166,8 @@ void gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB
|
|||
|
||||
void gst_gl_window_set_window_handle (GstGLWindow *window, guintptr handle);
|
||||
guintptr gst_gl_window_get_window_handle (GstGLWindow *window);
|
||||
void gst_gl_window_draw_unlocked (GstGLWindow *window, guint width, guint height);
|
||||
void gst_gl_window_draw (GstGLWindow *window, guint width, guint height);
|
||||
void gst_gl_window_draw_unlocked (GstGLWindow *window);
|
||||
void gst_gl_window_draw (GstGLWindow *window);
|
||||
void gst_gl_window_run (GstGLWindow *window);
|
||||
void gst_gl_window_quit (GstGLWindow *window);
|
||||
void gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
|
||||
|
@ -175,6 +176,7 @@ guintptr gst_gl_window_get_display (GstGLWindow *window);
|
|||
void gst_gl_window_get_surface_dimensions (GstGLWindow * window, guint * width,
|
||||
guint * height);
|
||||
void gst_gl_window_handle_events (GstGLWindow * window, gboolean handle_events);
|
||||
void gst_gl_window_set_preferred_size (GstGLWindow * window, gint width, gint height);
|
||||
|
||||
GstGLContext * gst_gl_window_get_context (GstGLWindow *window);
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow *
|
|||
window);
|
||||
static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static void gst_gl_window_wayland_egl_draw (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
static void gst_gl_window_wayland_egl_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_wayland_egl_run (GstGLWindow * window);
|
||||
static void gst_gl_window_wayland_egl_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_wayland_egl_send_message_async (GstGLWindow * window,
|
||||
|
@ -510,17 +509,10 @@ window_resize (GstGLWindowWaylandEGL * window_egl, guint width, guint height)
|
|||
window_egl->window.window_height = height;
|
||||
}
|
||||
|
||||
struct draw
|
||||
{
|
||||
GstGLWindowWaylandEGL *window;
|
||||
guint width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLWindowWaylandEGL *window_egl = draw_data->window;
|
||||
GstGLWindowWaylandEGL *window_egl = data;
|
||||
GstGLWindow *window = GST_GL_WINDOW (window_egl);
|
||||
GstGLContext *context = gst_gl_window_get_context (window);
|
||||
GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
|
||||
|
@ -534,15 +526,9 @@ draw_cb (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_wayland_egl_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_wayland_egl_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
|
||||
draw_data.window = GST_GL_WINDOW_WAYLAND_EGL (window);
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
||||
static guintptr
|
||||
|
|
|
@ -44,6 +44,9 @@ enum
|
|||
struct _GstGLWindowWin32Private
|
||||
{
|
||||
GThread *thread;
|
||||
|
||||
gint preferred_width;
|
||||
gint preferred_height;
|
||||
};
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_window_win32_debug
|
||||
|
@ -58,8 +61,9 @@ G_DEFINE_TYPE_WITH_CODE (GstGLWindowWin32, gst_gl_window_win32,
|
|||
static void gst_gl_window_win32_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
static guintptr gst_gl_window_win32_get_display (GstGLWindow * window);
|
||||
static void gst_gl_window_win32_draw (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
static void gst_gl_window_win32_set_preferred_size (GstGLWindow * window,
|
||||
gint width, gint height);
|
||||
static void gst_gl_window_win32_draw (GstGLWindow * window);
|
||||
static void gst_gl_window_win32_run (GstGLWindow * window);
|
||||
static void gst_gl_window_win32_quit (GstGLWindow * window);
|
||||
static void gst_gl_window_win32_send_message_async (GstGLWindow * window,
|
||||
|
@ -82,6 +86,8 @@ gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_send_message_async);
|
||||
window_class->get_display =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_display);
|
||||
window_class->set_preferred_size =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_set_preferred_size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -256,12 +262,24 @@ gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id)
|
|||
window_win32->parent_win_id = (HWND) id;
|
||||
}
|
||||
|
||||
/* Thread safe */
|
||||
static void
|
||||
gst_gl_window_win32_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_win32_set_preferred_size (GstGLWindow * window, gint width,
|
||||
gint height)
|
||||
{
|
||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
||||
|
||||
window_win32->priv->preferred_width = width;
|
||||
window_win32->priv->preferred_height = height;
|
||||
}
|
||||
|
||||
/* Thread safe */
|
||||
static void
|
||||
gst_gl_window_win32_draw (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
||||
gint width = window_win32->priv->preferred_width;
|
||||
gint height = window_win32->priv->preferred_height;
|
||||
|
||||
if (!window_win32->visible) {
|
||||
HWND parent_id = window_win32->parent_win_id;
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ struct _GstGLWindowX11Private
|
|||
{
|
||||
gboolean activate;
|
||||
gboolean activate_result;
|
||||
|
||||
gint preferred_width;
|
||||
gint preferred_height;
|
||||
};
|
||||
|
||||
guintptr gst_gl_window_x11_get_display (GstGLWindow * window);
|
||||
|
@ -66,9 +69,10 @@ gboolean gst_gl_window_x11_activate (GstGLWindow * window, gboolean activate);
|
|||
void gst_gl_window_x11_set_window_handle (GstGLWindow * window,
|
||||
guintptr handle);
|
||||
guintptr gst_gl_window_x11_get_window_handle (GstGLWindow * window);
|
||||
void gst_gl_window_x11_draw_unlocked (GstGLWindow * window, guint width,
|
||||
guint height);
|
||||
void gst_gl_window_x11_draw (GstGLWindow * window, guint width, guint height);
|
||||
static void gst_gl_window_x11_set_preferred_size (GstGLWindow * window,
|
||||
gint width, gint height);
|
||||
void gst_gl_window_x11_draw_unlocked (GstGLWindow * window);
|
||||
void gst_gl_window_x11_draw (GstGLWindow * window);
|
||||
void gst_gl_window_x11_run (GstGLWindow * window);
|
||||
void gst_gl_window_x11_quit (GstGLWindow * window);
|
||||
void gst_gl_window_x11_send_message_async (GstGLWindow * window,
|
||||
|
@ -117,6 +121,8 @@ gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_surface_dimensions);
|
||||
window_class->handle_events =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_x11_handle_events);
|
||||
window_class->set_preferred_size =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_x11_set_preferred_size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -355,10 +361,19 @@ gst_gl_window_x11_get_window_handle (GstGLWindow * window)
|
|||
return window_x11->internal_win_id;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_x11_set_preferred_size (GstGLWindow * window, gint width,
|
||||
gint height)
|
||||
{
|
||||
GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
|
||||
|
||||
window_x11->priv->preferred_width = width;
|
||||
window_x11->priv->preferred_height = height;
|
||||
}
|
||||
|
||||
/* Called in the gl thread */
|
||||
void
|
||||
gst_gl_window_x11_draw_unlocked (GstGLWindow * window, guint width,
|
||||
guint height)
|
||||
gst_gl_window_x11_draw_unlocked (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowX11 *window_x11;
|
||||
|
||||
|
@ -378,19 +393,12 @@ gst_gl_window_x11_draw_unlocked (GstGLWindow * window, guint width,
|
|||
}
|
||||
}
|
||||
|
||||
struct draw
|
||||
{
|
||||
GstGLWindowX11 *window;
|
||||
guint width, height;
|
||||
};
|
||||
|
||||
static void
|
||||
draw_cb (gpointer data)
|
||||
{
|
||||
struct draw *draw_data = data;
|
||||
GstGLWindowX11 *window_x11 = draw_data->window;
|
||||
guint width = draw_data->width;
|
||||
guint height = draw_data->height;
|
||||
GstGLWindowX11 *window_x11 = data;
|
||||
guint width = window_x11->priv->preferred_width;
|
||||
guint height = window_x11->priv->preferred_height;
|
||||
|
||||
if (g_main_loop_is_running (window_x11->loop)) {
|
||||
XWindowAttributes attr;
|
||||
|
@ -430,22 +438,15 @@ draw_cb (gpointer data)
|
|||
}
|
||||
}
|
||||
|
||||
gst_gl_window_x11_draw_unlocked (GST_GL_WINDOW (window_x11), width, height);
|
||||
gst_gl_window_x11_draw_unlocked (GST_GL_WINDOW (window_x11));
|
||||
}
|
||||
}
|
||||
|
||||
/* Not called by the gl thread */
|
||||
void
|
||||
gst_gl_window_x11_draw (GstGLWindow * window, guint width, guint height)
|
||||
gst_gl_window_x11_draw (GstGLWindow * window)
|
||||
{
|
||||
struct draw draw_data;
|
||||
|
||||
draw_data.window = GST_GL_WINDOW_X11 (window);
|
||||
draw_data.width = width;
|
||||
draw_data.height = height;
|
||||
|
||||
/* Call from the GL thread */
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
|
||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue