mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
clutter/image: Port to G_DECLARE_DERIVABLE_TYPE
Cleanup all the boilerplate, and port the function to use the auto generated private helper. Remove the manual autocleanup declaration since this is now done in the clutter-image.h header. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
This commit is contained in:
parent
ca19109ac6
commit
a2c999b6b1
@ -51,7 +51,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref)
|
|||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFixedLayout, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFixedLayout, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterImage, g_object_unref)
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterKeyframeTransition, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterKeyframeTransition, g_object_unref)
|
||||||
|
@ -48,12 +48,12 @@
|
|||||||
#include "clutter-paint-nodes.h"
|
#include "clutter-paint-nodes.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
|
|
||||||
struct _ClutterImagePrivate
|
typedef struct
|
||||||
{
|
{
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
};
|
} ClutterImagePrivate;
|
||||||
|
|
||||||
static void clutter_content_iface_init (ClutterContentInterface *iface);
|
static void clutter_content_iface_init (ClutterContentInterface *iface);
|
||||||
|
|
||||||
@ -88,20 +88,21 @@ create_texture_from_data (unsigned int width,
|
|||||||
static void
|
static void
|
||||||
update_image_size (ClutterImage *self)
|
update_image_size (ClutterImage *self)
|
||||||
{
|
{
|
||||||
|
ClutterImagePrivate *priv = clutter_image_get_instance_private (self);
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
if (self->priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
width = cogl_texture_get_width (self->priv->texture);
|
width = cogl_texture_get_width (priv->texture);
|
||||||
height = cogl_texture_get_height (self->priv->texture);
|
height = cogl_texture_get_height (priv->texture);
|
||||||
|
|
||||||
if (self->priv->width == width &&
|
if (priv->width == width &&
|
||||||
self->priv->height == height)
|
priv->height == height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self->priv->width = width;
|
priv->width = width;
|
||||||
self->priv->height = height;
|
priv->height = height;
|
||||||
|
|
||||||
clutter_content_invalidate_size (CLUTTER_CONTENT (self));
|
clutter_content_invalidate_size (CLUTTER_CONTENT (self));
|
||||||
}
|
}
|
||||||
@ -109,7 +110,8 @@ update_image_size (ClutterImage *self)
|
|||||||
static void
|
static void
|
||||||
clutter_image_finalize (GObject *gobject)
|
clutter_image_finalize (GObject *gobject)
|
||||||
{
|
{
|
||||||
ClutterImagePrivate *priv = CLUTTER_IMAGE (gobject)->priv;
|
ClutterImage *image = CLUTTER_IMAGE (gobject);
|
||||||
|
ClutterImagePrivate *priv = clutter_image_get_instance_private (image);
|
||||||
|
|
||||||
if (priv->texture != NULL)
|
if (priv->texture != NULL)
|
||||||
{
|
{
|
||||||
@ -129,7 +131,6 @@ clutter_image_class_init (ClutterImageClass *klass)
|
|||||||
static void
|
static void
|
||||||
clutter_image_init (ClutterImage *self)
|
clutter_image_init (ClutterImage *self)
|
||||||
{
|
{
|
||||||
self->priv = clutter_image_get_instance_private (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -138,7 +139,8 @@ clutter_image_paint_content (ClutterContent *content,
|
|||||||
ClutterPaintNode *root,
|
ClutterPaintNode *root,
|
||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterImagePrivate *priv = CLUTTER_IMAGE (content)->priv;
|
ClutterImage *image = CLUTTER_IMAGE (content);
|
||||||
|
ClutterImagePrivate *priv = clutter_image_get_instance_private (image);
|
||||||
ClutterPaintNode *node;
|
ClutterPaintNode *node;
|
||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
@ -155,7 +157,8 @@ clutter_image_get_preferred_size (ClutterContent *content,
|
|||||||
gfloat *width,
|
gfloat *width,
|
||||||
gfloat *height)
|
gfloat *height)
|
||||||
{
|
{
|
||||||
ClutterImagePrivate *priv = CLUTTER_IMAGE (content)->priv;
|
ClutterImage *image = CLUTTER_IMAGE (content);
|
||||||
|
ClutterImagePrivate *priv = clutter_image_get_instance_private (image);
|
||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -252,7 +255,7 @@ clutter_image_set_data (ClutterImage *image,
|
|||||||
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
|
||||||
priv = image->priv;
|
priv = clutter_image_get_instance_private (image);
|
||||||
|
|
||||||
if (priv->texture != NULL)
|
if (priv->texture != NULL)
|
||||||
cogl_object_unref (priv->texture);
|
cogl_object_unref (priv->texture);
|
||||||
@ -312,7 +315,7 @@ clutter_image_set_bytes (ClutterImage *image,
|
|||||||
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
|
||||||
priv = image->priv;
|
priv = clutter_image_get_instance_private (image);
|
||||||
|
|
||||||
if (priv->texture != NULL)
|
if (priv->texture != NULL)
|
||||||
cogl_object_unref (priv->texture);
|
cogl_object_unref (priv->texture);
|
||||||
@ -376,7 +379,7 @@ clutter_image_set_area (ClutterImage *image,
|
|||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
g_return_val_if_fail (area != NULL, FALSE);
|
g_return_val_if_fail (area != NULL, FALSE);
|
||||||
|
|
||||||
priv = image->priv;
|
priv = clutter_image_get_instance_private (image);
|
||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
{
|
{
|
||||||
@ -434,7 +437,10 @@ clutter_image_set_area (ClutterImage *image,
|
|||||||
CoglTexture *
|
CoglTexture *
|
||||||
clutter_image_get_texture (ClutterImage *image)
|
clutter_image_get_texture (ClutterImage *image)
|
||||||
{
|
{
|
||||||
|
ClutterImagePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), NULL);
|
||||||
|
|
||||||
return image->priv->texture;
|
priv = clutter_image_get_instance_private (image);
|
||||||
|
return priv->texture;
|
||||||
}
|
}
|
||||||
|
@ -34,33 +34,10 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_IMAGE (clutter_image_get_type ())
|
#define CLUTTER_TYPE_IMAGE (clutter_image_get_type ())
|
||||||
#define CLUTTER_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_IMAGE, ClutterImage))
|
|
||||||
#define CLUTTER_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_IMAGE))
|
|
||||||
#define CLUTTER_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_IMAGE, ClutterImageClass))
|
|
||||||
#define CLUTTER_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_IMAGE))
|
|
||||||
#define CLUTTER_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_IMAGE, ClutterImageClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterImage ClutterImage;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterImagePrivate ClutterImagePrivate;
|
G_DECLARE_DERIVABLE_TYPE (ClutterImage, clutter_image, CLUTTER, IMAGE, GObject)
|
||||||
typedef struct _ClutterImageClass ClutterImageClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClutterImage:
|
|
||||||
*
|
|
||||||
* The #ClutterImage structure contains
|
|
||||||
* private data and should only be accessed using the provided
|
|
||||||
* API.
|
|
||||||
*
|
|
||||||
* Since: 1.10
|
|
||||||
*/
|
|
||||||
struct _ClutterImage
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
ClutterImagePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterImageClass:
|
* ClutterImageClass:
|
||||||
@ -78,9 +55,6 @@ struct _ClutterImageClass
|
|||||||
gpointer _padding[16];
|
gpointer _padding[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_image_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterContent * clutter_image_new (void);
|
ClutterContent * clutter_image_new (void);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
|
Loading…
Reference in New Issue
Block a user