mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
[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:
parent
10494006b8
commit
2e2213fbd7
6 changed files with 1802 additions and 1808 deletions
|
@ -25,10 +25,10 @@
|
|||
|
||||
#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,
|
||||
|
@ -36,12 +36,12 @@ gst_gl_buffer_finalize (GstGLBuffer* buffer)
|
|||
|
||||
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;
|
||||
|
||||
|
@ -53,7 +53,7 @@ gst_gl_buffer_init (GstGLBuffer* buffer, gpointer g_class)
|
|||
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);
|
||||
|
||||
|
@ -87,11 +87,11 @@ 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;
|
||||
|
@ -102,7 +102,8 @@ gst_gl_buffer_new (GstGLDisplay* display,
|
|||
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) ;
|
||||
gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width,
|
||||
gl_height);
|
||||
|
||||
return gl_buffer;
|
||||
}
|
||||
|
@ -118,9 +119,9 @@ gst_gl_buffer_get_size (gint width, gint height)
|
|||
|
||||
|
||||
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");
|
||||
|
||||
if (!ret)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,14 +31,14 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
|
||||
|
||||
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
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_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
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,
|
||||
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);
|
||||
|
@ -71,8 +71,8 @@ static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|||
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
||||
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
|
||||
|
@ -132,8 +132,7 @@ gst_gl_filter_set_property (GObject * object, guint prop_id,
|
|||
{
|
||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -146,8 +145,7 @@ gst_gl_filter_get_property (GObject * object, guint prop_id,
|
|||
{
|
||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -155,21 +153,20 @@ gst_gl_filter_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -180,7 +177,7 @@ 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);
|
||||
|
@ -192,7 +189,7 @@ gst_gl_filter_start (GstBaseTransform* bt)
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -206,7 +203,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);
|
||||
|
@ -215,7 +212,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);
|
||||
|
@ -223,14 +220,14 @@ 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));
|
||||
|
||||
|
@ -240,13 +237,11 @@ gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
|||
|
||||
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);
|
||||
gst_caps_merge_structure (ret, structure);
|
||||
}
|
||||
else
|
||||
} else
|
||||
gst_structure_free (structure);
|
||||
|
||||
GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret);
|
||||
|
@ -256,8 +251,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;
|
||||
|
@ -271,18 +266,17 @@ 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);
|
||||
|
||||
|
@ -291,7 +285,8 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
|
|||
&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)
|
||||
|
@ -311,20 +306,19 @@ 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;
|
||||
}
|
||||
|
@ -335,12 +329,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);
|
||||
|
||||
|
@ -350,10 +344,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);
|
||||
|
||||
|
@ -363,15 +357,13 @@ 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);
|
||||
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);
|
||||
|
@ -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,9 +32,11 @@
|
|||
#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))
|
||||
|
@ -79,8 +81,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);
|
||||
|
@ -106,9 +108,8 @@ 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;
|
||||
|
@ -124,12 +125,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);
|
||||
|
||||
|
@ -146,7 +147,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);
|
||||
|
||||
|
@ -169,22 +170,16 @@ 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,
|
||||
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
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
@ -206,36 +201,41 @@ 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,7 +245,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -255,7 +256,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -264,19 +266,18 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -286,7 +287,7 @@ gst_gl_window_draw (GstGLWindow *window)
|
|||
}
|
||||
|
||||
void
|
||||
gst_gl_window_run_loop (GstGLWindow *window)
|
||||
gst_gl_window_run_loop (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
gboolean running = TRUE;
|
||||
|
@ -295,15 +296,11 @@ 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());
|
||||
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
|
||||
{
|
||||
} else {
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
|
@ -314,12 +311,13 @@ 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");
|
||||
}
|
||||
|
@ -327,12 +325,13 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
|
|||
|
||||
/* 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));
|
||||
}
|
||||
}
|
||||
|
@ -340,14 +339,14 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe
|
|||
/* 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;
|
||||
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
|
@ -376,7 +375,7 @@ gst_gl_window_set_pixel_format (GstGLWindow *window)
|
|||
|
||||
pfd.cColorBits = (BYTE) GetDeviceCaps (priv->device, BITSPIXEL);
|
||||
|
||||
pixelformat = ChoosePixelFormat (priv->device, &pfd );
|
||||
pixelformat = ChoosePixelFormat (priv->device, &pfd);
|
||||
|
||||
g_assert (pixelformat);
|
||||
|
||||
|
@ -385,11 +384,13 @@ gst_gl_window_set_pixel_format (GstGLWindow *window)
|
|||
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");
|
||||
|
||||
|
@ -403,20 +404,21 @@ LRESULT CALLBACK 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);
|
||||
|
@ -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->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);
|
||||
|
@ -477,13 +478,13 @@ LRESULT CALLBACK 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");
|
||||
|
@ -494,19 +495,19 @@ LRESULT CALLBACK 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");
|
||||
}
|
||||
|
||||
|
@ -524,8 +525,7 @@ LRESULT CALLBACK 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,25 +536,23 @@ LRESULT CALLBACK 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;*/
|
||||
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,16 +142,14 @@ 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;
|
||||
}
|
||||
|
@ -206,8 +204,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);
|
||||
|
@ -231,7 +229,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);
|
||||
|
||||
|
@ -270,7 +268,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 ();
|
||||
|
@ -314,8 +312,7 @@ 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;
|
||||
}
|
||||
|
@ -326,7 +323,8 @@ 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);
|
||||
|
@ -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 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;
|
||||
|
||||
|
@ -358,7 +359,8 @@ 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);
|
||||
|
||||
|
@ -376,21 +378,22 @@ 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);
|
||||
|
||||
|
@ -417,10 +420,9 @@ 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;
|
||||
|
||||
|
@ -432,9 +434,11 @@ 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);
|
||||
|
||||
|
@ -443,13 +447,14 @@ 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;
|
||||
|
||||
|
@ -462,7 +467,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -475,7 +481,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -489,12 +496,11 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -510,44 +516,42 @@ 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;
|
||||
|
@ -556,8 +560,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +575,8 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -581,7 +586,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;
|
||||
|
||||
|
@ -589,23 +594,21 @@ 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:
|
||||
{
|
||||
|
||||
|
@ -647,9 +650,10 @@ 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);
|
||||
|
@ -679,7 +683,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
|
|||
gpointer destroy_data = (gpointer) event.xclient.data.l[1];
|
||||
#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 */
|
||||
priv->running = FALSE;
|
||||
|
@ -716,9 +721,8 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -726,7 +730,8 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -735,18 +740,16 @@ 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);
|
||||
|
@ -761,7 +764,8 @@ 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;
|
||||
|
@ -771,9 +775,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);
|
||||
|
||||
|
@ -782,23 +786,23 @@ 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;
|
||||
#if SIZEOF_VOID_P == 8
|
||||
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;
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@ -820,23 +825,23 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
|
|||
|
||||
/* 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;
|
||||
#if SIZEOF_VOID_P == 8
|
||||
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;
|
||||
#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);
|
||||
|
||||
/* block until opengl calls have been executed in the gl thread */
|
||||
|
|
Loading…
Reference in a new issue