[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:
David Schleef 2009-02-10 21:57:31 -08:00 committed by Tim-Philipp Müller
parent 2f0e5b1dc4
commit f0b62d760f
6 changed files with 1858 additions and 1848 deletions

View File

@ -36,8 +36,8 @@ 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)->finalize (GST_MINI_OBJECT GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->
(buffer)); finalize (GST_MINI_OBJECT (buffer));
} }
static void static void
@ -88,10 +88,10 @@ gst_gl_buffer_get_type (void)
GstGLBuffer* GstGLBuffer*
gst_gl_buffer_new (GstGLDisplay * display, gint gl_width, gint gl_height) gst_gl_buffer_new (GstGLDisplay* display,
gint gl_width, gint gl_height)
{ {
GstGLBuffer *gl_buffer = GstGLBuffer* gl_buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_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,8 +102,7 @@ gst_gl_buffer_new (GstGLDisplay * display, gint gl_width, gint gl_height)
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, gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width, gl_height) ;
gl_height);
return gl_buffer; return gl_buffer;
} }

File diff suppressed because it is too large Load Diff

View File

@ -132,7 +132,8 @@ 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;
@ -145,7 +146,8 @@ 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;
@ -157,16 +159,17 @@ 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, gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl, filter);
filter);
} }
//blocking call, delete the FBO //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); g_object_unref (filter->display);
filter->display = NULL; filter->display = NULL;
} }
@ -237,11 +240,13 @@ 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);
@ -275,7 +280,8 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
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);
@ -285,8 +291,7 @@ 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, gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
filter);
} }
if (filter_class->onInitFBO) if (filter_class->onInitFBO)
@ -318,7 +323,8 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
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;
} }
@ -358,12 +364,14 @@ gst_gl_filter_do_transform (GstGLFilter * filter,
void void
gst_gl_filter_render_to_target (GstGLFilter *filter, gst_gl_filter_render_to_target (GstGLFilter *filter,
GLuint input, GLuint target, GLCB func, gpointer data) GLuint input, GLuint target,
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, data); GST_GL_DISPLAY_PROJECTION_ORTHO2D,
data);
} }

View File

@ -33,10 +33,8 @@
#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, LRESULT CALLBACK window_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);
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))
@ -108,7 +106,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;
@ -170,16 +169,22 @@ 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 += height += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
priv->internal_win_id = CreateWindowEx (0, priv->internal_win_id = CreateWindowEx (
0,
"GSTGL", "GSTGL",
"OpenGL renderer", "OpenGL renderer",
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
x, y, width, height, (HWND) NULL, (HMENU) NULL, hinstance, window); 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); g_debug ("failed to create gl window: %d\n", priv->internal_win_id);
return NULL; return NULL;
} }
@ -204,8 +209,7 @@ 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 window_parent_proc = (WNDPROC) (guint64) GetWindowLongPtr((HWND)id, GWL_WNDPROC);
(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);
@ -218,12 +222,9 @@ gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 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, SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top, rect.right, rect.bottom,
rect.right, rect.bottom, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE);
SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right, rect.bottom, FALSE);
SWP_FRAMECHANGED | SWP_NOACTIVATE);
MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right,
rect.bottom, FALSE);
} }
void void
@ -234,8 +235,7 @@ gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
/* 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, gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; 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 */ /* Must be called in the gl thread */
void void
gst_gl_window_set_resize_callback (GstGLWindow * window, gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
GstGLWindowCB2 callback, gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -256,8 +255,7 @@ gst_gl_window_set_resize_callback (GstGLWindow * window,
/* 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, gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -277,7 +275,8 @@ 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;
} }
@ -296,11 +295,15 @@ 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);
} }
@ -311,13 +314,12 @@ gst_gl_window_run_loop (GstGLWindow * window)
/* Thread safe */ /* Thread safe */
void void
gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback, gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
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, LRESULT res = PostMessage(priv->internal_win_id, WM_GST_GL_WINDOW_QUIT, (WPARAM) data, (LPARAM) callback);
(WPARAM) data, (LPARAM) callback);
g_assert (SUCCEEDED (res)); g_assert (SUCCEEDED (res));
g_debug ("end loop requested\n"); g_debug ("end loop requested\n");
} }
@ -325,13 +327,12 @@ gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
/* Thread safe */ /* Thread safe */
void void
gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback, gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
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, LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM, (WPARAM) data, (LPARAM) callback);
(WPARAM) data, (LPARAM) callback);
g_assert (SUCCEEDED (res)); g_assert (SUCCEEDED (res));
} }
} }
@ -384,13 +385,11 @@ gst_gl_window_set_pixel_format (GstGLWindow * window)
g_assert (res); g_assert (res);
} }
LRESULT CALLBACK LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (uMsg == WM_CREATE) { if (uMsg == WM_CREATE) {
GstGLWindow *window = GstGLWindow *window = (GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
(GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
g_debug ("WM_CREATE\n"); g_debug ("WM_CREATE\n");
@ -404,19 +403,18 @@ 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, g_debug ("failed to create glcontext %d, %x\r\n", hWnd, GetLastError());
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, g_debug ("failed to make opengl context current %d, %x\r\n", hWnd, GetLastError());
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;
@ -442,7 +440,8 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
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);
@ -478,13 +477,13 @@ 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, SetWindowLongPtr (parent_id, GWL_WNDPROC, (LONG) (guint64) parent_proc);
(LONG) (guint64) parent_proc);
SetParent (hWnd, NULL); SetParent (hWnd, NULL);
RemoveProp (parent_id, "gl_window_parent_proc"); RemoveProp (parent_id, "gl_window_parent_proc");
@ -497,17 +496,17 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
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, g_debug ("failed to destroy context %d, %x\r\n", priv->gl_context, GetLastError());
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, g_debug ("failed to destroy window %d, %x\r\n", hWnd, GetLastError());
GetLastError ());
g_debug ("AFTER\n"); g_debug ("AFTER\n");
} }
@ -525,7 +524,8 @@ 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);
} }
@ -540,19 +540,21 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return 0; return 0;
} else }
else
return DefWindowProc( hWnd, uMsg, wParam, lParam ); return DefWindowProc( hWnd, uMsg, wParam, lParam );
} }
LRESULT FAR PASCAL LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
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

