[310/906] Global reindent

Indent parameters:
INDENT_PARAMETERS="--braces-on-if-line \
        --case-brace-indentation0 \
        --case-indentation2 \
        --braces-after-struct-decl-line \
        --line-length80 \
        --no-tabs \
        --cuddle-else \
        --dont-line-up-parentheses \
        --honour-newlines \
        --continuation-indentation4 \
        --tab-size8 \
        --indent-level2"
This commit is contained in:
David Schleef 2009-02-10 22:39:14 -08:00 committed by Tim-Philipp Müller
parent 10494006b8
commit 2e2213fbd7
6 changed files with 1802 additions and 1808 deletions

View file

@ -25,10 +25,10 @@
#include "gstglbuffer.h" #include "gstglbuffer.h"
static GObjectClass* gst_gl_buffer_parent_class; static GObjectClass *gst_gl_buffer_parent_class;
static void static void
gst_gl_buffer_finalize (GstGLBuffer* buffer) gst_gl_buffer_finalize (GstGLBuffer * buffer)
{ {
//blocking call, put the texture in the pool //blocking call, put the texture in the pool
gst_gl_display_del_texture (buffer->display, buffer->texture, gst_gl_display_del_texture (buffer->display, buffer->texture,
@ -36,12 +36,12 @@ gst_gl_buffer_finalize (GstGLBuffer* buffer)
g_object_unref (buffer->display); g_object_unref (buffer->display);
GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)-> GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->finalize (GST_MINI_OBJECT
finalize (GST_MINI_OBJECT (buffer)); (buffer));
} }
static void 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;
@ -53,7 +53,7 @@ gst_gl_buffer_init (GstGLBuffer* buffer, gpointer g_class)
static void static void
gst_gl_buffer_class_init (gpointer g_class, gpointer class_data) 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);
@ -87,11 +87,11 @@ gst_gl_buffer_get_type (void)
} }
GstGLBuffer* GstGLBuffer *
gst_gl_buffer_new (GstGLDisplay* display, gst_gl_buffer_new (GstGLDisplay * display, gint gl_width, gint gl_height)
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->display = g_object_ref (display);
gl_buffer->width = gl_width; gl_buffer->width = gl_width;
@ -102,7 +102,8 @@ gst_gl_buffer_new (GstGLDisplay* display,
GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height); GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
//blocking call, generate a texture using the pool //blocking call, generate a texture using the pool
gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width, gl_height) ; gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width,
gl_height);
return gl_buffer; return gl_buffer;
} }
@ -118,9 +119,9 @@ gst_gl_buffer_get_size (gint width, gint height)
gboolean 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); GstStructure *structure = gst_caps_get_structure (caps, 0);
gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl"); gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl");
if (!ret) if (!ret)

File diff suppressed because it is too large Load diff

View file

