2017-11-18 13:30:57 +00:00
|
|
|
#ifndef __GSK_GL_GLYPH_CACHE_PRIVATE_H__
|
|
|
|
#define __GSK_GL_GLYPH_CACHE_PRIVATE_H__
|
|
|
|
|
|
|
|
#include "gskgldriverprivate.h"
|
|
|
|
#include "gskglimageprivate.h"
|
2019-05-22 05:33:45 +00:00
|
|
|
#include "gskgltextureatlasprivate.h"
|
2017-11-18 13:30:57 +00:00
|
|
|
#include <pango/pango.h>
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-06-04 21:27:09 +00:00
|
|
|
int ref_count;
|
|
|
|
|
|
|
|
GdkDisplay *display;
|
2017-11-18 13:30:57 +00:00
|
|
|
GHashTable *hash_table;
|
2019-06-04 21:27:09 +00:00
|
|
|
GskGLTextureAtlases *atlases;
|
2017-11-18 13:30:57 +00:00
|
|
|
|
2019-10-12 15:03:04 +00:00
|
|
|
int timestamp;
|
2017-11-18 13:30:57 +00:00
|
|
|
} GskGLGlyphCache;
|
|
|
|
|
2019-10-13 00:09:14 +00:00
|
|
|
struct _CacheKeyData
|
2019-01-06 14:35:54 +00:00
|
|
|
{
|
|
|
|
PangoFont *font;
|
|
|
|
PangoGlyph glyph;
|
2019-10-10 01:49:43 +00:00
|
|
|
guint xshift : 3;
|
|
|
|
guint yshift : 3;
|
|
|
|
guint scale : 26; /* times 1024 */
|
2019-10-13 00:09:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _CacheKeyData CacheKeyData;
|
|
|
|
|
|
|
|
struct _GlyphCacheKey
|
|
|
|
{
|
|
|
|
CacheKeyData data;
|
2019-10-10 01:49:43 +00:00
|
|
|
guint hash;
|
2019-10-13 00:09:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GlyphCacheKey GlyphCacheKey;
|
2019-01-06 14:35:54 +00:00
|
|
|
|
2019-10-10 01:49:43 +00:00
|
|
|
#define PHASE(x) ((int)(floor (4 * (x + 0.125)) - 4 * floor (x + 0.125)))
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
glyph_cache_key_set_glyph_and_shift (GlyphCacheKey *key,
|
|
|
|
PangoGlyph glyph,
|
|
|
|
float x,
|
|
|
|
float y)
|
|
|
|
{
|
2019-10-13 00:09:14 +00:00
|
|
|
key->data.glyph = glyph;
|
|
|
|
key->data.xshift = PHASE (x);
|
|
|
|
key->data.yshift = PHASE (y);
|
|
|
|
key->hash = GPOINTER_TO_UINT (key->data.font) ^
|
|
|
|
key->data.glyph ^
|
|
|
|
(key->data.xshift << 24) ^
|
|
|
|
(key->data.yshift << 26) ^
|
|
|
|
key->data.scale;
|
2019-10-10 01:49:43 +00:00
|
|
|
}
|
|
|
|
|
2019-01-06 14:35:54 +00:00
|
|
|
typedef struct _GskGLCachedGlyph GskGLCachedGlyph;
|
|
|
|
|
|
|
|
struct _GskGLCachedGlyph
|
2017-11-18 13:30:57 +00:00
|
|
|
{
|
2019-05-22 05:33:45 +00:00
|
|
|
GskGLTextureAtlas *atlas;
|
2019-06-04 21:27:09 +00:00
|
|
|
guint texture_id;
|
2017-11-18 13:30:57 +00:00
|
|
|
|
|
|
|
float tx;
|
|
|
|
float ty;
|
|
|
|
float tw;
|
|
|
|
float th;
|
|
|
|
|
|
|
|
int draw_x;
|
|
|
|
int draw_y;
|
|
|
|
int draw_width;
|
|
|
|
int draw_height;
|
|
|
|
|
2019-10-12 15:03:04 +00:00
|
|
|
guint accessed : 1; /* accessed since last check */
|
|
|
|
guint used : 1; /* accounted as used in the atlas */
|
2019-01-06 14:35:54 +00:00
|
|
|
};
|
|
|
|
|
2017-11-18 13:30:57 +00:00
|
|
|
|
2019-06-04 21:27:09 +00:00
|
|
|
GskGLGlyphCache * gsk_gl_glyph_cache_new (GdkDisplay *display,
|
|
|
|
GskGLTextureAtlases *atlases);
|
|
|
|
GskGLGlyphCache * gsk_gl_glyph_cache_ref (GskGLGlyphCache *self);
|
|
|
|
void gsk_gl_glyph_cache_unref (GskGLGlyphCache *self);
|
2019-10-12 00:42:24 +00:00
|
|
|
void gsk_gl_glyph_cache_begin_frame (GskGLGlyphCache *self,
|
2019-10-12 22:26:09 +00:00
|
|
|
GskGLDriver *driver,
|
2019-10-12 00:42:24 +00:00
|
|
|
GPtrArray *removed_atlases);
|
2019-10-12 05:35:13 +00:00
|
|
|
void gsk_gl_glyph_cache_lookup_or_add (GskGLGlyphCache *self,
|
2019-10-10 01:49:43 +00:00
|
|
|
GlyphCacheKey *lookup,
|
2019-07-28 09:57:43 +00:00
|
|
|
GskGLDriver *driver,
|
2019-10-09 21:27:48 +00:00
|
|
|
const GskGLCachedGlyph **cached_glyph_out);
|
2017-11-18 13:30:57 +00:00
|
|
|
|
|
|
|
#endif
|