mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
cogl-pango: Cache whether glyphs are backed up by a color font
This will be necessary later on. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1148
This commit is contained in:
parent
d4c070da88
commit
40fb06ca17
@ -81,6 +81,7 @@ struct _CoglPangoDisplayListNode
|
|||||||
GArray *rectangles;
|
GArray *rectangles;
|
||||||
/* A primitive representing those vertices */
|
/* A primitive representing those vertices */
|
||||||
CoglPrimitive *primitive;
|
CoglPrimitive *primitive;
|
||||||
|
guint has_color : 1;
|
||||||
} texture;
|
} texture;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -58,7 +58,9 @@ struct _CoglPangoGlyphCacheValue
|
|||||||
|
|
||||||
/* This will be set to TRUE when the glyph atlas is reorganized
|
/* This will be set to TRUE when the glyph atlas is reorganized
|
||||||
which means the glyph will need to be redrawn */
|
which means the glyph will need to be redrawn */
|
||||||
gboolean dirty;
|
guint dirty : 1;
|
||||||
|
/* Set to TRUE if the glyph has colors (eg. emoji) */
|
||||||
|
guint has_color : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (* CoglPangoGlyphCacheDirtyFunc) (PangoFont *font,
|
typedef void (* CoglPangoGlyphCacheDirtyFunc) (PangoFont *font,
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
#include <pango/pango-renderer.h>
|
#include <pango/pango-renderer.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
#include <cairo-ft.h>
|
||||||
|
|
||||||
#include "cogl/cogl-debug.h"
|
#include "cogl/cogl-debug.h"
|
||||||
#include "cogl/cogl-context-private.h"
|
#include "cogl/cogl-context-private.h"
|
||||||
@ -526,6 +527,24 @@ cogl_pango_renderer_get_cached_glyph (PangoRenderer *renderer,
|
|||||||
create, font, glyph);
|
create, font, glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
font_has_color_glyphs (const PangoFont *font)
|
||||||
|
{
|
||||||
|
cairo_scaled_font_t *scaled_font;
|
||||||
|
gboolean has_color = FALSE;
|
||||||
|
|
||||||
|
scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *) font);
|
||||||
|
|
||||||
|
if (cairo_scaled_font_get_type (scaled_font) == CAIRO_FONT_TYPE_FT)
|
||||||
|
{
|
||||||
|
FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
|
||||||
|
has_color = (FT_HAS_COLOR (ft_face) != 0);
|
||||||
|
cairo_ft_scaled_font_unlock_face (scaled_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
return has_color;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
||||||
PangoGlyph glyph,
|
PangoGlyph glyph,
|
||||||
@ -600,6 +619,8 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
|||||||
cairo_image_surface_get_data (surface));
|
cairo_image_surface_get_data (surface));
|
||||||
|
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
value->has_color = font_has_color_glyphs (font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user