2019-05-22 05:33:45 +00:00
|
|
|
|
|
|
|
#ifndef __GSK_GL_TEXTURE_ATLAS_H__
|
|
|
|
#define __GSK_GL_TEXTURE_ATLAS_H__
|
|
|
|
|
|
|
|
#include "stb_rect_pack.h"
|
|
|
|
#include "gskglimageprivate.h"
|
|
|
|
#include "gskgldriverprivate.h"
|
|
|
|
|
|
|
|
struct _GskGLTextureAtlas
|
|
|
|
{
|
|
|
|
struct stbrp_context context;
|
|
|
|
struct stbrp_node *nodes;
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
2019-06-04 21:27:09 +00:00
|
|
|
guint texture_id;
|
2019-05-22 05:33:45 +00:00
|
|
|
|
|
|
|
int unused_pixels; /* Pixels of rects that have been used at some point,
|
|
|
|
But are now unused. */
|
|
|
|
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
typedef struct _GskGLTextureAtlas GskGLTextureAtlas;
|
|
|
|
|
2019-06-04 21:27:09 +00:00
|
|
|
struct _GskGLTextureAtlases
|
|
|
|
{
|
|
|
|
int ref_count;
|
|
|
|
|
|
|
|
GPtrArray *atlases;
|
|
|
|
};
|
|
|
|
typedef struct _GskGLTextureAtlases GskGLTextureAtlases;
|
|
|
|
|
|
|
|
GskGLTextureAtlases *gsk_gl_texture_atlases_new (void);
|
|
|
|
GskGLTextureAtlases *gsk_gl_texture_atlases_ref (GskGLTextureAtlases *atlases);
|
|
|
|
void gsk_gl_texture_atlases_unref (GskGLTextureAtlases *atlases);
|
|
|
|
|
2019-10-12 00:42:24 +00:00
|
|
|
void gsk_gl_texture_atlases_begin_frame (GskGLTextureAtlases *atlases,
|
|
|
|
GPtrArray *removed);
|
2019-06-04 21:27:09 +00:00
|
|
|
gboolean gsk_gl_texture_atlases_pack (GskGLTextureAtlases *atlases,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GskGLTextureAtlas **atlas_out,
|
|
|
|
int *out_x,
|
|
|
|
int *out_y);
|
|
|
|
|
2019-05-22 05:33:45 +00:00
|
|
|
void gsk_gl_texture_atlas_init (GskGLTextureAtlas *self,
|
|
|
|
int width,
|
|
|
|
int height);
|
|
|
|
|
|
|
|
void gsk_gl_texture_atlas_free (GskGLTextureAtlas *self);
|
|
|
|
|
2019-06-04 21:27:09 +00:00
|
|
|
void gsk_gl_texture_atlas_realize (GskGLTextureAtlas *self);
|
|
|
|
|
2019-05-22 05:33:45 +00:00
|
|
|
void gsk_gl_texture_atlas_mark_unused (GskGLTextureAtlas *self,
|
|
|
|
int width,
|
|
|
|
int height);
|
|
|
|
|
|
|
|
void gsk_gl_texture_atlas_mark_used (GskGLTextureAtlas *self,
|
|
|
|
int width,
|
|
|
|
int height);
|
|
|
|
|
|
|
|
|
|
|
|
gboolean gsk_gl_texture_atlas_pack (GskGLTextureAtlas *self,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int *out_x,
|
|
|
|
int *out_y);
|
|
|
|
|
|
|
|
double gsk_gl_texture_atlas_get_unused_ratio (const GskGLTextureAtlas *self);
|
|
|
|
|
|
|
|
#endif
|