summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-05-19 04:08:29 +0200
committerBenjamin Otte <otte@redhat.com>2019-05-21 06:43:59 +0200
commita1d08b4b52615bd1408976b5503c1bbe7e2c5bd9 (patch)
tree035ec6b4b84c82703a26ba37aaa380e2f1d696e5 /gsk
parent0fd0be4f9a51af7c0ab0a0a007287e538d755c35 (diff)
downloadgtk+-a1d08b4b52615bd1408976b5503c1bbe7e2c5bd9.tar.gz
rendernode: Take a graphene_point_t for the offset
... instead of 2 floats.
Diffstat (limited to 'gsk')
-rw-r--r--gsk/gl/gskglrenderer.c5
-rw-r--r--gsk/gskrendernode.h7
-rw-r--r--gsk/gskrendernodeimpl.c45
-rw-r--r--gsk/gskrendernodeparser.c14
-rw-r--r--gsk/vulkan/gskvulkancolortextpipeline.c7
-rw-r--r--gsk/vulkan/gskvulkancolortextpipelineprivate.h3
-rw-r--r--gsk/vulkan/gskvulkanrenderpass.c6
-rw-r--r--gsk/vulkan/gskvulkantextpipeline.c7
-rw-r--r--gsk/vulkan/gskvulkantextpipelineprivate.h3
9 files changed, 36 insertions, 61 deletions
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 3a57fb1eef..99e1cacfbe 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -527,8 +527,9 @@ render_text_node (GskGLRenderer *self,
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
int i;
int x_position = 0;
- float x = gsk_text_node_get_x (node) + builder->dx;
- float y = gsk_text_node_get_y (node) + builder->dy;
+ const graphene_point_t *offset = gsk_text_node_get_offset (node);
+ float x = offset->x + builder->dx;
+ float y = offset->y + builder->dy;
/* If the font has color glyphs, we don't need to recolor anything */
if (!force_color && font_has_color_glyphs (font))
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index b1ae30785e..1c82f2cf13 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -292,8 +292,7 @@ GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_text_node_new (PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
- float x,
- float y);
+ const graphene_point_t *offset);
GDK_AVAILABLE_IN_ALL
const PangoFont * gsk_text_node_peek_font (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
@@ -303,9 +302,7 @@ const PangoGlyphInfo *gsk_text_node_peek_glyphs (GskRenderNode
GDK_AVAILABLE_IN_ALL
const GdkRGBA * gsk_text_node_peek_color (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
-float gsk_text_node_get_x (GskRenderNode *node);
-GDK_AVAILABLE_IN_ALL
-float gsk_text_node_get_y (GskRenderNode *node);
+const graphene_point_t *gsk_text_node_get_offset (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index a5f0c03c73..a2082dc326 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -3429,8 +3429,7 @@ struct _GskTextNode
PangoFont *font;
GdkRGBA color;
- double x;
- double y;
+ graphene_point_t offset;
guint num_glyphs;
PangoGlyphInfo glyphs[];
@@ -3464,7 +3463,7 @@ gsk_text_node_draw (GskRenderNode *node,
cairo_save (cr);
gdk_cairo_set_source_rgba (cr, &self->color);
- cairo_translate (cr, self->x, self->y);
+ cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
cairo_restore (cr);
@@ -3480,8 +3479,7 @@ gsk_text_node_diff (GskRenderNode *node1,
if (self1->font == self2->font &&
gdk_rgba_equal (&self1->color, &self2->color) &&
- self1->x == self2->x &&
- self1->y == self2->y &&
+ graphene_point_equal (&self1->offset, &self2->offset) &&
self1->num_glyphs == self2->num_glyphs)
{
guint i;
@@ -3523,8 +3521,7 @@ static const GskRenderNodeClass GSK_TEXT_NODE_CLASS = {
* @font: the #PangoFont containing the glyphs
* @glyphs: the #PangoGlyphString to render
* @color: the foreground color to render with
- * @x: the x coordinate at which to put the baseline
- * @y: the y coordinate at wihch to put the baseline
+ * @offset: offset of the baseline
*
* Creates a render node that renders the given glyphs,
* Note that @color may not be used if the font contains
@@ -3533,11 +3530,10 @@ static const GskRenderNodeClass GSK_TEXT_NODE_CLASS = {
* Returns: (nullable): a new text node, or %NULL
*/
GskRenderNode *
-gsk_text_node_new (PangoFont *font,
- PangoGlyphString *glyphs,
- const GdkRGBA *color,
- float x,
- float y)
+gsk_text_node_new (PangoFont *font,
+ PangoGlyphString *glyphs,
+ const GdkRGBA *color,
+ const graphene_point_t *offset)
{
GskTextNode *self;
PangoRectangle ink_rect;
@@ -3553,14 +3549,13 @@ gsk_text_node_new (PangoFont *font,
self->font = g_object_ref (font);
self->color = *color;
- self->x = x;
- self->y = y;
+ self->offset = *offset;
self->num_glyphs = glyphs->num_glyphs;
memcpy (self->glyphs, glyphs->glyphs, sizeof (PangoGlyphInfo) * glyphs->num_glyphs);
graphene_rect_init (&self->render_node.bounds,
- x + ink_rect.x - 1,
- y + ink_rect.y - 1,
+ offset->x + ink_rect.x - 1,
+ offset->y + ink_rect.y - 1,
ink_rect.width + 2,
ink_rect.height + 2);
@@ -3607,24 +3602,14 @@ gsk_text_node_peek_glyphs (GskRenderNode *node)
return self->glyphs;
}
-float
-gsk_text_node_get_x (GskRenderNode *node)
-{
- GskTextNode *self = (GskTextNode *) node;
-
- g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), 0.0);
-
- return (float)self->x;
-}
-
-float
-gsk_text_node_get_y (GskRenderNode *node)
+const graphene_point_t *
+gsk_text_node_get_offset (GskRenderNode *node)
{
GskTextNode *self = (GskTextNode *) node;
- g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), 0.0);
+ g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TEXT_NODE), NULL);
- return (float)self->y;
+ return &self->offset;
}
/*** GSK_BLUR_NODE ***/
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c
index b9603b235e..07e55fd7a2 100644
--- a/gsk/gskrendernodeparser.c
+++ b/gsk/gskrendernodeparser.c
@@ -1004,14 +1004,12 @@ static GskRenderNode *
parse_text_node (GtkCssParser *parser)
{
PangoFont *font = NULL;
- double x = 0;
- double y = 0;
+ graphene_point_t offset = GRAPHENE_POINT_INIT (0, 0);
GdkRGBA color = { 0, 0, 0, 1 };
PangoGlyphString *glyphs = NULL;
const Declaration declarations[] = {
{ "font", parse_font, clear_font, &font },
- { "x", parse_double, NULL, &x },
- { "y", parse_double, NULL, &y },
+ { "offset", parse_point, NULL, &offset },
{ "color", parse_color, NULL, &color },
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs }
};
@@ -1022,7 +1020,7 @@ parse_text_node (GtkCssParser *parser)
if (!font || !glyphs)
return NULL;
- result = gsk_text_node_new (font, glyphs, &color, x, y);
+ result = gsk_text_node_new (font, glyphs, &color, &offset);
g_object_unref (font);
pango_glyph_string_free (glyphs);
@@ -1855,6 +1853,7 @@ render_node_print (Printer *p,
{
const guint n_glyphs = gsk_text_node_get_num_glyphs (node);
const PangoGlyphInfo *glyph;
+ const graphene_point_t *offset = gsk_text_node_get_offset (node);
PangoFontDescription *desc;
char *font_name;
guint i;
@@ -1887,9 +1886,8 @@ render_node_print (Printer *p,
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
- append_float_param (p, "x", gsk_text_node_get_x (node));
- append_float_param (p, "y", gsk_text_node_get_y (node));
-
+ if (!graphene_point_equal (offset, graphene_point_zero ()))
+ append_point_param (p, "offset", offset);
end_node (p);
}
diff --git a/gsk/vulkan/gskvulkancolortextpipeline.c b/gsk/vulkan/gskvulkancolortextpipeline.c
index 9770b27938..a7b0ad39a7 100644
--- a/gsk/vulkan/gskvulkancolortextpipeline.c
+++ b/gsk/vulkan/gskvulkancolortextpipeline.c
@@ -100,8 +100,7 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
- float x,
- float y,
+ const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale)
@@ -132,8 +131,8 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
instance->tex_rect[2] = glyph->tw;
instance->tex_rect[3] = glyph->th;
- instance->rect[0] = x + cx + glyph->draw_x;
- instance->rect[1] = y + cy + glyph->draw_y;
+ instance->rect[0] = offset->x + cx + glyph->draw_x;
+ instance->rect[1] = offset->y + cy + glyph->draw_y;
instance->rect[2] = glyph->draw_width;
instance->rect[3] = glyph->draw_height;
diff --git a/gsk/vulkan/gskvulkancolortextpipelineprivate.h b/gsk/vulkan/gskvulkancolortextpipelineprivate.h
index 2e46b1c6a8..a549c25fcd 100644
--- a/gsk/vulkan/gskvulkancolortextpipelineprivate.h
+++ b/gsk/vulkan/gskvulkancolortextpipelineprivate.h
@@ -28,8 +28,7 @@ void gsk_vulkan_color_text_pipeline_collect_vertex_data (Gs
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
- float x,
- float y,
+ const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale);
diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c
index fedd07a832..55f96456a8 100644
--- a/gsk/vulkan/gskvulkanrenderpass.c
+++ b/gsk/vulkan/gskvulkanrenderpass.c
@@ -1206,8 +1206,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
gsk_text_node_get_num_glyphs (op->text.node),
gsk_text_node_peek_glyphs (op->text.node),
gsk_text_node_peek_color (op->text.node),
- gsk_text_node_get_x (op->text.node),
- gsk_text_node_get_y (op->text.node),
+ gsk_text_node_get_offset (op->text.node),
op->text.start_glyph,
op->text.num_glyphs,
op->text.scale);
@@ -1225,8 +1224,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
(PangoFont *)gsk_text_node_peek_font (op->text.node),
gsk_text_node_get_num_glyphs (op->text.node),
gsk_text_node_peek_glyphs (op->text.node),
- gsk_text_node_get_x (op->text.node),
- gsk_text_node_get_y (op->text.node),
+ gsk_text_node_get_offset (op->text.node),
op->text.start_glyph,
op->text.num_glyphs,
op->text.scale);
diff --git a/gsk/vulkan/gskvulkantextpipeline.c b/gsk/vulkan/gskvulkantextpipeline.c
index 361c53675d..7cd85c5d9a 100644
--- a/gsk/vulkan/gskvulkantextpipeline.c
+++ b/gsk/vulkan/gskvulkantextpipeline.c
@@ -108,8 +108,7 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
const GdkRGBA *color,
- float x,
- float y,
+ const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale)
@@ -140,8 +139,8 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
instance->tex_rect[2] = glyph->tw;
instance->tex_rect[3] = glyph->th;
- instance->rect[0] = x + cx + glyph->draw_x;
- instance->rect[1] = y + cy + glyph->draw_y;
+ instance->rect[0] = offset->x + cx + glyph->draw_x;
+ instance->rect[1] = offset->y + cy + glyph->draw_y;
instance->rect[2] = glyph->draw_width;
instance->rect[3] = glyph->draw_height;
diff --git a/gsk/vulkan/gskvulkantextpipelineprivate.h b/gsk/vulkan/gskvulkantextpipelineprivate.h
index 47517de03c..c186c4d983 100644
--- a/gsk/vulkan/gskvulkantextpipelineprivate.h
+++ b/gsk/vulkan/gskvulkantextpipelineprivate.h
@@ -29,8 +29,7 @@ void gsk_vulkan_text_pipeline_collect_vertex_data (GskVulka
guint total_glyphs,
const PangoGlyphInfo *glyphs,
const GdkRGBA *color,
- float x,
- float y,
+ const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale);