"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl-pango / cogl-pango-glyph-cache.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By Matthew Allum  <mallum@openedhand.com>
7  *
8  * Copyright (C) 2008 OpenedHand
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef __COGL_PANGO_GLYPH_CACHE_H__
25 #define __COGL_PANGO_GLYPH_CACHE_H__
26
27 #include <glib.h>
28 #include <cogl/cogl.h>
29 #include <pango/pango-font.h>
30
31 G_BEGIN_DECLS
32
33 typedef struct _CoglPangoGlyphCache      CoglPangoGlyphCache;
34 typedef struct _CoglPangoGlyphCacheValue CoglPangoGlyphCacheValue;
35
36 struct _CoglPangoGlyphCacheValue
37 {
38   CoglTexture *texture;
39
40   float tx1;
41   float ty1;
42   float tx2;
43   float ty2;
44
45   int tx_pixel;
46   int ty_pixel;
47
48   int draw_x;
49   int draw_y;
50   int draw_width;
51   int draw_height;
52
53   /* This will be set to TRUE when the glyph atlas is reorganized
54      which means the glyph will need to be redrawn */
55   gboolean   dirty;
56 };
57
58 typedef void (* CoglPangoGlyphCacheDirtyFunc) (PangoFont *font,
59                                                PangoGlyph glyph,
60                                                CoglPangoGlyphCacheValue *value);
61
62 CoglPangoGlyphCache *
63 cogl_pango_glyph_cache_new (gboolean use_mipmapping);
64
65 void
66 cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache);
67
68 CoglPangoGlyphCacheValue *
69 cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
70                                gboolean             create,
71                                PangoFont           *font,
72                                PangoGlyph           glyph);
73
74 void
75 cogl_pango_glyph_cache_clear (CoglPangoGlyphCache *cache);
76
77 void
78 _cogl_pango_glyph_cache_add_reorganize_callback (CoglPangoGlyphCache *cache,
79                                                  GHookFunc func,
80                                                  void *user_data);
81
82 void
83 _cogl_pango_glyph_cache_remove_reorganize_callback (CoglPangoGlyphCache *cache,
84                                                     GHookFunc func,
85                                                     void *user_data);
86
87 void
88 _cogl_pango_glyph_cache_set_dirty_glyphs (CoglPangoGlyphCache *cache,
89                                           CoglPangoGlyphCacheDirtyFunc func);
90
91 G_END_DECLS
92
93 #endif /* __COGL_PANGO_GLYPH_CACHE_H__ */