[gtk/glyphcache-fiddling: 6/6] gsk: Store color bit info in text nodes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/glyphcache-fiddling: 6/6] gsk: Store color bit info in text nodes
- Date: Thu, 10 Oct 2019 11:39:12 +0000 (UTC)
commit 6ac80738e775ef4dde9abcc8f924f81bdfa62198
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 10 07:31:08 2019 -0400
gsk: Store color bit info in text nodes
Keep the 'has color glyphs' info in text nodes,
instead of determining it over and over in both
the vulkan and gl backends.
gsk/gl/gskglrenderer.c | 20 +-------------------
gsk/gskrendernode.h | 1 +
gsk/gskrendernodeimpl.c | 30 ++++++++++++++++++++++++++++++
gsk/vulkan/gskvulkanrenderpass.c | 22 ++--------------------
4 files changed, 34 insertions(+), 39 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 7b84ae1b6c..307228cc12 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -25,7 +25,6 @@
#include "gdk/gdkprofilerprivate.h"
#include <epoxy/gl.h>
-#include <cairo-ft.h>
#define SHADER_VERSION_GLES 100
#define SHADER_VERSION_GL2_LEGACY 110
@@ -190,23 +189,6 @@ dump_node (GskRenderNode *node,
cairo_surface_destroy (surface);
}
-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 inline void
rgba_to_float (const GdkRGBA *c,
float *f)
@@ -570,7 +552,7 @@ render_text_node (GskGLRenderer *self,
GlyphCacheKey lookup;
/* If the font has color glyphs, we don't need to recolor anything */
- if (!force_color && font_has_color_glyphs (font))
+ if (!force_color && gsk_text_node_has_color_glyphs (node))
{
ops_set_program (builder, &self->blit_program);
}
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 79f0c6a059..876905ebc2 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -295,6 +295,7 @@ GskRenderNode * gsk_text_node_new (PangoFont
const graphene_point_t *offset);
GDK_AVAILABLE_IN_ALL
PangoFont * gsk_text_node_peek_font (GskRenderNode *node);
+gboolean gsk_text_node_has_color_glyphs (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
guint gsk_text_node_get_num_glyphs (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 8878ca3bd9..8c7be01555 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -28,6 +28,7 @@
#include "gsktransformprivate.h"
#include "gdk/gdktextureprivate.h"
+#include <cairo-ft.h>
static void
rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
@@ -3408,6 +3409,7 @@ struct _GskTextNode
GskRenderNode render_node;
PangoFont *font;
+ gboolean has_color_glyphs;
GdkRGBA color;
graphene_point_t offset;
@@ -3491,6 +3493,23 @@ static const GskRenderNodeClass GSK_TEXT_NODE_CLASS = {
gsk_text_node_diff,
};
+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;
+}
+
/**
* gsk_text_node_new:
* @font: the #PangoFont containing the glyphs
@@ -3523,6 +3542,7 @@ gsk_text_node_new (PangoFont *font,
self = (GskTextNode *) gsk_render_node_new (&GSK_TEXT_NODE_CLASS, sizeof (PangoGlyphInfo) *
glyphs->num_glyphs);
self->font = g_object_ref (font);
+ self->has_color_glyphs = font_has_color_glyphs (font);
self->color = *color;
self->offset = *offset;
self->num_glyphs = glyphs->num_glyphs;
@@ -3565,6 +3585,16 @@ gsk_text_node_peek_font (GskRenderNode *node)
return self->font;
}
+gboolean
+gsk_text_node_has_color_glyphs (GskRenderNode *node)
+{
+ GskTextNode *self = (GskTextNode *) node;
+
+ g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), FALSE);
+
+ return self->has_color_glyphs;
+}
+
guint
gsk_text_node_get_num_glyphs (GskRenderNode *node)
{
diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c
index 414d8b55d4..fb19d8d04d 100644
--- a/gsk/vulkan/gskvulkanrenderpass.c
+++ b/gsk/vulkan/gskvulkanrenderpass.c
@@ -26,8 +26,6 @@
#include "gskvulkanrendererprivate.h"
#include "gskprivate.h"
-#include <cairo-ft.h>
-
#define ORTHO_NEAR_PLANE -10000
#define ORTHO_FAR_PLANE 10000
@@ -236,23 +234,6 @@ gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
g_slice_free (GskVulkanRenderPass, self);
}
-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;
-}
-
#define FALLBACK(...) G_STMT_START { \
GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, g_message (__VA_ARGS__)); \
goto fallback; \
@@ -367,13 +348,14 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
const PangoFont *font = gsk_text_node_peek_font (node);
const PangoGlyphInfo *glyphs = gsk_text_node_peek_glyphs (node);
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
+ gboolean has_color_glyphs = gsk_text_node_has_color_glyphs (node);
int i;
guint count;
guint texture_index;
gint x_position;
GskVulkanRenderer *renderer = GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render));
- if (font_has_color_glyphs (font))
+ if (has_color_glyphs)
{
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_TEXT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]