@ -31,14 +31,14 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static GstStaticPadTemplate gst_gl_filter_src_pad_template = static GstStaticPadTemplate gst_gl_filter_src_pad_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS) GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
); );
static GstStaticPadTemplate gst_gl_filter_sink_pad_template = static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS) GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
@ -55,8 +55,8 @@ static void gst_gl_filter_set_property (GObject * object, guint prop_id,
static void gst_gl_filter_get_property (GObject * object, guint prop_id, 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, static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
GstPadDirection direction, GstCaps* caps); GstPadDirection direction, GstCaps * caps);
static void gst_gl_filter_reset (GstGLFilter * filter); static void gst_gl_filter_reset (GstGLFilter * filter);
static gboolean gst_gl_filter_start (GstBaseTransform * bt); static gboolean gst_gl_filter_start (GstBaseTransform * bt);
static gboolean gst_gl_filter_stop (GstBaseTransform * bt); static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
@ -71,8 +71,8 @@ static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter, static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
GstGLBuffer * inbuf, GstGLBuffer * outbuf); GstGLBuffer * inbuf, GstGLBuffer * outbuf);
/* GstGLDisplayThreadFunc */ /* GstGLDisplayThreadFunc */
static void gst_gl_filter_start_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 gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data);
static void static void
@ -132,8 +132,7 @@ gst_gl_filter_set_property (GObject * object, guint prop_id,
{ {
//GstGLFilter *filter = GST_GL_FILTER (object); //GstGLFilter *filter = GST_GL_FILTER (object);
switch (prop_id) switch (prop_id) {
{
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -146,8 +145,7 @@ gst_gl_filter_get_property (GObject * object, guint prop_id,
{ {
//GstGLFilter *filter = GST_GL_FILTER (object); //GstGLFilter *filter = GST_GL_FILTER (object);
switch (prop_id) switch (prop_id) {
{
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -155,21 +153,20 @@ gst_gl_filter_get_property (GObject * object, guint prop_id,
} }
static void 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) if (filter_class->onReset)
filter_class->onReset (filter); filter_class->onReset (filter);
if (filter_class->display_reset_cb != NULL) { 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 //blocking call, delete the FBO
gst_gl_display_del_fbo (filter->display, filter->fbo, gst_gl_display_del_fbo (filter->display, filter->fbo, filter->depthbuffer);
filter->depthbuffer);
g_object_unref (filter->display); g_object_unref (filter->display);
filter->display = NULL; filter->display = NULL;
} }
@ -180,7 +177,7 @@ gst_gl_filter_reset (GstGLFilter* filter)
} }
static gboolean static gboolean
gst_gl_filter_start (GstBaseTransform* bt) gst_gl_filter_start (GstBaseTransform * bt)
{ {
GstGLFilter *filter = GST_GL_FILTER (bt); GstGLFilter *filter = GST_GL_FILTER (bt);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@ -192,7 +189,7 @@ gst_gl_filter_start (GstBaseTransform* bt)
} }
static gboolean static gboolean
gst_gl_filter_stop (GstBaseTransform* bt) gst_gl_filter_stop (GstBaseTransform * bt)
{ {
GstGLFilter *filter = GST_GL_FILTER (bt); GstGLFilter *filter = GST_GL_FILTER (bt);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@ -206,7 +203,7 @@ gst_gl_filter_stop (GstBaseTransform* bt)
} }
static void 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); GstGLFilter *filter = GST_GL_FILTER (data);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@ -215,7 +212,7 @@ gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data)
} }
static void 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); GstGLFilter *filter = GST_GL_FILTER (data);
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@ -223,14 +220,14 @@ gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data)
filter_class->display_reset_cb (filter); filter_class->display_reset_cb (filter);
} }
static GstCaps* static GstCaps *
gst_gl_filter_transform_caps (GstBaseTransform* bt, gst_gl_filter_transform_caps (GstBaseTransform * bt,
GstPadDirection direction, GstCaps* caps) GstPadDirection direction, GstCaps * caps)
{ {
//GstGLFilter* filter = GST_GL_FILTER (bt); //GstGLFilter* filter = GST_GL_FILTER (bt);
GstStructure* structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
GstCaps* ret = gst_caps_copy (caps); GstCaps *ret = gst_caps_copy (caps);
const GValue* par = NULL; const GValue *par = NULL;
structure = gst_structure_copy (gst_caps_get_structure (ret, 0)); structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
@ -240,13 +237,11 @@ gst_gl_filter_transform_caps (GstBaseTransform* bt,
gst_caps_merge_structure (ret, gst_structure_copy (structure)); 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, 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); gst_caps_merge_structure (ret, structure);
} } else
else
gst_structure_free (structure); gst_structure_free (structure);
GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret); GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret);
@ -256,8 +251,8 @@ gst_gl_filter_transform_caps (GstBaseTransform* bt,
static gboolean static gboolean
gst_gl_filter_get_unit_size (GstBaseTransform* trans, GstCaps* caps, gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
guint* size) guint * size)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
gint width = 0; gint width = 0;
@ -271,18 +266,17 @@ gst_gl_filter_get_unit_size (GstBaseTransform* trans, GstCaps* caps,
} }
static GstFlowReturn static GstFlowReturn
gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans, gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
GstBuffer* inbuf, gint size, GstCaps* caps, GstBuffer** buf) GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf)
{ {
GstGLFilter* filter = NULL; GstGLFilter *filter = NULL;
GstGLBuffer* gl_inbuf = GST_GL_BUFFER (inbuf); GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
GstGLBuffer* gl_outbuf = NULL; GstGLBuffer *gl_outbuf = NULL;
filter = GST_GL_FILTER (trans); filter = GST_GL_FILTER (trans);
if (filter->display == NULL) if (filter->display == NULL) {
{ GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
filter->display = g_object_ref (gl_inbuf->display); filter->display = g_object_ref (gl_inbuf->display);
@ -291,7 +285,8 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
&filter->fbo, &filter->depthbuffer); &filter->fbo, &filter->depthbuffer);
if (filter_class->display_init_cb != NULL) { 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) if (filter_class->onInitFBO)
@ -311,20 +306,19 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
} }
static gboolean static gboolean
gst_gl_filter_set_caps (GstBaseTransform* bt, GstCaps* incaps, gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
GstCaps* outcaps) GstCaps * outcaps)
{ {
GstGLFilter* filter = GST_GL_FILTER (bt); GstGLFilter *filter = GST_GL_FILTER (bt);
gboolean ret = FALSE; 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); ret = gst_gl_buffer_parse_caps (outcaps, &filter->width, &filter->height);
if (filter_class->set_caps) if (filter_class->set_caps)
filter_class->set_caps (filter, incaps, outcaps); filter_class->set_caps (filter, incaps, outcaps);
if (!ret) if (!ret) {
{
GST_DEBUG ("bad caps"); GST_DEBUG ("bad caps");
return FALSE; return FALSE;
} }
@ -335,12 +329,12 @@ gst_gl_filter_set_caps (GstBaseTransform* bt, GstCaps* incaps,
} }
static GstFlowReturn static GstFlowReturn
gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf, gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
GstBuffer* outbuf) GstBuffer * outbuf)
{ {
GstGLFilter* filter; GstGLFilter *filter;
GstGLBuffer* gl_inbuf = GST_GL_BUFFER (inbuf); GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
GstGLBuffer* gl_outbuf = GST_GL_BUFFER (outbuf); GstGLBuffer *gl_outbuf = GST_GL_BUFFER (outbuf);
filter = GST_GL_FILTER (bt); filter = GST_GL_FILTER (bt);
@ -350,10 +344,10 @@ gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf,
} }
static gboolean static gboolean
gst_gl_filter_do_transform (GstGLFilter* filter, gst_gl_filter_do_transform (GstGLFilter * filter,
GstGLBuffer* inbuf, GstGLBuffer* outbuf) 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); filter_class->filter (filter, inbuf, outbuf);
@ -363,15 +357,13 @@ gst_gl_filter_do_transform (GstGLFilter* filter,
/* convenience functions to simplify filter development */ /* convenience functions to simplify filter development */
void void
gst_gl_filter_render_to_target (GstGLFilter *filter, gst_gl_filter_render_to_target (GstGLFilter * filter,
GLuint input, GLuint target, GLuint input, GLuint target, GLCB func, gpointer data)
GLCB func, gpointer data)
{ {
gst_gl_display_use_fbo (filter->display, filter->width, filter->height, gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
filter->fbo, filter->depthbuffer, target, filter->fbo, filter->depthbuffer, target,
func, func,
filter->width, filter->height, input, filter->width, filter->height, input,
0, filter->width, 0, filter->height, 0, filter->width, 0, filter->height,
GST_GL_DISPLAY_PROJECTION_ORTHO2D, GST_GL_DISPLAY_PROJECTION_ORTHO2D, data);
data);
} }

