mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
[298/906] Revert "Fix indention"
This reverts commit 96e4ab18c2cf9876f6c031b9aba6282d0bd45a93. You should have asked first. And you would have been told "no", because it causes people on development branches to do a huge amount of extra work.
This commit is contained in:
parent
2f0e5b1dc4
commit
f0b62d760f
6 changed files with 1858 additions and 1848 deletions
|
@ -25,40 +25,40 @@
|
|||
|
||||
#include "gstglbuffer.h"
|
||||
|
||||
static GObjectClass *gst_gl_buffer_parent_class;
|
||||
static GObjectClass* gst_gl_buffer_parent_class;
|
||||
|
||||
static void
|
||||
gst_gl_buffer_finalize (GstGLBuffer * buffer)
|
||||
gst_gl_buffer_finalize (GstGLBuffer* buffer)
|
||||
{
|
||||
//blocking call, put the texture in the pool
|
||||
gst_gl_display_del_texture (buffer->display, buffer->texture,
|
||||
//blocking call, put the texture in the pool
|
||||
gst_gl_display_del_texture (buffer->display, buffer->texture,
|
||||
buffer->width, buffer->height);
|
||||
|
||||
g_object_unref (buffer->display);
|
||||
g_object_unref (buffer->display);
|
||||
|
||||
GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->finalize (GST_MINI_OBJECT
|
||||
(buffer));
|
||||
GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->
|
||||
finalize (GST_MINI_OBJECT (buffer));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_buffer_init (GstGLBuffer * buffer, gpointer g_class)
|
||||
gst_gl_buffer_init (GstGLBuffer* buffer, gpointer g_class)
|
||||
{
|
||||
buffer->display = NULL;
|
||||
buffer->display = NULL;
|
||||
|
||||
buffer->width = 0;
|
||||
buffer->height = 0;
|
||||
buffer->texture = 0;
|
||||
buffer->width = 0;
|
||||
buffer->height = 0;
|
||||
buffer->texture = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_buffer_class_init (gpointer g_class, gpointer class_data)
|
||||
{
|
||||
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
||||
GstMiniObjectClass* mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
||||
|
||||
gst_gl_buffer_parent_class = g_type_class_peek_parent (g_class);
|
||||
gst_gl_buffer_parent_class = g_type_class_peek_parent (g_class);
|
||||
|
||||
mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
|
||||
gst_gl_buffer_finalize;
|
||||
mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
|
||||
gst_gl_buffer_finalize;
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,48 +87,47 @@ gst_gl_buffer_get_type (void)
|
|||
}
|
||||
|
||||
|
||||
GstGLBuffer *
|
||||
gst_gl_buffer_new (GstGLDisplay * display, gint gl_width, gint gl_height)
|
||||
GstGLBuffer*
|
||||
gst_gl_buffer_new (GstGLDisplay* display,
|
||||
gint gl_width, gint gl_height)
|
||||
{
|
||||
GstGLBuffer *gl_buffer =
|
||||
(GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
||||
GstGLBuffer* gl_buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
||||
|
||||
gl_buffer->display = g_object_ref (display);
|
||||
gl_buffer->width = gl_width;
|
||||
gl_buffer->height = gl_height;
|
||||
gl_buffer->display = g_object_ref (display);
|
||||
gl_buffer->width = gl_width;
|
||||
gl_buffer->height = gl_height;
|
||||
|
||||
//it does not depends on the video format because gl buffer has always one texture.
|
||||
//the one attached to the upload FBO
|
||||
GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
|
||||
//it does not depends on the video format because gl buffer has always one texture.
|
||||
//the one attached to the upload FBO
|
||||
GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
|
||||
|
||||
//blocking call, generate a texture using the pool
|
||||
gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width,
|
||||
gl_height);
|
||||
//blocking call, generate a texture using the pool
|
||||
gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width, gl_height) ;
|
||||
|
||||
return gl_buffer;
|
||||
return gl_buffer;
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gst_gl_buffer_get_size (gint width, gint height)
|
||||
{
|
||||
//this is not strictly true, but it's used for compatibility with
|
||||
//queue and BaseTransform
|
||||
return width * height * 4;
|
||||
//this is not strictly true, but it's used for compatibility with
|
||||
//queue and BaseTransform
|
||||
return width * height * 4;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gst_gl_buffer_parse_caps (GstCaps * caps, gint * width, gint * height)
|
||||
gst_gl_buffer_parse_caps (GstCaps* caps, gint* width, gint* height)
|
||||
{
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl");
|
||||
GstStructure* structure = gst_caps_get_structure (caps, 0);
|
||||
gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl");
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
ret = gst_structure_get_int (structure, "width", width);
|
||||
ret &= gst_structure_get_int (structure, "height", height);
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
ret = gst_structure_get_int (structure, "width", width);
|
||||
ret &= gst_structure_get_int (structure, "height", height);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,48 +31,48 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
|
||||
|
||||
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
);
|
||||
|
||||
#define DEBUG_INIT(bla) \
|
||||
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0, "glfilter element");
|
||||
|
||||
GST_BOILERPLATE_FULL (GstGLFilter, gst_gl_filter, GstBaseTransform,
|
||||
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
||||
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
||||
|
||||
static void gst_gl_filter_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_gl_filter_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps);
|
||||
static GstCaps* gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
||||
GstPadDirection direction, GstCaps* caps);
|
||||
static void gst_gl_filter_reset (GstGLFilter * filter);
|
||||
static gboolean gst_gl_filter_start (GstBaseTransform * bt);
|
||||
static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
|
||||
static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans,
|
||||
GstCaps * caps, guint * size);
|
||||
GstCaps * caps, guint * size);
|
||||
static GstFlowReturn gst_gl_filter_transform (GstBaseTransform * bt,
|
||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||
static GstFlowReturn gst_gl_filter_prepare_output_buffer (GstBaseTransform *
|
||||
trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
|
||||
trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
|
||||
static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
||||
GstCaps * outcaps);
|
||||
GstCaps * outcaps);
|
||||
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
|
||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
|
||||
/* GstGLDisplayThreadFunc */
|
||||
static void gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data);
|
||||
static void gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data);
|
||||
static void gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data);
|
||||
static void gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data);
|
||||
|
||||
|
||||
static void
|
||||
|
@ -81,9 +81,9 @@ gst_gl_filter_base_init (gpointer klass)
|
|||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_gl_filter_src_pad_template));
|
||||
gst_static_pad_template_get (&gst_gl_filter_src_pad_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_gl_filter_sink_pad_template));
|
||||
gst_static_pad_template_get (&gst_gl_filter_sink_pad_template));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -96,14 +96,14 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
|
|||
gobject_class->get_property = gst_gl_filter_get_property;
|
||||
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
|
||||
gst_gl_filter_transform_caps;
|
||||
gst_gl_filter_transform_caps;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_filter_start;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size = gst_gl_filter_get_unit_size;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
|
||||
gst_gl_filter_prepare_output_buffer;
|
||||
gst_gl_filter_prepare_output_buffer;
|
||||
|
||||
klass->set_caps = NULL;
|
||||
klass->filter = NULL;
|
||||
|
@ -128,45 +128,48 @@ gst_gl_filter_init (GstGLFilter * filter, GstGLFilterClass * klass)
|
|||
|
||||
static void
|
||||
gst_gl_filter_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_reset (GstGLFilter * filter)
|
||||
gst_gl_filter_reset (GstGLFilter* filter)
|
||||
{
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
if (filter->display) {
|
||||
if (filter->display)
|
||||
{
|
||||
if (filter_class->onReset)
|
||||
filter_class->onReset (filter);
|
||||
|
||||
if (filter_class->display_reset_cb != NULL) {
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl,
|
||||
filter);
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl, filter);
|
||||
}
|
||||
//blocking call, delete the FBO
|
||||
gst_gl_display_del_fbo (filter->display, filter->fbo, filter->depthbuffer);
|
||||
gst_gl_display_del_fbo (filter->display, filter->fbo,
|
||||
filter->depthbuffer);
|
||||
g_object_unref (filter->display);
|
||||
filter->display = NULL;
|
||||
}
|
||||
|
@ -177,19 +180,19 @@ gst_gl_filter_reset (GstGLFilter * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_start (GstBaseTransform * bt)
|
||||
gst_gl_filter_start (GstBaseTransform* bt)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (bt);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
if (filter_class->onStart)
|
||||
filter_class->onStart (filter);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_stop (GstBaseTransform * bt)
|
||||
gst_gl_filter_stop (GstBaseTransform* bt)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (bt);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
@ -203,7 +206,7 @@ gst_gl_filter_stop (GstBaseTransform * bt)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data)
|
||||
gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
@ -212,7 +215,7 @@ gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data)
|
||||
gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
@ -220,28 +223,30 @@ gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data)
|
|||
filter_class->display_reset_cb (filter);
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_gl_filter_transform_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps)
|
||||
static GstCaps*
|
||||
gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
||||
GstPadDirection direction, GstCaps* caps)
|
||||
{
|
||||
//GstGLFilter* filter = GST_GL_FILTER (bt);
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
GstCaps *ret = gst_caps_copy (caps);
|
||||
const GValue *par = NULL;
|
||||
GstStructure* structure = gst_caps_get_structure (caps, 0);
|
||||
GstCaps* ret = gst_caps_copy (caps);
|
||||
const GValue* par = NULL;
|
||||
|
||||
structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
|
||||
|
||||
gst_structure_set (structure,
|
||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
|
||||
gst_caps_merge_structure (ret, gst_structure_copy (structure));
|
||||
|
||||
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
|
||||
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio")))
|
||||
{
|
||||
gst_structure_set (structure,
|
||||
"pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
||||
"pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
||||
gst_caps_merge_structure (ret, structure);
|
||||
} else
|
||||
}
|
||||
else
|
||||
gst_structure_free (structure);
|
||||
|
||||
GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret);
|
||||
|
@ -251,8 +256,8 @@ gst_gl_filter_transform_caps (GstBaseTransform * bt,
|
|||
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
||||
guint * size)
|
||||
gst_gl_filter_get_unit_size (GstBaseTransform* trans, GstCaps* caps,
|
||||
guint* size)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gint width = 0;
|
||||
|
@ -266,27 +271,27 @@ gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
|
||||
GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf)
|
||||
gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
|
||||
GstBuffer* inbuf, gint size, GstCaps* caps, GstBuffer** buf)
|
||||
{
|
||||
GstGLFilter *filter = NULL;
|
||||
GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
|
||||
GstGLBuffer *gl_outbuf = NULL;
|
||||
GstGLFilter* filter = NULL;
|
||||
GstGLBuffer* gl_inbuf = GST_GL_BUFFER (inbuf);
|
||||
GstGLBuffer* gl_outbuf = NULL;
|
||||
|
||||
filter = GST_GL_FILTER (trans);
|
||||
|
||||
if (filter->display == NULL) {
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
if (filter->display == NULL)
|
||||
{
|
||||
GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
filter->display = g_object_ref (gl_inbuf->display);
|
||||
|
||||
//blocking call, generate a FBO
|
||||
gst_gl_display_gen_fbo (filter->display, filter->width, filter->height,
|
||||
&filter->fbo, &filter->depthbuffer);
|
||||
&filter->fbo, &filter->depthbuffer);
|
||||
|
||||
if (filter_class->display_init_cb != NULL) {
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl,
|
||||
filter);
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
|
||||
}
|
||||
|
||||
if (filter_class->onInitFBO)
|
||||
|
@ -294,7 +299,7 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
|
|||
}
|
||||
|
||||
gl_outbuf = gst_gl_buffer_new (filter->display,
|
||||
filter->width, filter->height);
|
||||
filter->width, filter->height);
|
||||
|
||||
*buf = GST_BUFFER (gl_outbuf);
|
||||
gst_buffer_set_caps (*buf, caps);
|
||||
|
@ -306,19 +311,20 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
||||
GstCaps * outcaps)
|
||||
gst_gl_filter_set_caps (GstBaseTransform* bt, GstCaps* incaps,
|
||||
GstCaps* outcaps)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (bt);
|
||||
GstGLFilter* filter = GST_GL_FILTER (bt);
|
||||
gboolean ret = FALSE;
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
ret = gst_gl_buffer_parse_caps (outcaps, &filter->width, &filter->height);
|
||||
|
||||
if (filter_class->set_caps)
|
||||
filter_class->set_caps (filter, incaps, outcaps);
|
||||
|
||||
if (!ret) {
|
||||
if (!ret)
|
||||
{
|
||||
GST_DEBUG ("bad caps");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -329,12 +335,12 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
||||
GstBuffer * outbuf)
|
||||
gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf,
|
||||
GstBuffer* outbuf)
|
||||
{
|
||||
GstGLFilter *filter;
|
||||
GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
|
||||
GstGLBuffer *gl_outbuf = GST_GL_BUFFER (outbuf);
|
||||
GstGLFilter* filter;
|
||||
GstGLBuffer* gl_inbuf = GST_GL_BUFFER (inbuf);
|
||||
GstGLBuffer* gl_outbuf = GST_GL_BUFFER (outbuf);
|
||||
|
||||
filter = GST_GL_FILTER (bt);
|
||||
|
||||
|
@ -344,10 +350,10 @@ gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_do_transform (GstGLFilter * filter,
|
||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf)
|
||||
gst_gl_filter_do_transform (GstGLFilter* filter,
|
||||
GstGLBuffer* inbuf, GstGLBuffer* outbuf)
|
||||
{
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
filter_class->filter (filter, inbuf, outbuf);
|
||||
|
||||
|
@ -357,13 +363,15 @@ gst_gl_filter_do_transform (GstGLFilter * filter,
|
|||
/* convenience functions to simplify filter development */
|
||||
|
||||
void
|
||||
gst_gl_filter_render_to_target (GstGLFilter * filter,
|
||||
GLuint input, GLuint target, GLCB func, gpointer data)
|
||||
gst_gl_filter_render_to_target (GstGLFilter *filter,
|
||||
GLuint input, GLuint target,
|
||||
GLCB func, gpointer data)
|
||||
{
|
||||
gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
|
||||
filter->fbo, filter->depthbuffer, target,
|
||||
func,
|
||||
filter->width, filter->height, input,
|
||||
0, filter->width, 0, filter->height,
|
||||
GST_GL_DISPLAY_PROJECTION_ORTHO2D, data);
|
||||
filter->fbo, filter->depthbuffer, target,
|
||||
func,
|
||||
filter->width, filter->height, input,
|
||||
0, filter->width, 0, filter->height,
|
||||
GST_GL_DISPLAY_PROJECTION_ORTHO2D,
|
||||
data);
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ gst_gl_shader_get_property (GObject * object,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_shader_log_handler (const gchar * domain, GLogLevelFlags flags,
|
||||
const gchar * message, gpointer user_data)
|
||||
gst_gl_shader_log_handler (const gchar *domain, GLogLevelFlags flags,
|
||||
const gchar *message, gpointer user_data)
|
||||
{
|
||||
if (_gst_gl_shader_debug) {
|
||||
g_log_default_handler (domain, flags, message, user_data);
|
||||
|
@ -249,7 +249,7 @@ gst_gl_shader_init (GstGLShader * self)
|
|||
_gst_gl_shader_debug = TRUE;
|
||||
|
||||
g_log_set_handler ("GstGLShader", G_LOG_LEVEL_DEBUG,
|
||||
gst_gl_shader_log_handler, NULL);
|
||||
gst_gl_shader_log_handler, NULL);
|
||||
}
|
||||
|
||||
GstGLShader *
|
||||
|
@ -511,7 +511,7 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
|
|||
}
|
||||
|
||||
GLint
|
||||
gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
|
||||
gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar *name)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
|
||||
|
|
|
@ -32,11 +32,9 @@
|
|||
#define WM_GST_GL_WINDOW_CUSTOM (WM_APP+1)
|
||||
#define WM_GST_GL_WINDOW_QUIT (WM_APP+2)
|
||||
|
||||
void gst_gl_window_set_pixel_format (GstGLWindow * window);
|
||||
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
void gst_gl_window_set_pixel_format (GstGLWindow *window);
|
||||
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#define GST_GL_WINDOW_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW, GstGLWindowPrivate))
|
||||
|
@ -81,8 +79,8 @@ gst_gl_window_finalize (GObject * object)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
|
||||
const gchar * message, gpointer user_data)
|
||||
gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags,
|
||||
const gchar *message, gpointer user_data)
|
||||
{
|
||||
if (_gst_gl_window_debug) {
|
||||
g_log_default_handler (domain, flags, message, user_data);
|
||||
|
@ -108,8 +106,9 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
|
|||
|
||||
atom = GetClassInfo (hinstance, "GSTGL", &wc);
|
||||
|
||||
if (atom == 0) {
|
||||
ZeroMemory (&wc, sizeof (WNDCLASS));
|
||||
if (atom == 0)
|
||||
{
|
||||
ZeroMemory (&wc, sizeof(WNDCLASS));
|
||||
|
||||
wc.lpfnWndProc = window_proc;
|
||||
wc.cbClsExtra = 0;
|
||||
|
@ -125,12 +124,12 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
|
|||
atom = RegisterClass (&wc);
|
||||
|
||||
if (atom == 0)
|
||||
g_error ("Failed to register window class %x\r\n", GetLastError ());
|
||||
g_error ("Failed to register window class %x\r\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_init (GstGLWindow * window)
|
||||
gst_gl_window_init (GstGLWindow *window)
|
||||
{
|
||||
window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
|
||||
|
||||
|
@ -138,7 +137,7 @@ gst_gl_window_init (GstGLWindow * window)
|
|||
_gst_gl_window_debug = TRUE;
|
||||
|
||||
g_log_set_handler ("GstGLWindow", G_LOG_LEVEL_DEBUG,
|
||||
gst_gl_window_log_handler, NULL);
|
||||
gst_gl_window_log_handler, NULL);
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -147,7 +146,7 @@ gst_gl_window_new (gint width, gint height)
|
|||
{
|
||||
GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
GstGLWindowClass *klass = GST_GL_WINDOW_GET_CLASS (window);
|
||||
GstGLWindowClass* klass = GST_GL_WINDOW_GET_CLASS (window);
|
||||
|
||||
HINSTANCE hinstance = GetModuleHandle (NULL);
|
||||
|
||||
|
@ -170,16 +169,22 @@ gst_gl_window_new (gint width, gint height)
|
|||
priv->visible = FALSE;
|
||||
|
||||
width += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
|
||||
height +=
|
||||
2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
|
||||
height += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
|
||||
|
||||
priv->internal_win_id = CreateWindowEx (0,
|
||||
"GSTGL",
|
||||
"OpenGL renderer",
|
||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
|
||||
x, y, width, height, (HWND) NULL, (HMENU) NULL, hinstance, window);
|
||||
priv->internal_win_id = CreateWindowEx (
|
||||
0,
|
||||
"GSTGL",
|
||||
"OpenGL renderer",
|
||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
|
||||
x, y, width, height,
|
||||
(HWND) NULL,
|
||||
(HMENU) NULL,
|
||||
hinstance,
|
||||
window
|
||||
);
|
||||
|
||||
if (!priv->internal_win_id) {
|
||||
if (!priv->internal_win_id)
|
||||
{
|
||||
g_debug ("failed to create gl window: %d\n", priv->internal_win_id);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -201,41 +206,36 @@ gst_gl_window_error_quark (void)
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
|
||||
gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
WNDPROC window_parent_proc =
|
||||
(WNDPROC) (guint64) GetWindowLongPtr ((HWND) id, GWL_WNDPROC);
|
||||
WNDPROC window_parent_proc = (WNDPROC) (guint64) GetWindowLongPtr((HWND)id, GWL_WNDPROC);
|
||||
RECT rect;
|
||||
|
||||
SetProp (priv->internal_win_id, "gl_window_parent_id", (HWND) id);
|
||||
SetProp ((HWND) id, "gl_window_id", priv->internal_win_id);
|
||||
SetProp ((HWND) id, "gl_window_parent_proc", (WNDPROC) window_parent_proc);
|
||||
SetWindowLongPtr ((HWND) id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc);
|
||||
SetProp (priv->internal_win_id, "gl_window_parent_id", (HWND)id);
|
||||
SetProp ((HWND)id, "gl_window_id", priv->internal_win_id);
|
||||
SetProp ((HWND)id, "gl_window_parent_proc", (WNDPROC) window_parent_proc);
|
||||
SetWindowLongPtr ((HWND)id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc);
|
||||
|
||||
SetWindowLongPtr (priv->internal_win_id, GWL_STYLE, WS_CHILD | WS_MAXIMIZE);
|
||||
SetParent (priv->internal_win_id, (HWND) id);
|
||||
SetParent (priv->internal_win_id, (HWND)id);
|
||||
|
||||
//take changes into account: SWP_FRAMECHANGED
|
||||
GetClientRect ((HWND) id, &rect);
|
||||
SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top,
|
||||
rect.right, rect.bottom,
|
||||
SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
||||
MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right,
|
||||
rect.bottom, FALSE);
|
||||
GetClientRect ((HWND)id, &rect);
|
||||
SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top, rect.right, rect.bottom,
|
||||
SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
||||
MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right, rect.bottom, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
|
||||
gst_gl_window_set_external_gl_context (GstGLWindow *window, guint64 context)
|
||||
{
|
||||
g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
void
|
||||
gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -245,8 +245,7 @@ gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
void
|
||||
gst_gl_window_set_resize_callback (GstGLWindow * window,
|
||||
GstGLWindowCB2 callback, gpointer data)
|
||||
gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -256,8 +255,7 @@ gst_gl_window_set_resize_callback (GstGLWindow * window,
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
void
|
||||
gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -266,28 +264,29 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_draw_unlocked (GstGLWindow * window)
|
||||
gst_gl_window_draw_unlocked (GstGLWindow *window)
|
||||
{
|
||||
gst_gl_window_draw (window);
|
||||
}
|
||||
|
||||
/* Thread safe */
|
||||
void
|
||||
gst_gl_window_draw (GstGLWindow * window)
|
||||
gst_gl_window_draw (GstGLWindow *window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
if (!priv->visible) {
|
||||
if (!priv->visible)
|
||||
{
|
||||
ShowWindowAsync (priv->internal_win_id, SW_SHOW);
|
||||
priv->visible = TRUE;
|
||||
}
|
||||
|
||||
RedrawWindow (priv->internal_win_id, NULL, NULL,
|
||||
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
|
||||
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_window_run_loop (GstGLWindow * window)
|
||||
gst_gl_window_run_loop (GstGLWindow *window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
gboolean running = TRUE;
|
||||
|
@ -296,14 +295,18 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
|
||||
g_debug ("begin loop\n");
|
||||
|
||||
while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0) {
|
||||
if (bRet == -1) {
|
||||
g_error ("Failed to get message %x\r\n", GetLastError ());
|
||||
running = FALSE;
|
||||
} else {
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0)
|
||||
{
|
||||
if (bRet == -1)
|
||||
{
|
||||
g_error ("Failed to get message %x\r\n", GetLastError());
|
||||
running = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
}
|
||||
|
||||
g_debug ("end loop\n");
|
||||
|
@ -311,13 +314,12 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
|
||||
/* Thread safe */
|
||||
void
|
||||
gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
LRESULT res = PostMessage (priv->internal_win_id, WM_GST_GL_WINDOW_QUIT,
|
||||
(WPARAM) data, (LPARAM) callback);
|
||||
LRESULT res = PostMessage(priv->internal_win_id, WM_GST_GL_WINDOW_QUIT, (WPARAM) data, (LPARAM) callback);
|
||||
g_assert (SUCCEEDED (res));
|
||||
g_debug ("end loop requested\n");
|
||||
}
|
||||
|
@ -325,13 +327,12 @@ gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
|
|||
|
||||
/* Thread safe */
|
||||
void
|
||||
gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM,
|
||||
(WPARAM) data, (LPARAM) callback);
|
||||
LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM, (WPARAM) data, (LPARAM) callback);
|
||||
g_assert (SUCCEEDED (res));
|
||||
}
|
||||
}
|
||||
|
@ -339,58 +340,56 @@ gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
|||
/* PRIVATE */
|
||||
|
||||
void
|
||||
gst_gl_window_set_pixel_format (GstGLWindow * window)
|
||||
gst_gl_window_set_pixel_format (GstGLWindow *window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
gint pixelformat = 0;
|
||||
gboolean res = FALSE;
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
gint pixelformat = 0;
|
||||
gboolean res = FALSE;
|
||||
|
||||
pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cRedBits = 0;
|
||||
pfd.cRedShift = 0;
|
||||
pfd.cGreenBits = 0;
|
||||
pfd.cGreenShift = 0;
|
||||
pfd.cBlueBits = 0;
|
||||
pfd.cBlueShift = 0;
|
||||
pfd.cAlphaBits = 0;
|
||||
pfd.cAlphaShift = 0;
|
||||
pfd.cAccumBits = 0;
|
||||
pfd.cAccumRedBits = 0;
|
||||
pfd.cAccumGreenBits = 0;
|
||||
pfd.cAccumBlueBits = 0;
|
||||
pfd.cAccumAlphaBits = 0;
|
||||
pfd.cDepthBits = 32;
|
||||
pfd.cStencilBits = 8;
|
||||
pfd.cAuxBuffers = 0;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
pfd.bReserved = 0;
|
||||
pfd.dwLayerMask = 0;
|
||||
pfd.dwVisibleMask = 0;
|
||||
pfd.dwDamageMask = 0;
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cRedBits = 0;
|
||||
pfd.cRedShift = 0;
|
||||
pfd.cGreenBits = 0;
|
||||
pfd.cGreenShift = 0;
|
||||
pfd.cBlueBits = 0;
|
||||
pfd.cBlueShift = 0;
|
||||
pfd.cAlphaBits = 0;
|
||||
pfd.cAlphaShift = 0;
|
||||
pfd.cAccumBits = 0;
|
||||
pfd.cAccumRedBits = 0;
|
||||
pfd.cAccumGreenBits = 0;
|
||||
pfd.cAccumBlueBits = 0;
|
||||
pfd.cAccumAlphaBits = 0;
|
||||
pfd.cDepthBits = 32;
|
||||
pfd.cStencilBits = 8;
|
||||
pfd.cAuxBuffers = 0;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
pfd.bReserved = 0;
|
||||
pfd.dwLayerMask = 0;
|
||||
pfd.dwVisibleMask = 0;
|
||||
pfd.dwDamageMask = 0;
|
||||
|
||||
pfd.cColorBits = (BYTE) GetDeviceCaps (priv->device, BITSPIXEL);
|
||||
pfd.cColorBits = (BYTE) GetDeviceCaps (priv->device, BITSPIXEL);
|
||||
|
||||
pixelformat = ChoosePixelFormat (priv->device, &pfd);
|
||||
pixelformat = ChoosePixelFormat (priv->device, &pfd );
|
||||
|
||||
g_assert (pixelformat);
|
||||
g_assert (pixelformat);
|
||||
|
||||
res = SetPixelFormat (priv->device, pixelformat, &pfd);
|
||||
res = SetPixelFormat (priv->device, pixelformat, &pfd);
|
||||
|
||||
g_assert (res);
|
||||
g_assert (res);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (uMsg == WM_CREATE) {
|
||||
|
||||
GstGLWindow *window =
|
||||
(GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
|
||||
GstGLWindow *window = (GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
|
||||
|
||||
g_debug ("WM_CREATE\n");
|
||||
|
||||
|
@ -404,21 +403,20 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
if (priv->gl_context)
|
||||
g_debug ("gl context created: %d\n", priv->gl_context);
|
||||
else
|
||||
g_debug ("failed to create glcontext %d, %x\r\n", hWnd,
|
||||
GetLastError ());
|
||||
g_debug ("failed to create glcontext %d, %x\r\n", hWnd, GetLastError());
|
||||
g_assert (priv->gl_context);
|
||||
ReleaseDC (hWnd, priv->device);
|
||||
if (!wglMakeCurrent (priv->device, priv->gl_context))
|
||||
g_debug ("failed to make opengl context current %d, %x\r\n", hWnd,
|
||||
GetLastError ());
|
||||
g_debug ("failed to make opengl context current %d, %x\r\n", hWnd, GetLastError());
|
||||
}
|
||||
|
||||
SetProp (hWnd, "gl_window", window);
|
||||
|
||||
return 0;
|
||||
} else if (GetProp (hWnd, "gl_window")) {
|
||||
}
|
||||
else if (GetProp(hWnd, "gl_window")) {
|
||||
|
||||
GstGLWindow *window = GetProp (hWnd, "gl_window");
|
||||
GstGLWindow *window = GetProp(hWnd, "gl_window");
|
||||
GstGLWindowPrivate *priv = NULL;
|
||||
|
||||
g_assert (window);
|
||||
|
@ -429,20 +427,21 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
g_assert (priv->internal_win_id == hWnd);
|
||||
|
||||
g_assert (priv->gl_context == wglGetCurrentContext ());
|
||||
g_assert (priv->gl_context == wglGetCurrentContext());
|
||||
|
||||
switch (uMsg) {
|
||||
switch ( uMsg ) {
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (priv->resize_cb)
|
||||
priv->resize_cb (priv->resize_data, LOWORD (lParam), HIWORD (lParam));
|
||||
priv->resize_cb (priv->resize_data, LOWORD(lParam), HIWORD(lParam));
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
if (priv->draw_cb) {
|
||||
if (priv->draw_cb)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
BeginPaint (hWnd, &ps);
|
||||
priv->draw_cb (priv->draw_data);
|
||||
|
@ -457,14 +456,14 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
ShowWindowAsync (priv->internal_win_id, SW_HIDE);
|
||||
|
||||
if (priv->close_cb)
|
||||
priv->close_cb (priv->close_data);
|
||||
priv->close_cb (priv->close_data);
|
||||
|
||||
priv->draw_cb = NULL;
|
||||
priv->draw_data = NULL;
|
||||
priv->resize_cb = NULL;
|
||||
priv->resize_data = NULL;
|
||||
priv->close_cb = NULL;
|
||||
priv->close_data = NULL;
|
||||
priv->draw_cb = NULL;
|
||||
priv->draw_data = NULL;
|
||||
priv->resize_cb = NULL;
|
||||
priv->resize_data = NULL;
|
||||
priv->close_cb = NULL;
|
||||
priv->close_data = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -478,13 +477,13 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
destroy_cb ((gpointer) wParam);
|
||||
|
||||
parent_id = GetProp (hWnd, "gl_window_parent_id");
|
||||
if (parent_id) {
|
||||
if (parent_id)
|
||||
{
|
||||
WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc");
|
||||
|
||||
g_assert (parent_proc);
|
||||
|
||||
SetWindowLongPtr (parent_id, GWL_WNDPROC,
|
||||
(LONG) (guint64) parent_proc);
|
||||
SetWindowLongPtr (parent_id, GWL_WNDPROC, (LONG) (guint64) parent_proc);
|
||||
SetParent (hWnd, NULL);
|
||||
|
||||
RemoveProp (parent_id, "gl_window_parent_proc");
|
||||
|
@ -495,19 +494,19 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
RemoveProp (hWnd, "gl_window");
|
||||
|
||||
if (!wglMakeCurrent (NULL, NULL))
|
||||
g_debug ("failed to make current %d, %x\r\n", hWnd, GetLastError ());
|
||||
g_debug ("failed to make current %d, %x\r\n", hWnd, GetLastError());
|
||||
|
||||
if (priv->gl_context) {
|
||||
if (priv->gl_context)
|
||||
{
|
||||
if (!wglDeleteContext (priv->gl_context))
|
||||
g_debug ("failed to destroy context %d, %x\r\n", priv->gl_context,
|
||||
GetLastError ());
|
||||
g_debug ("failed to destroy context %d, %x\r\n", priv->gl_context, GetLastError());
|
||||
}
|
||||
|
||||
if (priv->internal_win_id) {
|
||||
if (priv->internal_win_id)
|
||||
{
|
||||
g_debug ("BEFORE\n");
|
||||
if (!DestroyWindow (priv->internal_win_id))
|
||||
g_debug ("failed to destroy window %d, %x\r\n", hWnd,
|
||||
GetLastError ());
|
||||
if (!DestroyWindow(priv->internal_win_id))
|
||||
g_debug ("failed to destroy window %d, %x\r\n", hWnd, GetLastError());
|
||||
g_debug ("AFTER\n");
|
||||
}
|
||||
|
||||
|
@ -525,7 +524,8 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
case WM_GST_GL_WINDOW_CUSTOM:
|
||||
{
|
||||
if (!priv->is_closed) {
|
||||
if (!priv->is_closed)
|
||||
{
|
||||
GstGLWindowCB custom_cb = (GstGLWindowCB) lParam;
|
||||
custom_cb ((gpointer) wParam);
|
||||
}
|
||||
|
@ -536,23 +536,25 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
return TRUE;
|
||||
|
||||
default:
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
return 0;
|
||||
} else
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
else
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
LRESULT FAR PASCAL
|
||||
sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WNDPROC window_parent_proc = GetProp (hWnd, "gl_window_parent_proc");
|
||||
|
||||
if (uMsg == WM_SIZE) {
|
||||
if (uMsg == WM_SIZE)
|
||||
{
|
||||
HWND gl_window_id = GetProp (hWnd, "gl_window_id");
|
||||
MoveWindow (gl_window_id, 0, 0, LOWORD (lParam), HIWORD (lParam), FALSE);
|
||||
MoveWindow (gl_window_id, 0, 0, LOWORD(lParam), HIWORD(lParam), FALSE);
|
||||
}
|
||||
|
||||
return CallWindowProc (window_parent_proc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,14 +119,14 @@ gst_gl_window_finalize (GObject * object)
|
|||
|
||||
XSync (priv->device, FALSE);
|
||||
|
||||
while (XPending (priv->device))
|
||||
while(XPending (priv->device))
|
||||
XNextEvent (priv->device, &event);
|
||||
|
||||
XSetCloseDownMode (priv->device, DestroyAll);
|
||||
|
||||
/*XAddToSaveSet (display, w)
|
||||
Display *display;
|
||||
Window w; */
|
||||
Display *display;
|
||||
Window w;*/
|
||||
|
||||
//FIXME: it seems it causes destroy all created windows, even by other display connection:
|
||||
//This is case in: gst-launch-0.10 videotestsrc ! tee name=t t. ! queue ! glimagesink t. ! queue ! glimagesink
|
||||
|
@ -142,14 +142,16 @@ gst_gl_window_finalize (GObject * object)
|
|||
|
||||
g_debug ("display sender closed\n");
|
||||
|
||||
if (priv->cond_send_message) {
|
||||
if (priv->cond_send_message)
|
||||
{
|
||||
g_cond_free (priv->cond_send_message);
|
||||
priv->cond_send_message = NULL;
|
||||
}
|
||||
|
||||
g_mutex_unlock (priv->x_lock);
|
||||
|
||||
if (priv->x_lock) {
|
||||
if (priv->x_lock)
|
||||
{
|
||||
g_mutex_free (priv->x_lock);
|
||||
priv->x_lock = NULL;
|
||||
}
|
||||
|
@ -204,8 +206,8 @@ gst_gl_window_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
|
||||
const gchar * message, gpointer user_data)
|
||||
gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags,
|
||||
const gchar *message, gpointer user_data)
|
||||
{
|
||||
if (_gst_gl_window_debug) {
|
||||
g_log_default_handler (domain, flags, message, user_data);
|
||||
|
@ -229,7 +231,7 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_init (GstGLWindow * window)
|
||||
gst_gl_window_init (GstGLWindow *window)
|
||||
{
|
||||
window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
|
||||
|
||||
|
@ -237,7 +239,7 @@ gst_gl_window_init (GstGLWindow * window)
|
|||
_gst_gl_window_debug = TRUE;
|
||||
|
||||
g_log_set_handler ("GstGLWindow", G_LOG_LEVEL_DEBUG,
|
||||
gst_gl_window_log_handler, NULL);
|
||||
gst_gl_window_log_handler, NULL);
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -268,7 +270,7 @@ gst_gl_window_new (gint width, gint height)
|
|||
static gint x = 0;
|
||||
static gint y = 0;
|
||||
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
priv->x_lock = g_mutex_new ();
|
||||
priv->cond_send_message = g_cond_new ();
|
||||
|
@ -312,7 +314,8 @@ gst_gl_window_new (gint width, gint height)
|
|||
|
||||
priv->visual_info = glXChooseVisual (priv->device, priv->screen_num, attrib);
|
||||
|
||||
if (!priv->visual_info) {
|
||||
if (!priv->visual_info)
|
||||
{
|
||||
g_warning ("glx visual is null (bad attributes)\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -323,8 +326,7 @@ gst_gl_window_new (gint width, gint height)
|
|||
if (priv->visual_info->class == TrueColor)
|
||||
g_debug ("visual is using TrueColor\n");
|
||||
|
||||
g_debug ("visual ID: %d\n",
|
||||
(gint) XVisualIDFromVisual (priv->visual_info->visual));
|
||||
g_debug ("visual ID: %d\n", (gint)XVisualIDFromVisual(priv->visual_info->visual));
|
||||
g_debug ("visual info screen: %d\n", priv->visual_info->screen);
|
||||
g_debug ("visual info visualid: %d\n", (gint) priv->visual_info->visualid);
|
||||
g_debug ("visual info depth: %d\n", priv->visual_info->depth);
|
||||
|
@ -334,23 +336,20 @@ gst_gl_window_new (gint width, gint height)
|
|||
g_debug ("visual info blue_mask: %ld\n", priv->visual_info->blue_mask);
|
||||
g_debug ("visual info bits_per_rgb: %d\n", priv->visual_info->bits_per_rgb);
|
||||
|
||||
win_attr.event_mask =
|
||||
StructureNotifyMask | ExposureMask | VisibilityChangeMask;
|
||||
win_attr.event_mask = StructureNotifyMask | ExposureMask | VisibilityChangeMask;
|
||||
win_attr.do_not_propagate_mask = NoEventMask;
|
||||
|
||||
win_attr.background_pixmap = None;
|
||||
win_attr.background_pixel = 0;
|
||||
win_attr.border_pixel = 0;
|
||||
|
||||
win_attr.colormap =
|
||||
XCreateColormap (priv->device, priv->root, priv->visual_info->visual,
|
||||
AllocNone);
|
||||
win_attr.colormap = XCreateColormap(priv->device, priv->root, priv->visual_info->visual, AllocNone);
|
||||
|
||||
mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
|
||||
width, height, 0, priv->visual_info->depth, InputOutput,
|
||||
priv->visual_info->visual, mask, &win_attr);
|
||||
width, height, 0, priv->visual_info->depth, InputOutput,
|
||||
priv->visual_info->visual, mask, &win_attr);
|
||||
|
||||
x += 20;
|
||||
y += 20;
|
||||
|
@ -359,8 +358,7 @@ gst_gl_window_new (gint width, gint height)
|
|||
|
||||
XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None);
|
||||
|
||||
g_debug ("gl window id: %" G_GUINT64_FORMAT "\n",
|
||||
(guint64) priv->internal_win_id);
|
||||
g_debug ("gl window id: %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
|
||||
|
||||
g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height);
|
||||
|
||||
|
@ -378,22 +376,21 @@ gst_gl_window_new (gint width, gint height)
|
|||
|
||||
XSetWMProtocols (priv->device, priv->internal_win_id, wm_atoms, 2);
|
||||
|
||||
priv->gl_context =
|
||||
glXCreateContext (priv->device, priv->visual_info, NULL, TRUE);
|
||||
priv->gl_context = glXCreateContext (priv->device, priv->visual_info, NULL, TRUE);
|
||||
|
||||
g_debug ("gl context id: %ld\n", (gulong) priv->gl_context);
|
||||
|
||||
if (!glXIsDirect (priv->device, priv->gl_context))
|
||||
if (!glXIsDirect(priv->device, priv->gl_context))
|
||||
g_debug ("direct rendering failed\n");
|
||||
|
||||
wm_hints.flags = StateHint;
|
||||
wm_hints.initial_state = NormalState;
|
||||
wm_hints.input = False;
|
||||
|
||||
XStringListToTextProperty ((char **) &title, 1, &text_property);
|
||||
XStringListToTextProperty ((char**)&title, 1, &text_property);
|
||||
|
||||
XSetWMProperties (priv->device, priv->internal_win_id, &text_property,
|
||||
&text_property, 0, 0, NULL, &wm_hints, NULL);
|
||||
XSetWMProperties (priv->device, priv->internal_win_id, &text_property, &text_property, 0, 0,
|
||||
NULL, &wm_hints, NULL);
|
||||
|
||||
XFree (text_property.value);
|
||||
|
||||
|
@ -420,9 +417,10 @@ gst_gl_window_error_quark (void)
|
|||
|
||||
/* Not called by the gl thread */
|
||||
void
|
||||
gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
|
||||
gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
XWindowAttributes attr;
|
||||
|
||||
|
@ -434,11 +432,9 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
|
|||
|
||||
XGetWindowAttributes (priv->disp_send, priv->parent, &attr);
|
||||
|
||||
XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width,
|
||||
attr.height);
|
||||
XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width, attr.height);
|
||||
|
||||
XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent,
|
||||
attr.x, attr.y);
|
||||
XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent, attr.x, attr.y);
|
||||
|
||||
XSync (priv->disp_send, FALSE);
|
||||
|
||||
|
@ -447,14 +443,13 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
|
||||
gst_gl_window_set_external_gl_context (GstGLWindow *window, guint64 context)
|
||||
{
|
||||
g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -467,8 +462,7 @@ gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_resize_callback (GstGLWindow * window,
|
||||
GstGLWindowCB2 callback, gpointer data)
|
||||
gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -481,8 +475,7 @@ gst_gl_window_set_resize_callback (GstGLWindow * window,
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -496,11 +489,12 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
|
|||
|
||||
/* Called in the gl thread */
|
||||
void
|
||||
gst_gl_window_draw_unlocked (GstGLWindow * window)
|
||||
gst_gl_window_draw_unlocked (GstGLWindow *window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
if (priv->running && priv->allow_extra_expose_events) {
|
||||
if (priv->running && priv->allow_extra_expose_events)
|
||||
{
|
||||
XEvent event;
|
||||
XWindowAttributes attr;
|
||||
|
||||
|
@ -516,42 +510,44 @@ gst_gl_window_draw_unlocked (GstGLWindow * window)
|
|||
event.xexpose.height = attr.height;
|
||||
event.xexpose.count = 0;
|
||||
|
||||
XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask,
|
||||
&event);
|
||||
XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask, &event);
|
||||
XSync (priv->disp_send, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Not called by the gl thread */
|
||||
void
|
||||
gst_gl_window_draw (GstGLWindow * window)
|
||||
gst_gl_window_draw (GstGLWindow *window)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
g_mutex_lock (priv->x_lock);
|
||||
|
||||
if (priv->running) {
|
||||
if (priv->running)
|
||||
{
|
||||
XEvent event;
|
||||
XWindowAttributes attr;
|
||||
|
||||
if (!priv->visible) {
|
||||
if (!priv->visible)
|
||||
{
|
||||
XMapWindow (priv->disp_send, priv->internal_win_id);
|
||||
priv->visible = TRUE;
|
||||
}
|
||||
|
||||
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
|
||||
|
||||
if (priv->parent) {
|
||||
if (priv->parent)
|
||||
{
|
||||
XWindowAttributes attr_parent;
|
||||
XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);
|
||||
|
||||
if (attr.x != attr_parent.x || attr.y != attr_parent.y ||
|
||||
attr.width != attr_parent.width
|
||||
|| attr.height != attr_parent.height) {
|
||||
XMoveResizeWindow (priv->disp_send, priv->internal_win_id,
|
||||
attr_parent.x, attr_parent.y, attr_parent.width,
|
||||
attr_parent.height);
|
||||
attr.width != attr_parent.width || attr.height != attr_parent.height)
|
||||
{
|
||||
XMoveResizeWindow (priv->disp_send, priv->internal_win_id, attr_parent.x, attr_parent.y,
|
||||
attr_parent.width, attr_parent.height);
|
||||
XSync (priv->disp_send, FALSE);
|
||||
|
||||
attr.x = attr_parent.x;
|
||||
|
@ -560,8 +556,8 @@ gst_gl_window_draw (GstGLWindow * window)
|
|||
attr.width = attr_parent.width;
|
||||
attr.height = attr_parent.height;
|
||||
|
||||
g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x,
|
||||
attr_parent.y, attr_parent.width, attr_parent.height);
|
||||
g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x, attr_parent.y,
|
||||
attr_parent.width, attr_parent.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,8 +571,7 @@ gst_gl_window_draw (GstGLWindow * window)
|
|||
event.xexpose.height = attr.height;
|
||||
event.xexpose.count = 0;
|
||||
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, ExposureMask,
|
||||
&event);
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, ExposureMask, &event);
|
||||
XSync (priv->disp_send, FALSE);
|
||||
}
|
||||
|
||||
|
@ -586,7 +581,7 @@ gst_gl_window_draw (GstGLWindow * window)
|
|||
|
||||
/* Called in the gl thread */
|
||||
void
|
||||
gst_gl_window_run_loop (GstGLWindow * window)
|
||||
gst_gl_window_run_loop (GstGLWindow *window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
|
@ -594,21 +589,23 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
|
||||
g_mutex_lock (priv->x_lock);
|
||||
|
||||
while (priv->running) {
|
||||
while (priv->running)
|
||||
{
|
||||
XEvent event;
|
||||
XEvent pending_event;
|
||||
|
||||
g_mutex_unlock (priv->x_lock);
|
||||
|
||||
/* XSendEvent (which are called in other threads) are done from another display structure */
|
||||
XNextEvent (priv->device, &event);
|
||||
XNextEvent(priv->device, &event);
|
||||
|
||||
g_mutex_lock (priv->x_lock);
|
||||
|
||||
// use in generic/cube and other related uses
|
||||
priv->allow_extra_expose_events = XPending (priv->device) <= 2;
|
||||
|
||||
switch (event.type) {
|
||||
switch (event.type)
|
||||
{
|
||||
case ClientMessage:
|
||||
{
|
||||
|
||||
|
@ -624,8 +621,10 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
g_debug ("Cannot create WM_QUIT_LOOP\n");
|
||||
|
||||
/* Message sent with gst_gl_window_send_message */
|
||||
if (wm_gl != None && event.xclient.message_type == wm_gl) {
|
||||
if (priv->running) {
|
||||
if (wm_gl != None && event.xclient.message_type == wm_gl)
|
||||
{
|
||||
if (priv->running)
|
||||
{
|
||||
GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
|
||||
gpointer custom_data = (gpointer) event.xclient.data.l[1];
|
||||
|
||||
|
@ -639,10 +638,9 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
}
|
||||
|
||||
/* User clicked on the cross */
|
||||
else if (wm_delete != None
|
||||
&& (Atom) event.xclient.data.l[0] == wm_delete) {
|
||||
g_debug ("Close %" G_GUINT64_FORMAT "\n",
|
||||
(guint64) priv->internal_win_id);
|
||||
else if (wm_delete != None && (Atom) event.xclient.data.l[0] == wm_delete)
|
||||
{
|
||||
g_debug ("Close %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
|
||||
|
||||
if (priv->close_cb)
|
||||
priv->close_cb (priv->close_data);
|
||||
|
@ -656,22 +654,21 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
}
|
||||
|
||||
/* message sent with gst_gl_window_quit_loop */
|
||||
else if (wm_quit_loop != None
|
||||
&& event.xclient.message_type == wm_quit_loop) {
|
||||
else if (wm_quit_loop != None && event.xclient.message_type == wm_quit_loop)
|
||||
{
|
||||
GstGLWindowCB destroy_cb = (GstGLWindowCB) event.xclient.data.l[0];
|
||||
gpointer destroy_data = (gpointer) event.xclient.data.l[1];
|
||||
|
||||
g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n",
|
||||
(guint64) priv->internal_win_id);
|
||||
g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
|
||||
|
||||
/* exit loop */
|
||||
priv->running = FALSE;
|
||||
|
||||
/* make sure last pendings send message calls are executed */
|
||||
XFlush (priv->device);
|
||||
while (XCheckTypedEvent (priv->device, ClientMessage, &pending_event)) {
|
||||
GstGLWindowCB custom_cb =
|
||||
(GstGLWindowCB) pending_event.xclient.data.l[0];
|
||||
while (XCheckTypedEvent (priv->device, ClientMessage, &pending_event))
|
||||
{
|
||||
GstGLWindowCB custom_cb = (GstGLWindowCB) pending_event.xclient.data.l[0];
|
||||
gpointer custom_data = (gpointer) pending_event.xclient.data.l[1];
|
||||
|
||||
g_debug ("execute last pending custom x events\n");
|
||||
|
@ -690,8 +687,9 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
|
||||
destroy_cb (destroy_data);
|
||||
|
||||
} else
|
||||
g_debug ("client message not reconized \n");
|
||||
}
|
||||
else
|
||||
g_debug("client message not reconized \n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -699,8 +697,7 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
case ConfigureNotify:
|
||||
{
|
||||
if (priv->resize_cb)
|
||||
priv->resize_cb (priv->resize_data, event.xconfigure.width,
|
||||
event.xconfigure.height);
|
||||
priv->resize_cb (priv->resize_data, event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -709,16 +706,18 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
break;
|
||||
|
||||
case Expose:
|
||||
if (priv->draw_cb) {
|
||||
if (priv->draw_cb)
|
||||
{
|
||||
priv->draw_cb (priv->draw_data);
|
||||
glFlush ();
|
||||
glFlush();
|
||||
glXSwapBuffers (priv->device, priv->internal_win_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case VisibilityNotify:
|
||||
{
|
||||
switch (event.xvisibility.state) {
|
||||
switch (event.xvisibility.state)
|
||||
{
|
||||
case VisibilityUnobscured:
|
||||
if (priv->draw_cb)
|
||||
priv->draw_cb (priv->draw_data);
|
||||
|
@ -733,8 +732,7 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
break;
|
||||
|
||||
default:
|
||||
g_debug ("unknown xvisibility event: %d\n",
|
||||
event.xvisibility.state);
|
||||
g_debug("unknown xvisibility event: %d\n", event.xvisibility.state);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -744,9 +742,9 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
g_debug ("unknow\n");
|
||||
break;
|
||||
|
||||
} // switch
|
||||
}// switch
|
||||
|
||||
} // while running
|
||||
}// while running
|
||||
|
||||
g_mutex_unlock (priv->x_lock);
|
||||
|
||||
|
@ -755,29 +753,28 @@ gst_gl_window_run_loop (GstGLWindow * window)
|
|||
|
||||
/* Not called by the gl thread */
|
||||
void
|
||||
gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
g_mutex_lock (priv->x_lock);
|
||||
|
||||
if (priv->running) {
|
||||
if (priv->running)
|
||||
{
|
||||
XEvent event;
|
||||
|
||||
event.xclient.type = ClientMessage;
|
||||
event.xclient.send_event = TRUE;
|
||||
event.xclient.display = priv->disp_send;
|
||||
event.xclient.window = priv->internal_win_id;
|
||||
event.xclient.message_type =
|
||||
XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
|
||||
event.xclient.message_type = XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = (long) callback;
|
||||
event.xclient.data.l[1] = (long) data;
|
||||
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask,
|
||||
&event);
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
|
||||
XSync (priv->disp_send, FALSE);
|
||||
}
|
||||
|
||||
|
@ -787,29 +784,28 @@ gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
|
|||
|
||||
/* Not called by the gl thread */
|
||||
void
|
||||
gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
|
||||
gpointer data)
|
||||
gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
|
||||
{
|
||||
if (window) {
|
||||
if (window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
g_mutex_lock (priv->x_lock);
|
||||
|
||||
if (priv->running) {
|
||||
if (priv->running)
|
||||
{
|
||||
XEvent event;
|
||||
|
||||
event.xclient.type = ClientMessage;
|
||||
event.xclient.send_event = TRUE;
|
||||
event.xclient.display = priv->disp_send;
|
||||
event.xclient.window = priv->internal_win_id;
|
||||
event.xclient.message_type =
|
||||
XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
|
||||
event.xclient.message_type = XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = (long) callback;
|
||||
event.xclient.data.l[1] = (long) data;
|
||||
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask,
|
||||
&event);
|
||||
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
|
||||
XSync (priv->disp_send, FALSE);
|
||||
|
||||
/* block until opengl calls have been executed in the gl thread */
|
||||
|
|
Loading…
Reference in a new issue