@ -142,14 +142,16 @@ 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;
} }
@ -312,7 +314,8 @@ 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;
} }
@ -323,8 +326,7 @@ 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", g_debug ("visual ID: %d\n", (gint)XVisualIDFromVisual(priv->visual_info->visual));
(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);
@ -334,17 +336,14 @@ 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 = win_attr.event_mask = StructureNotifyMask | ExposureMask | VisibilityChangeMask;
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 = win_attr.colormap = XCreateColormap(priv->device, priv->root, priv->visual_info->visual, AllocNone);
XCreateColormap (priv->device, priv->root, priv->visual_info->visual,
AllocNone);
mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask; mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
@ -359,8 +358,7 @@ 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", g_debug ("gl window id: %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
(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);
@ -378,8 +376,7 @@ 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 = priv->gl_context = glXCreateContext (priv->device, priv->visual_info, NULL, TRUE);
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);
@ -392,8 +389,8 @@ gst_gl_window_new (gint width, gint height)
XStringListToTextProperty ((char**)&title, 1, &text_property); XStringListToTextProperty ((char**)&title, 1, &text_property);
XSetWMProperties (priv->device, priv->internal_win_id, &text_property, XSetWMProperties (priv->device, priv->internal_win_id, &text_property, &text_property, 0, 0,
&text_property, 0, 0, NULL, &wm_hints, NULL); NULL, &wm_hints, NULL);
XFree (text_property.value); XFree (text_property.value);
@ -422,7 +419,8 @@ 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)
{ {
if (window) { if (window)
{
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
XWindowAttributes attr; XWindowAttributes attr;
@ -434,11 +432,9 @@ 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, XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width, attr.height);
attr.height);
XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent, XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent, attr.x, attr.y);
attr.x, attr.y);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
@ -453,8 +449,7 @@ gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
} }
void void
gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback, gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -467,8 +462,7 @@ gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
} }
void void
gst_gl_window_set_resize_callback (GstGLWindow * window, gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
GstGLWindowCB2 callback, gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -481,8 +475,7 @@ gst_gl_window_set_resize_callback (GstGLWindow * window,
} }
void void
gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback, gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
gpointer data)
{ {
GstGLWindowPrivate *priv = window->priv; GstGLWindowPrivate *priv = window->priv;
@ -500,7 +493,8 @@ 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;
@ -516,8 +510,7 @@ 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, XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask, &event);
&event);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
} }
} }
@ -526,32 +519,35 @@ gst_gl_window_draw_unlocked (GstGLWindow * window)
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.width != attr_parent.width || attr.height != attr_parent.height)
|| attr.height != attr_parent.height) { {
XMoveResizeWindow (priv->disp_send, priv->internal_win_id, XMoveResizeWindow (priv->disp_send, priv->internal_win_id, attr_parent.x, attr_parent.y,
attr_parent.x, attr_parent.y, attr_parent.width, attr_parent.width, attr_parent.height);
attr_parent.height);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
attr.x = attr_parent.x; attr.x = attr_parent.x;
@ -560,8 +556,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, g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x, attr_parent.y,
attr_parent.y, attr_parent.width, attr_parent.height); attr_parent.width, attr_parent.height);
} }
} }
@ -575,8 +571,7 @@ 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, XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, ExposureMask, &event);
&event);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
} }
@ -594,7 +589,8 @@ 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;
@ -608,7 +604,8 @@ gst_gl_window_run_loop (GstGLWindow * window)
// 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:
{ {
@ -624,8 +621,10 @@ gst_gl_window_run_loop (GstGLWindow * window)
g_debug ("Cannot create WM_QUIT_LOOP\n"); g_debug ("Cannot create WM_QUIT_LOOP\n");
/* Message sent with gst_gl_window_send_message */ /* Message sent with gst_gl_window_send_message */
if (wm_gl != None && event.xclient.message_type == wm_gl) { if (wm_gl != None && event.xclient.message_type == wm_gl)
if (priv->running) { {
if (priv->running)
{
GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0]; GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
gpointer custom_data = (gpointer) event.xclient.data.l[1]; 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 */ /* User clicked on the cross */
else if (wm_delete != None else if (wm_delete != None && (Atom) event.xclient.data.l[0] == wm_delete)
&& (Atom) event.xclient.data.l[0] == wm_delete) { {
g_debug ("Close %" G_GUINT64_FORMAT "\n", g_debug ("Close %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
(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);
@ -656,22 +654,21 @@ gst_gl_window_run_loop (GstGLWindow * window)
} }
/* message sent with gst_gl_window_quit_loop */ /* message sent with gst_gl_window_quit_loop */
else if (wm_quit_loop != None else if (wm_quit_loop != None && event.xclient.message_type == wm_quit_loop)
&& event.xclient.message_type == wm_quit_loop) { {
GstGLWindowCB destroy_cb = (GstGLWindowCB) event.xclient.data.l[0]; GstGLWindowCB destroy_cb = (GstGLWindowCB) event.xclient.data.l[0];
gpointer destroy_data = (gpointer) event.xclient.data.l[1]; gpointer destroy_data = (gpointer) event.xclient.data.l[1];
g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n", g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
(guint64) priv->internal_win_id);
/* exit loop */ /* exit loop */
priv->running = FALSE; priv->running = FALSE;
/* make sure last pendings send message calls are executed */ /* make sure last pendings send message calls are executed */
XFlush (priv->device); XFlush (priv->device);
while (XCheckTypedEvent (priv->device, ClientMessage, &pending_event)) { while (XCheckTypedEvent (priv->device, ClientMessage, &pending_event))
GstGLWindowCB custom_cb = {
(GstGLWindowCB) pending_event.xclient.data.l[0]; GstGLWindowCB custom_cb = (GstGLWindowCB) pending_event.xclient.data.l[0];
gpointer custom_data = (gpointer) pending_event.xclient.data.l[1]; gpointer custom_data = (gpointer) pending_event.xclient.data.l[1];
g_debug ("execute last pending custom x events\n"); g_debug ("execute last pending custom x events\n");
@ -690,7 +687,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;
} }
@ -699,8 +697,7 @@ 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, priv->resize_cb (priv->resize_data, event.xconfigure.width, event.xconfigure.height);
event.xconfigure.height);
break; break;
} }
@ -709,7 +706,8 @@ 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);
@ -718,7 +716,8 @@ gst_gl_window_run_loop (GstGLWindow * window)
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);
@ -733,8 +732,7 @@ gst_gl_window_run_loop (GstGLWindow * window)
break; break;
default: default:
g_debug ("unknown xvisibility event: %d\n", g_debug("unknown xvisibility event: %d\n", event.xvisibility.state);
event.xvisibility.state);
break; break;
} }
break; break;
@ -755,29 +753,28 @@ 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, gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
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 = event.xclient.message_type = XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
event.xclient.format = 32; event.xclient.format = 32;
event.xclient.data.l[0] = (long) callback; event.xclient.data.l[0] = (long) callback;
event.xclient.data.l[1] = (long) data; event.xclient.data.l[1] = (long) data;
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
&event);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
} }
@ -787,29 +784,28 @@ gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
/* Not called by the gl thread */ /* Not called by the gl thread */
void void
gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback, gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
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 = event.xclient.message_type = XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
event.xclient.format = 32; event.xclient.format = 32;
event.xclient.data.l[0] = (long) callback; event.xclient.data.l[0] = (long) callback;
event.xclient.data.l[1] = (long) data; event.xclient.data.l[1] = (long) data;
XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
&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 */