View file

@ -132,8 +132,8 @@ gst_gl_shader_get_property (GObject * object,
} }
static void static void
gst_gl_shader_log_handler (const gchar *domain, GLogLevelFlags flags, gst_gl_shader_log_handler (const gchar * domain, GLogLevelFlags flags,
const gchar *message, gpointer user_data) const gchar * message, gpointer user_data)
{ {
if (_gst_gl_shader_debug) { if (_gst_gl_shader_debug) {
g_log_default_handler (domain, flags, message, user_data); g_log_default_handler (domain, flags, message, user_data);
@ -511,7 +511,7 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
} }
GLint 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; GstGLShaderPrivate *priv;

View file

@ -32,9 +32,11 @@
#define WM_GST_GL_WINDOW_CUSTOM (WM_APP+1) #define WM_GST_GL_WINDOW_CUSTOM (WM_APP+1)
#define WM_GST_GL_WINDOW_QUIT (WM_APP+2) #define WM_GST_GL_WINDOW_QUIT (WM_APP+2)
void gst_gl_window_set_pixel_format (GstGLWindow *window); void gst_gl_window_set_pixel_format (GstGLWindow * window);
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LPARAM lParam);
LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam);
#define GST_GL_WINDOW_GET_PRIVATE(o) \ #define GST_GL_WINDOW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW, GstGLWindowPrivate)) (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW, GstGLWindowPrivate))
@ -79,8 +81,8 @@ gst_gl_window_finalize (GObject * object)
} }
static void static void
gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags, gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
const gchar *message, gpointer user_data) const gchar * message, gpointer user_data)
{ {
if (_gst_gl_window_debug) { if (_gst_gl_window_debug) {
g_log_default_handler (domain, flags, message, user_data); g_log_default_handler (domain, flags, message, user_data);
@ -106,9 +108,8 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
atom = GetClassInfo (hinstance, "GSTGL", &wc); atom = GetClassInfo (hinstance, "GSTGL", &wc);
if (atom == 0) if (atom == 0) {
{ ZeroMemory (&wc, sizeof (WNDCLASS));
ZeroMemory (&wc, sizeof(WNDCLASS));
wc.lpfnWndProc = window_proc; wc.lpfnWndProc = window_proc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
@ -124,12 +125,12 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
atom = RegisterClass (&wc); atom = RegisterClass (&wc);
if (atom == 0) 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 static void
gst_gl_window_init (GstGLWindow *window) gst_gl_window_init (GstGLWindow * window)
{ {
window->priv = GST_GL_WINDOW_GET_PRIVATE (window); window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
@ -146,7 +147,7 @@ gst_gl_window_new (gint width, gint height)
{ {
GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL); GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
GstGLWindowClass* klass = GST_GL_WINDOW_GET_CLASS (window); GstGLWindowClass *klass = GST_GL_WINDOW_GET_CLASS (window);
HINSTANCE hinstance = GetModuleHandle (NULL); HINSTANCE hinstance = GetModuleHandle (NULL);
@ -169,22 +170,16 @@ gst_gl_window_new (gint width, gint height)
priv->visible = FALSE; priv->visible = FALSE;
width += 2 * GetSystemMetrics (SM_CXSIZEFRAME); 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 ( priv->internal_win_id = CreateWindowEx (0,
0,
"GSTGL", "GSTGL",
"OpenGL renderer", "OpenGL renderer",
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
x, y, width, height, x, y, width, height, (HWND) NULL, (HMENU) NULL, hinstance, window);
(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); g_debug ("failed to create gl window: %d\n", priv->internal_win_id);
return NULL; return NULL;
} }
@ -206,36 +201,41 @@ gst_gl_window_error_quark (void)
} }
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; 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; RECT rect;
SetProp (priv->internal_win_id, "gl_window_parent_id", (HWND)id); 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_id", priv->internal_win_id);
SetProp ((HWND)id, "gl_window_parent_proc", (WNDPROC) window_parent_proc); SetProp ((HWND) id, "gl_window_parent_proc", (WNDPROC) window_parent_proc);
SetWindowLongPtr ((HWND)id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc); SetWindowLongPtr ((HWND) id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc);
SetWindowLongPtr (priv->internal_win_id, GWL_STYLE, WS_CHILD | WS_MAXIMIZE); 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 //take changes into account: SWP_FRAMECHANGED
GetClientRect ((HWND)id, &rect); GetClientRect ((HWND) id, &rect);
SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top, rect.right, rect.bottom, SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top,
SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE); rect.right, rect.bottom,
MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right, rect.bottom, FALSE); 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 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"); g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
} }
/* Must be called in the gl thread */ /* Must be called in the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
@ -245,7 +245,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
/* Must be called in the gl thread */ /* Must be called in the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
@ -255,7 +256,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
/* Must be called in the gl thread */ /* Must be called in the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
@ -264,19 +266,18 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
} }
void void
gst_gl_window_draw_unlocked (GstGLWindow *window) gst_gl_window_draw_unlocked (GstGLWindow * window)
{ {
gst_gl_window_draw (window); gst_gl_window_draw (window);
} }
/* Thread safe */ /* Thread safe */
void void
gst_gl_window_draw (GstGLWindow *window) gst_gl_window_draw (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
if (!priv->visible) if (!priv->visible) {
{
ShowWindowAsync (priv->internal_win_id, SW_SHOW); ShowWindowAsync (priv->internal_win_id, SW_SHOW);
priv->visible = TRUE; priv->visible = TRUE;
} }
@ -286,7 +287,7 @@ gst_gl_window_draw (GstGLWindow *window)
} }
void void
gst_gl_window_run_loop (GstGLWindow *window) gst_gl_window_run_loop (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
gboolean running = TRUE; gboolean running = TRUE;
@ -295,15 +296,11 @@ gst_gl_window_run_loop (GstGLWindow *window)
g_debug ("begin loop\n"); g_debug ("begin loop\n");
while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0) while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0) {
{ if (bRet == -1) {
if (bRet == -1) g_error ("Failed to get message %x\r\n", GetLastError ());
{
g_error ("Failed to get message %x\r\n", GetLastError());
running = FALSE; running = FALSE;
} } else {
else
{
TranslateMessage (&msg); TranslateMessage (&msg);
DispatchMessage (&msg); DispatchMessage (&msg);
} }
@ -314,12 +311,13 @@ gst_gl_window_run_loop (GstGLWindow *window)
/* Thread safe */ /* Thread safe */
void 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; 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_assert (SUCCEEDED (res));
g_debug ("end loop requested\n"); g_debug ("end loop requested\n");
} }
@ -327,12 +325,13 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
/* Thread safe */ /* Thread safe */
void 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; 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)); g_assert (SUCCEEDED (res));
} }
} }
@ -340,14 +339,14 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe
/* PRIVATE */ /* PRIVATE */
void void
gst_gl_window_set_pixel_format (GstGLWindow *window) gst_gl_window_set_pixel_format (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
gint pixelformat = 0; gint pixelformat = 0;
gboolean res = FALSE; gboolean res = FALSE;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1; pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA; pfd.iPixelType = PFD_TYPE_RGBA;
@ -376,7 +375,7 @@ gst_gl_window_set_pixel_format (GstGLWindow *window)
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);
@ -385,11 +384,13 @@ gst_gl_window_set_pixel_format (GstGLWindow *window)
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) { if (uMsg == WM_CREATE) {
GstGLWindow *window = (GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams); GstGLWindow *window =
(GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
g_debug ("WM_CREATE\n"); g_debug ("WM_CREATE\n");
@ -403,20 +404,21 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
if (priv->gl_context) if (priv->gl_context)
g_debug ("gl context created: %d\n", priv->gl_context); g_debug ("gl context created: %d\n", priv->gl_context);
else 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); g_assert (priv->gl_context);
ReleaseDC (hWnd, priv->device); ReleaseDC (hWnd, priv->device);
if (!wglMakeCurrent (priv->device, priv->gl_context)) 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); SetProp (hWnd, "gl_window", window);
return 0; 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; GstGLWindowPrivate *priv = NULL;
g_assert (window); g_assert (window);
@ -427,21 +429,20 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
g_assert (priv->internal_win_id == hWnd); 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: case WM_SIZE:
{ {
if (priv->resize_cb) 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; break;
} }
case WM_PAINT: case WM_PAINT:
{ {
if (priv->draw_cb) if (priv->draw_cb) {
{
PAINTSTRUCT ps; PAINTSTRUCT ps;
BeginPaint (hWnd, &ps); BeginPaint (hWnd, &ps);
priv->draw_cb (priv->draw_data); priv->draw_cb (priv->draw_data);
@ -477,13 +478,13 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
destroy_cb ((gpointer) wParam); destroy_cb ((gpointer) wParam);
parent_id = GetProp (hWnd, "gl_window_parent_id"); parent_id = GetProp (hWnd, "gl_window_parent_id");
if (parent_id) if (parent_id) {
{
WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc"); WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc");
g_assert (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); SetParent (hWnd, NULL);
RemoveProp (parent_id, "gl_window_parent_proc"); RemoveProp (parent_id, "gl_window_parent_proc");
@ -494,19 +495,19 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
RemoveProp (hWnd, "gl_window"); RemoveProp (hWnd, "gl_window");
if (!wglMakeCurrent (NULL, NULL)) 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)) 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"); g_debug ("BEFORE\n");
if (!DestroyWindow(priv->internal_win_id)) if (!DestroyWindow (priv->internal_win_id))
g_debug ("failed to destroy window %d, %x\r\n", hWnd, GetLastError()); g_debug ("failed to destroy window %d, %x\r\n", hWnd,
GetLastError ());
g_debug ("AFTER\n"); g_debug ("AFTER\n");
} }
@ -524,8 +525,7 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_GST_GL_WINDOW_CUSTOM: case WM_GST_GL_WINDOW_CUSTOM:
{ {
if (!priv->is_closed) if (!priv->is_closed) {
{
GstGLWindowCB custom_cb = (GstGLWindowCB) lParam; GstGLWindowCB custom_cb = (GstGLWindowCB) lParam;
custom_cb ((gpointer) wParam); custom_cb ((gpointer) wParam);
} }
@ -536,25 +536,23 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
return TRUE; return TRUE;
default: default:
return DefWindowProc( hWnd, uMsg, wParam, lParam ); return DefWindowProc (hWnd, uMsg, wParam, lParam);
} }
return 0; return 0;
} } else
else return DefWindowProc (hWnd, uMsg, wParam, lParam);
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"); 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"); 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); return CallWindowProc (window_parent_proc, hWnd, uMsg, wParam, lParam);
} }

