mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl: Port Renderer away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
4792db371a
commit
75023d96bc
@ -253,7 +253,7 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
|
||||
goto error;
|
||||
|
||||
/* the display owns the renderer and the swap chain */
|
||||
cogl_object_unref (backend->cogl_renderer);
|
||||
g_object_unref (backend->cogl_renderer);
|
||||
g_object_unref (swap_chain);
|
||||
|
||||
return TRUE;
|
||||
@ -267,7 +267,7 @@ error:
|
||||
|
||||
if (backend->cogl_renderer != NULL)
|
||||
{
|
||||
cogl_object_unref (backend->cogl_renderer);
|
||||
g_object_unref (backend->cogl_renderer);
|
||||
backend->cogl_renderer = NULL;
|
||||
}
|
||||
|
||||
|
@ -230,13 +230,13 @@ cogl_context_new (CoglDisplay *display,
|
||||
CoglRenderer *renderer = cogl_renderer_new ();
|
||||
if (!cogl_renderer_connect (renderer, error))
|
||||
{
|
||||
cogl_object_unref (renderer);
|
||||
g_object_unref (renderer);
|
||||
g_object_unref (context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
display = cogl_display_new (renderer, NULL);
|
||||
cogl_object_unref (renderer);
|
||||
g_object_unref (renderer);
|
||||
}
|
||||
else
|
||||
g_object_ref (display);
|
||||
|
@ -64,7 +64,7 @@ cogl_display_dispose (GObject *object)
|
||||
|
||||
if (display->renderer)
|
||||
{
|
||||
cogl_object_unref (display->renderer);
|
||||
g_object_unref (display->renderer);
|
||||
display->renderer = NULL;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ cogl_display_new (CoglRenderer *renderer,
|
||||
|
||||
display->renderer = renderer;
|
||||
if (renderer)
|
||||
cogl_object_ref (renderer);
|
||||
g_object_ref (renderer);
|
||||
else
|
||||
display->renderer = cogl_renderer_new ();
|
||||
|
||||
|
@ -53,7 +53,7 @@ cogl_poll_renderer_get_info (CoglRenderer *renderer,
|
||||
{
|
||||
GList *l, *next;
|
||||
|
||||
g_return_val_if_fail (cogl_is_renderer (renderer), 0);
|
||||
g_return_val_if_fail (COGL_IS_RENDERER (renderer), 0);
|
||||
g_return_val_if_fail (poll_fds != NULL, 0);
|
||||
g_return_val_if_fail (n_poll_fds != NULL, 0);
|
||||
g_return_val_if_fail (timeout != NULL, 0);
|
||||
@ -95,7 +95,7 @@ cogl_poll_renderer_dispatch (CoglRenderer *renderer,
|
||||
{
|
||||
GList *l, *next;
|
||||
|
||||
g_return_if_fail (cogl_is_renderer (renderer));
|
||||
g_return_if_fail (COGL_IS_RENDERER (renderer));
|
||||
|
||||
_cogl_closure_list_invoke_no_args (&renderer->idle_closures);
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "cogl/cogl-object-private.h"
|
||||
#include "cogl/cogl-driver.h"
|
||||
#include "cogl/cogl-texture-driver.h"
|
||||
#include "cogl/cogl-context.h"
|
||||
@ -43,7 +42,7 @@ typedef const CoglWinsysVtable *(*CoglCustomWinsysVtableGetter) (CoglRenderer *r
|
||||
|
||||
struct _CoglRenderer
|
||||
{
|
||||
CoglObject _parent;
|
||||
GObject parent_instance;
|
||||
gboolean connected;
|
||||
CoglDriver driver_override;
|
||||
const CoglDriverVtable *driver_vtable;
|
||||
|
@ -37,14 +37,12 @@
|
||||
|
||||
#include "cogl/cogl-util.h"
|
||||
#include "cogl/cogl-private.h"
|
||||
#include "cogl/cogl-object.h"
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-mutter.h"
|
||||
|
||||
#include "cogl/cogl-renderer.h"
|
||||
#include "cogl/cogl-renderer-private.h"
|
||||
#include "cogl/cogl-display-private.h"
|
||||
#include "cogl/cogl-gtype-private.h"
|
||||
|
||||
#include "cogl/winsys/cogl-winsys-private.h"
|
||||
|
||||
@ -129,10 +127,11 @@ static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static void _cogl_renderer_free (CoglRenderer *renderer);
|
||||
|
||||
COGL_OBJECT_DEFINE (Renderer, renderer);
|
||||
COGL_GTYPE_DEFINE_CLASS (Renderer, renderer);
|
||||
static const CoglWinsysVtable *
|
||||
_cogl_renderer_get_winsys (CoglRenderer *renderer)
|
||||
{
|
||||
return renderer->winsys_vtable;
|
||||
}
|
||||
|
||||
typedef struct _CoglNativeFilterClosure
|
||||
{
|
||||
@ -140,27 +139,19 @@ typedef struct _CoglNativeFilterClosure
|
||||
void *data;
|
||||
} CoglNativeFilterClosure;
|
||||
|
||||
uint32_t
|
||||
cogl_renderer_error_quark (void)
|
||||
{
|
||||
return g_quark_from_static_string ("cogl-renderer-error-quark");
|
||||
}
|
||||
|
||||
static const CoglWinsysVtable *
|
||||
_cogl_renderer_get_winsys (CoglRenderer *renderer)
|
||||
{
|
||||
return renderer->winsys_vtable;
|
||||
}
|
||||
|
||||
static void
|
||||
native_filter_closure_free (CoglNativeFilterClosure *closure)
|
||||
{
|
||||
g_free (closure);
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE (CoglRenderer, cogl_renderer, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
_cogl_renderer_free (CoglRenderer *renderer)
|
||||
cogl_renderer_dispose (GObject *object)
|
||||
{
|
||||
CoglRenderer *renderer = COGL_RENDERER (object);
|
||||
|
||||
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
||||
|
||||
_cogl_closure_list_disconnect_all (&renderer->idle_closures);
|
||||
@ -176,13 +167,32 @@ _cogl_renderer_free (CoglRenderer *renderer)
|
||||
|
||||
g_array_free (renderer->poll_fds, TRUE);
|
||||
|
||||
g_free (renderer);
|
||||
G_OBJECT_CLASS (cogl_renderer_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_renderer_init (CoglRenderer *renderer)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_renderer_class_init (CoglRendererClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->dispose = cogl_renderer_dispose;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
cogl_renderer_error_quark (void)
|
||||
{
|
||||
return g_quark_from_static_string ("cogl-renderer-error-quark");
|
||||
}
|
||||
|
||||
CoglRenderer *
|
||||
cogl_renderer_new (void)
|
||||
{
|
||||
CoglRenderer *renderer = g_new0 (CoglRenderer, 1);
|
||||
CoglRenderer *renderer = g_object_new (COGL_TYPE_RENDERER, NULL);
|
||||
|
||||
_cogl_init ();
|
||||
|
||||
@ -197,7 +207,7 @@ cogl_renderer_new (void)
|
||||
renderer->xlib_enable_event_retrieval = TRUE;
|
||||
#endif
|
||||
|
||||
return _cogl_renderer_object_new (renderer);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
#ifdef COGL_HAS_XLIB
|
||||
@ -205,7 +215,7 @@ void
|
||||
cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer,
|
||||
Display *xdisplay)
|
||||
{
|
||||
g_return_if_fail (cogl_is_renderer (renderer));
|
||||
g_return_if_fail (COGL_IS_RENDERER (renderer));
|
||||
|
||||
/* NB: Renderers are considered immutable once connected */
|
||||
g_return_if_fail (!renderer->connected);
|
||||
@ -220,7 +230,7 @@ cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer,
|
||||
Display *
|
||||
cogl_xlib_renderer_get_foreign_display (CoglRenderer *renderer)
|
||||
{
|
||||
g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_RENDERER (renderer), NULL);
|
||||
|
||||
return renderer->foreign_xdpy;
|
||||
}
|
||||
@ -229,7 +239,7 @@ void
|
||||
cogl_xlib_renderer_request_reset_on_video_memory_purge (CoglRenderer *renderer,
|
||||
gboolean enable)
|
||||
{
|
||||
g_return_if_fail (cogl_is_renderer (renderer));
|
||||
g_return_if_fail (COGL_IS_RENDERER (renderer));
|
||||
g_return_if_fail (!renderer->connected);
|
||||
|
||||
renderer->xlib_want_reset_on_video_memory_purge = enable;
|
||||
|
@ -42,8 +42,9 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-renderer
|
||||
* @short_description: Choosing a means to render
|
||||
* CoglRenderer:
|
||||
*
|
||||
* Choosing a means to render
|
||||
*
|
||||
* A #CoglRenderer represents a means to render. It encapsulates the
|
||||
* selection of an underlying driver, such as OpenGL or OpenGL-ES and
|
||||
@ -85,24 +86,15 @@ cogl_renderer_error_quark (void);
|
||||
|
||||
typedef struct _CoglRenderer CoglRenderer;
|
||||
|
||||
/**
|
||||
* cogl_renderer_get_gtype:
|
||||
*
|
||||
* Returns: a #GType that can be used with the GLib type system.
|
||||
*/
|
||||
COGL_EXPORT
|
||||
GType cogl_renderer_get_gtype (void);
|
||||
#define COGL_TYPE_RENDERER (cogl_renderer_get_type ())
|
||||
|
||||
COGL_EXPORT
|
||||
G_DECLARE_FINAL_TYPE (CoglRenderer,
|
||||
cogl_renderer,
|
||||
COGL,
|
||||
RENDERER,
|
||||
GObject)
|
||||
|
||||
/**
|
||||
* cogl_is_renderer:
|
||||
* @object: A #CoglObject pointer
|
||||
*
|
||||
* Determines if the given @object is a #CoglRenderer
|
||||
*
|
||||
* Return value: %TRUE if @object is a #CoglRenderer, else %FALSE.
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_is_renderer (void *object);
|
||||
|
||||
/**
|
||||
* cogl_renderer_new:
|
||||
|
@ -497,7 +497,7 @@ cogl_xlib_renderer_get_display (CoglRenderer *renderer)
|
||||
{
|
||||
CoglXlibRenderer *xlib_renderer;
|
||||
|
||||
g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_RENDERER (renderer), NULL);
|
||||
|
||||
xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user