gtk/gsk/gsktextureprivate.h
Benjamin Otte 48e7f4191f gsktexture: Allow attaching render data to textures
This allows renderers (or anyone really) to attach "render data" to
textures. Only the first render data sticks.

You can gsk_texture_set_render_data() with the key you will use to
look the data up again, and if no data has been set yet, yours will be
set.

You can retrieve this data via gsk_texture_get_render_data() later on.
If your data has been cleared, NULL will be returned.

When gsk_texture_clear_render_data() is called (which the texture will
call when it is finalized), your destory notify will be called and you
have to release your render data.

The GL driver uses this to attach texture ids to GskTextures.
2016-11-16 17:36:33 +01:00

53 lines
2.0 KiB
C

#ifndef __GSK_TEXTURE_PRIVATE_H__
#define __GSK_TEXTURE_PRIVATE_H__
#include "gsktexture.h"
G_BEGIN_DECLS
#define GSK_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_TEXTURE, GskTextureClass))
#define GSK_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_TEXTURE))
#define GSK_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_TEXTURE, GskTextureClass))
typedef struct _GskTextureClass GskTextureClass;
struct _GskTexture
{
const GskTextureClass *klass;
volatile int ref_count;
int width;
int height;
gpointer render_key;
gpointer render_data;
GDestroyNotify render_notify;
};
struct _GskTextureClass {
const char *name;
gsize size;
void (* finalize) (GskTexture *texture);
cairo_surface_t * (* download) (GskTexture *texture);
};
gpointer gsk_texture_new (const GskTextureClass *klass,
int width,
int height);
GskTexture * gsk_texture_new_for_surface (cairo_surface_t *surface);
cairo_surface_t * gsk_texture_download (GskTexture *texture);
gboolean gsk_texture_set_render_data (GskTexture *self,
gpointer key,
gpointer data,
GDestroyNotify notify);
void gsk_texture_clear_render_data (GskTexture *self);
gpointer gsk_texture_get_render_data (GskTexture *self,
gpointer key);
G_END_DECLS
#endif /* __GSK_TEXTURE_PRIVATE_H__ */