View file

@ -119,14 +119,14 @@ gst_gl_window_finalize (GObject * object)
XSync (priv->device, FALSE); XSync (priv->device, FALSE);
while(XPending (priv->device)) while (XPending (priv->device))
XNextEvent (priv->device, &event); XNextEvent (priv->device, &event);
XSetCloseDownMode (priv->device, DestroyAll); XSetCloseDownMode (priv->device, DestroyAll);
/*XAddToSaveSet (display, w) /*XAddToSaveSet (display, w)
Display *display; Display *display;
Window w;*/ Window w; */
//FIXME: it seems it causes destroy all created windows, even by other display connection: //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 //This is case in: gst-launch-0.10 videotestsrc ! tee name=t t. ! queue ! glimagesink t. ! queue ! glimagesink
@ -142,16 +142,14 @@ gst_gl_window_finalize (GObject * object)
g_debug ("display sender closed\n"); g_debug ("display sender closed\n");
if (priv->cond_send_message) if (priv->cond_send_message) {
{
g_cond_free (priv->cond_send_message); g_cond_free (priv->cond_send_message);
priv->cond_send_message = NULL; priv->cond_send_message = NULL;
} }
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
if (priv->x_lock) if (priv->x_lock) {
{
g_mutex_free (priv->x_lock); g_mutex_free (priv->x_lock);
priv->x_lock = NULL; priv->x_lock = NULL;
} }
@ -206,8 +204,8 @@ gst_gl_window_get_property (GObject * object, guint prop_id,
} }
static void static void
gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags, gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
const gchar *message, gpointer user_data) const gchar * message, gpointer user_data)
{ {
if (_gst_gl_window_debug) { if (_gst_gl_window_debug) {
g_log_default_handler (domain, flags, message, user_data); g_log_default_handler (domain, flags, message, user_data);
@ -231,7 +229,7 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
} }
static void static void
gst_gl_window_init (GstGLWindow *window) gst_gl_window_init (GstGLWindow * window)
{ {
window->priv = GST_GL_WINDOW_GET_PRIVATE (window); window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
@ -270,7 +268,7 @@ gst_gl_window_new (gint width, gint height)
static gint x = 0; static gint x = 0;
static gint y = 0; static gint y = 0;
setlocale(LC_NUMERIC, "C"); setlocale (LC_NUMERIC, "C");
priv->x_lock = g_mutex_new (); priv->x_lock = g_mutex_new ();
priv->cond_send_message = g_cond_new (); priv->cond_send_message = g_cond_new ();
@ -314,8 +312,7 @@ gst_gl_window_new (gint width, gint height)
priv->visual_info = glXChooseVisual (priv->device, priv->screen_num, attrib); 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"); g_warning ("glx visual is null (bad attributes)\n");
return NULL; return NULL;
} }
@ -326,7 +323,8 @@ gst_gl_window_new (gint width, gint height)
if (priv->visual_info->class == TrueColor) if (priv->visual_info->class == TrueColor)
g_debug ("visual is using TrueColor\n"); 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 screen: %d\n", priv->visual_info->screen);
g_debug ("visual info visualid: %d\n", (gint) priv->visual_info->visualid); g_debug ("visual info visualid: %d\n", (gint) priv->visual_info->visualid);
g_debug ("visual info depth: %d\n", priv->visual_info->depth); g_debug ("visual info depth: %d\n", priv->visual_info->depth);
@ -336,14 +334,17 @@ 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 blue_mask: %ld\n", priv->visual_info->blue_mask);
g_debug ("visual info bits_per_rgb: %d\n", priv->visual_info->bits_per_rgb); 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.do_not_propagate_mask = NoEventMask;
win_attr.background_pixmap = None; win_attr.background_pixmap = None;
win_attr.background_pixel = 0; win_attr.background_pixel = 0;
win_attr.border_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; mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
@ -358,7 +359,8 @@ gst_gl_window_new (gint width, gint height)
XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None); 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); g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height);
@ -376,21 +378,22 @@ gst_gl_window_new (gint width, gint height)
XSetWMProtocols (priv->device, priv->internal_win_id, wm_atoms, 2); 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); 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"); g_debug ("direct rendering failed\n");
wm_hints.flags = StateHint; wm_hints.flags = StateHint;
wm_hints.initial_state = NormalState; wm_hints.initial_state = NormalState;
wm_hints.input = False; 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, XSetWMProperties (priv->device, priv->internal_win_id, &text_property,
NULL, &wm_hints, NULL); &text_property, 0, 0, NULL, &wm_hints, NULL);
XFree (text_property.value); XFree (text_property.value);
@ -417,10 +420,9 @@ gst_gl_window_error_quark (void)
/* Not called by the gl thread */ /* Not called by the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
XWindowAttributes attr; XWindowAttributes attr;
@ -432,9 +434,11 @@ gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
XGetWindowAttributes (priv->disp_send, priv->parent, &attr); 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); XSync (priv->disp_send, FALSE);
@ -443,13 +447,14 @@ gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
} }
void 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"); g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
} }
void 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; GstGLWindowPrivate *priv = window->priv;
@ -462,7 +467,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
} }
void 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; GstGLWindowPrivate *priv = window->priv;
@ -475,7 +481,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
} }
void 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; GstGLWindowPrivate *priv = window->priv;
@ -489,12 +496,11 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
/* Called in the gl thread */ /* Called in the gl thread */
void void
gst_gl_window_draw_unlocked (GstGLWindow *window) gst_gl_window_draw_unlocked (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
if (priv->running && priv->allow_extra_expose_events) if (priv->running && priv->allow_extra_expose_events) {
{
XEvent event; XEvent event;
XWindowAttributes attr; XWindowAttributes attr;
@ -510,44 +516,42 @@ gst_gl_window_draw_unlocked (GstGLWindow *window)
event.xexpose.height = attr.height; event.xexpose.height = attr.height;
event.xexpose.count = 0; 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); XSync (priv->disp_send, FALSE);
} }
} }
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_draw (GstGLWindow *window) gst_gl_window_draw (GstGLWindow * window)
{ {
if (window) if (window) {
{
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
if (priv->running) if (priv->running) {
{
XEvent event; XEvent event;
XWindowAttributes attr; XWindowAttributes attr;
if (!priv->visible) if (!priv->visible) {
{
XMapWindow (priv->disp_send, priv->internal_win_id); XMapWindow (priv->disp_send, priv->internal_win_id);
priv->visible = TRUE; priv->visible = TRUE;
} }
XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr); XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
if (priv->parent) if (priv->parent) {
{
XWindowAttributes attr_parent; XWindowAttributes attr_parent;
XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent); XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);
if (attr.x != attr_parent.x || attr.y != attr_parent.y || if (attr.x != attr_parent.x || attr.y != attr_parent.y ||
attr.width != attr_parent.width || attr.height != 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, XMoveResizeWindow (priv->disp_send, priv->internal_win_id,
attr_parent.width, attr_parent.height); attr_parent.x, attr_parent.y, attr_parent.width,
attr_parent.height);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
attr.x = attr_parent.x; attr.x = attr_parent.x;
@ -556,8 +560,8 @@ gst_gl_window_draw (GstGLWindow *window)
attr.width = attr_parent.width; attr.width = attr_parent.width;
attr.height = attr_parent.height; attr.height = attr_parent.height;
g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x, attr_parent.y, g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x,
attr_parent.width, attr_parent.height); attr_parent.y, attr_parent.width, attr_parent.height);
} }
} }
@ -571,7 +575,8 @@ gst_gl_window_draw (GstGLWindow *window)
event.xexpose.height = attr.height; event.xexpose.height = attr.height;
event.xexpose.count = 0; 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); XSync (priv->disp_send, FALSE);
} }
@ -581,7 +586,7 @@ gst_gl_window_draw (GstGLWindow *window)
/* Called in the gl thread */ /* Called in the gl thread */
void void
gst_gl_window_run_loop (GstGLWindow *window) gst_gl_window_run_loop (GstGLWindow * window)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -589,23 +594,21 @@ gst_gl_window_run_loop (GstGLWindow *window)
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
while (priv->running) while (priv->running) {
{
XEvent event; XEvent event;
XEvent pending_event; XEvent pending_event;
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
/* XSendEvent (which are called in other threads) are done from another display structure */ /* 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); g_mutex_lock (priv->x_lock);
// use in generic/cube and other related uses // use in generic/cube and other related uses
priv->allow_extra_expose_events = XPending (priv->device) <= 2; priv->allow_extra_expose_events = XPending (priv->device) <= 2;
switch (event.type) switch (event.type) {
{
case ClientMessage: case ClientMessage:
{ {
@ -647,9 +650,10 @@ gst_gl_window_run_loop (GstGLWindow *window)
} }
/* User clicked on the cross */ /* User clicked on the cross */
else if (wm_delete != None && (Atom) event.xclient.data.l[0] == wm_delete) 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); g_debug ("Close %" G_GUINT64_FORMAT "\n",
(guint64) priv->internal_win_id);
if (priv->close_cb) if (priv->close_cb)
priv->close_cb (priv->close_data); priv->close_cb (priv->close_data);
@ -679,7 +683,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
gpointer destroy_data = (gpointer) event.xclient.data.l[1]; gpointer destroy_data = (gpointer) event.xclient.data.l[1];
#endif #endif
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 */ /* exit loop */
priv->running = FALSE; priv->running = FALSE;
@ -716,9 +721,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
destroy_cb (destroy_data); destroy_cb (destroy_data);
} } else
else g_debug ("client message not reconized \n");
g_debug("client message not reconized \n");
break; break;
} }
@ -726,7 +730,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
case ConfigureNotify: case ConfigureNotify:
{ {
if (priv->resize_cb) 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; break;
} }
@ -735,18 +740,16 @@ gst_gl_window_run_loop (GstGLWindow *window)
break; break;
case Expose: case Expose:
if (priv->draw_cb) if (priv->draw_cb) {
{
priv->draw_cb (priv->draw_data); priv->draw_cb (priv->draw_data);
glFlush(); glFlush ();
glXSwapBuffers (priv->device, priv->internal_win_id); glXSwapBuffers (priv->device, priv->internal_win_id);
} }
break; break;
case VisibilityNotify: case VisibilityNotify:
{ {
switch (event.xvisibility.state) switch (event.xvisibility.state) {
{
case VisibilityUnobscured: case VisibilityUnobscured:
if (priv->draw_cb) if (priv->draw_cb)
priv->draw_cb (priv->draw_data); priv->draw_cb (priv->draw_data);
@ -761,7 +764,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
break; break;
default: default:
g_debug("unknown xvisibility event: %d\n", event.xvisibility.state); g_debug ("unknown xvisibility event: %d\n",
event.xvisibility.state);
break; break;
} }
break; break;
@ -771,9 +775,9 @@ gst_gl_window_run_loop (GstGLWindow *window)
g_debug ("unknow\n"); g_debug ("unknow\n");
break; break;
}// switch } // switch
}// while running } // while running
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
@ -782,23 +786,23 @@ gst_gl_window_run_loop (GstGLWindow *window)
/* Not called by the gl thread */ /* Not called by the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
if (priv->running) if (priv->running) {
{
XEvent event; XEvent event;
event.xclient.type = ClientMessage; event.xclient.type = ClientMessage;
event.xclient.send_event = TRUE; event.xclient.send_event = TRUE;
event.xclient.display = priv->disp_send; event.xclient.display = priv->disp_send;
event.xclient.window = priv->internal_win_id; 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.format = 32;
#if SIZEOF_VOID_P == 8 #if SIZEOF_VOID_P == 8
event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff; event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff;
@ -810,7 +814,8 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
event.xclient.data.l[1] = (long) data; event.xclient.data.l[1] = (long) data;
#endif #endif
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); XSync (priv->disp_send, FALSE);
} }
@ -820,23 +825,23 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
/* Not called by the gl thread */ /* Not called by the gl thread */
void 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; GstGLWindowPrivate *priv = window->priv;
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
if (priv->running) if (priv->running) {
{
XEvent event; XEvent event;
event.xclient.type = ClientMessage; event.xclient.type = ClientMessage;
event.xclient.send_event = TRUE; event.xclient.send_event = TRUE;
event.xclient.display = priv->disp_send; event.xclient.display = priv->disp_send;
event.xclient.window = priv->internal_win_id; 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.format = 32;
#if SIZEOF_VOID_P == 8 #if SIZEOF_VOID_P == 8
event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff; event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff;
@ -848,7 +853,8 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe
event.xclient.data.l[1] = (long) data; event.xclient.data.l[1] = (long) data;
#endif #endif
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); XSync (priv->disp_send, FALSE);
/* block until opengl calls have been executed in the gl thread */ /* block until opengl calls have been executed in the gl thread */