cogl: Port Output away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
946b6c945a
commit
3c6c6a0ea5
@ -31,11 +31,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cogl/cogl-output.h"
|
#include "cogl/cogl-output.h"
|
||||||
#include "cogl/cogl-object-private.h"
|
|
||||||
|
|
||||||
struct _CoglOutput
|
struct _CoglOutput
|
||||||
{
|
{
|
||||||
CoglObject _parent;
|
GObject parent_instance;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
@ -31,32 +31,43 @@
|
|||||||
#include "cogl-config.h"
|
#include "cogl-config.h"
|
||||||
|
|
||||||
#include "cogl/cogl-output-private.h"
|
#include "cogl/cogl-output-private.h"
|
||||||
#include "cogl/cogl-gtype-private.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void _cogl_output_free (CoglOutput *output);
|
G_DEFINE_TYPE (CoglOutput, cogl_output, G_TYPE_OBJECT);
|
||||||
|
|
||||||
COGL_OBJECT_DEFINE (Output, output);
|
static void
|
||||||
COGL_GTYPE_DEFINE_CLASS (Output, output);
|
cogl_output_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
CoglOutput *output = COGL_OUTPUT (object);
|
||||||
|
|
||||||
|
g_free (output->name);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cogl_output_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_output_init (CoglOutput *output)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_output_class_init (CoglOutputClass *class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
|
object_class->dispose = cogl_output_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
CoglOutput *
|
CoglOutput *
|
||||||
_cogl_output_new (const char *name)
|
_cogl_output_new (const char *name)
|
||||||
{
|
{
|
||||||
CoglOutput *output;
|
CoglOutput *output;
|
||||||
|
|
||||||
output = g_new0 (CoglOutput, 1);
|
output = g_object_new (COGL_TYPE_OUTPUT, NULL);
|
||||||
output->name = g_strdup (name);
|
output->name = g_strdup (name);
|
||||||
|
|
||||||
return _cogl_output_object_new (output);
|
return output;
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cogl_output_free (CoglOutput *output)
|
|
||||||
{
|
|
||||||
g_free (output->name);
|
|
||||||
|
|
||||||
g_free (output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -44,8 +44,9 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:cogl-output
|
* CoglOutput:
|
||||||
* @short_description: information about an output device
|
*
|
||||||
|
* Information about an output device
|
||||||
*
|
*
|
||||||
* The #CoglOutput object holds information about an output device
|
* The #CoglOutput object holds information about an output device
|
||||||
* such as a monitor or laptop display. It can be queried to find
|
* such as a monitor or laptop display. It can be queried to find
|
||||||
@ -66,15 +67,15 @@ G_BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _CoglOutput CoglOutput;
|
typedef struct _CoglOutput CoglOutput;
|
||||||
#define COGL_OUTPUT(X) ((CoglOutput *)(X))
|
|
||||||
|
|
||||||
/**
|
#define COGL_TYPE_OUTPUT (cogl_output_get_type ())
|
||||||
* cogl_output_get_gtype:
|
|
||||||
*
|
|
||||||
* Returns: a #GType that can be used with the GLib type system.
|
|
||||||
*/
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
GType cogl_output_get_gtype (void);
|
G_DECLARE_FINAL_TYPE (CoglOutput,
|
||||||
|
cogl_output,
|
||||||
|
COGL,
|
||||||
|
OUTPUT,
|
||||||
|
GObject)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglSubpixelOrder:
|
* CoglSubpixelOrder:
|
||||||
@ -114,18 +115,6 @@ typedef enum
|
|||||||
COGL_SUBPIXEL_ORDER_VERTICAL_BGR
|
COGL_SUBPIXEL_ORDER_VERTICAL_BGR
|
||||||
} CoglSubpixelOrder;
|
} CoglSubpixelOrder;
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_is_output:
|
|
||||||
* @object: A #CoglObject pointer
|
|
||||||
*
|
|
||||||
* Gets whether the given object references a #CoglOutput.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the object references a #CoglOutput
|
|
||||||
* and %FALSE otherwise.
|
|
||||||
*/
|
|
||||||
COGL_EXPORT gboolean
|
|
||||||
cogl_is_output (void *object);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_output_get_x:
|
* cogl_output_get_x:
|
||||||
* @output: a #CoglOutput
|
* @output: a #CoglOutput
|
||||||
|
@ -293,7 +293,7 @@ update_outputs (CoglRenderer *renderer,
|
|||||||
renderer->outputs = g_list_remove_link (renderer->outputs, m);
|
renderer->outputs = g_list_remove_link (renderer->outputs, m);
|
||||||
renderer->outputs = g_list_insert_before (renderer->outputs,
|
renderer->outputs = g_list_insert_before (renderer->outputs,
|
||||||
m_next, output_l);
|
m_next, output_l);
|
||||||
cogl_object_ref (output_l);
|
g_object_ref (output_l);
|
||||||
|
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ update_outputs (CoglRenderer *renderer,
|
|||||||
{
|
{
|
||||||
renderer->outputs =
|
renderer->outputs =
|
||||||
g_list_insert_before (renderer->outputs, m, output_l);
|
g_list_insert_before (renderer->outputs, m, output_l);
|
||||||
cogl_object_ref (output_l);
|
g_object_ref (output_l);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ update_outputs (CoglRenderer *renderer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full (new_outputs, (GDestroyNotify)cogl_object_unref);
|
g_list_free_full (new_outputs, (GDestroyNotify)g_object_unref);
|
||||||
mtk_x11_error_trap_pop (xlib_renderer->xdpy);
|
mtk_x11_error_trap_pop (xlib_renderer->xdpy);
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
@ -481,7 +481,7 @@ _cogl_xlib_renderer_disconnect (CoglRenderer *renderer)
|
|||||||
CoglXlibRenderer *xlib_renderer =
|
CoglXlibRenderer *xlib_renderer =
|
||||||
_cogl_xlib_renderer_get_data (renderer);
|
_cogl_xlib_renderer_get_data (renderer);
|
||||||
|
|
||||||
g_list_free_full (renderer->outputs, (GDestroyNotify)cogl_object_unref);
|
g_list_free_full (renderer->outputs, (GDestroyNotify)g_object_unref);
|
||||||
renderer->outputs = NULL;
|
renderer->outputs = NULL;
|
||||||
|
|
||||||
if (!renderer->foreign_xdpy && xlib_renderer->xdpy)
|
if (!renderer->foreign_xdpy && xlib_renderer->xdpy)
|
||||||
|
@ -224,7 +224,7 @@ cogl_onscreen_glx_dispose (GObject *object)
|
|||||||
|
|
||||||
G_OBJECT_CLASS (cogl_onscreen_glx_parent_class)->dispose (object);
|
G_OBJECT_CLASS (cogl_onscreen_glx_parent_class)->dispose (object);
|
||||||
|
|
||||||
cogl_clear_object (&onscreen_glx->output);
|
g_clear_object (&onscreen_glx->output);
|
||||||
|
|
||||||
if (onscreen_glx->glxwin != None ||
|
if (onscreen_glx->glxwin != None ||
|
||||||
onscreen_glx->xwin != None)
|
onscreen_glx->xwin != None)
|
||||||
@ -1028,12 +1028,12 @@ cogl_onscreen_glx_update_output (CoglOnscreen *onscreen)
|
|||||||
if (onscreen_glx->output != output)
|
if (onscreen_glx->output != output)
|
||||||
{
|
{
|
||||||
if (onscreen_glx->output)
|
if (onscreen_glx->output)
|
||||||
cogl_object_unref (onscreen_glx->output);
|
g_object_unref (onscreen_glx->output);
|
||||||
|
|
||||||
onscreen_glx->output = output;
|
onscreen_glx->output = output;
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
cogl_object_ref (onscreen_glx->output);
|
g_object_ref (onscreen_glx->output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user