[mutter/wip/carlosg/pango-renderer-color-glyphs: 1/2] cogl-pango: Cache whether glyphs are backed up by a color font
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/pango-renderer-color-glyphs: 1/2] cogl-pango: Cache whether glyphs are backed up by a color font
- Date: Tue, 24 Mar 2020 23:53:24 +0000 (UTC)
commit a2d2c01a09aa16867529994a5da937cdd0590970
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Mar 25 00:28:30 2020 +0100
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
cogl/cogl-pango/cogl-pango-display-list.c | 1 +
cogl/cogl-pango/cogl-pango-glyph-cache.h | 4 +++-
cogl/cogl-pango/cogl-pango-render.c | 21 +++++++++++++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/cogl/cogl-pango/cogl-pango-display-list.c b/cogl/cogl-pango/cogl-pango-display-list.c
index 8615402b9..e4bb1275d 100644
--- a/cogl/cogl-pango/cogl-pango-display-list.c
+++ b/cogl/cogl-pango/cogl-pango-display-list.c
@@ -81,6 +81,7 @@ struct _CoglPangoDisplayListNode
GArray *rectangles;
/* A primitive representing those vertices */
CoglPrimitive *primitive;
+ guint has_color : 1;
} texture;
struct
diff --git a/cogl/cogl-pango/cogl-pango-glyph-cache.h b/cogl/cogl-pango/cogl-pango-glyph-cache.h
index ec0616acc..0e523184d 100644
--- a/cogl/cogl-pango/cogl-pango-glyph-cache.h
+++ b/cogl/cogl-pango/cogl-pango-glyph-cache.h
@@ -58,7 +58,9 @@ struct _CoglPangoGlyphCacheValue
/* This will be set to TRUE when the glyph atlas is reorganized
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,
diff --git a/cogl/cogl-pango/cogl-pango-render.c b/cogl/cogl-pango/cogl-pango-render.c
index dedc0433f..d1ef39cb0 100644
--- a/cogl/cogl-pango/cogl-pango-render.c
+++ b/cogl/cogl-pango/cogl-pango-render.c
@@ -50,6 +50,7 @@
#include <pango/pangocairo.h>
#include <pango/pango-renderer.h>
#include <cairo.h>
+#include <cairo-ft.h>
#include "cogl/cogl-debug.h"
#include "cogl/cogl-context-private.h"
@@ -526,6 +527,24 @@ cogl_pango_renderer_get_cached_glyph (PangoRenderer *renderer,
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
cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
PangoGlyph glyph,
@@ -600,6 +619,8 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
cairo_image_surface_get_data (surface));
cairo_surface_destroy (surface);
+
+ value->has_color = font_has_color_glyphs (font);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]