[gtk/wip/baedert/for-master] gskpango: Remove bounds rect
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] gskpango: Remove bounds rect
- Date: Mon, 21 Dec 2020 12:42:42 +0000 (UTC)
commit 98b99201b0704c722ccaf132b4c9294310ce4461
Author: Timm Bäder <mail baedert org>
Date: Mon Dec 21 12:56:38 2020 +0100
gskpango: Remove bounds rect
We only need this to render shapes and trapezoids, i.e. only when
falling back to cairo. Remove code to measure the layout and convert the
ink_rect to a graphene_rect_t from gtk_snapshot_append_layout() and do
it when drawing shapes and trapezoids instead.
gtk/gskpango.c | 20 ++++++++++++++------
gtk/gskpango.h | 1 -
gtk/gtktextlayout.c | 2 --
3 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index 2fa53f0624..6803f7528a 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -138,11 +138,19 @@ gsk_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
double x22)
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
+ PangoLayout *layout;
+ PangoRectangle ink_rect;
cairo_t *cr;
double x, y;
- cr = gtk_snapshot_append_cairo (crenderer->snapshot, &crenderer->bounds);
+ layout = pango_renderer_get_layout (renderer);
+ if (!layout)
+ return;
+ pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+ cr = gtk_snapshot_append_cairo (crenderer->snapshot,
+ &GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
+ ink_rect.width, ink_rect.height));
set_color (crenderer, part, cr);
x = y = 0;
@@ -263,12 +271,16 @@ gsk_pango_renderer_draw_shape (PangoRenderer *renderer,
if (!handled)
{
cairo_t *cr;
+ PangoRectangle ink_rect;
layout = pango_renderer_get_layout (renderer);
if (!layout)
return;
- cr = gtk_snapshot_append_cairo (crenderer->snapshot, &crenderer->bounds);
+ pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+ cr = gtk_snapshot_append_cairo (crenderer->snapshot,
+ &GRAPHENE_RECT_INIT (ink_rect.x, ink_rect.y,
+ ink_rect.width, ink_rect.height));
shape_renderer = pango_cairo_context_get_shape_renderer (pango_layout_get_context (layout),
&shape_renderer_data);
@@ -483,7 +495,6 @@ gtk_snapshot_append_layout (GtkSnapshot *snapshot,
const GdkRGBA *color)
{
GskPangoRenderer *crenderer;
- PangoRectangle ink_rect;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (PANGO_IS_LAYOUT (layout));
@@ -493,9 +504,6 @@ gtk_snapshot_append_layout (GtkSnapshot *snapshot,
crenderer->snapshot = snapshot;
crenderer->fg_color = *color;
- pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
- graphene_rect_init (&crenderer->bounds, ink_rect.x, ink_rect.y, ink_rect.width, ink_rect.height);
-
pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
gsk_pango_renderer_release (crenderer);
diff --git a/gtk/gskpango.h b/gtk/gskpango.h
index ab0933933c..fbd6340d7b 100644
--- a/gtk/gskpango.h
+++ b/gtk/gskpango.h
@@ -59,7 +59,6 @@ struct _GskPangoRenderer
GtkWidget *widget;
GtkSnapshot *snapshot;
GdkRGBA fg_color;
- graphene_rect_t bounds;
/* Error underline color for this widget */
GdkRGBA *error_color;
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 2bc7e5dbed..ecbd2d3a08 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -4166,8 +4166,6 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
crenderer->snapshot = snapshot;
crenderer->fg_color = color;
- graphene_rect_init (&crenderer->bounds, 0, 0, clip->width, clip->height);
-
gtk_text_layout_wrap_loop_start (layout);
have_selection = gtk_text_buffer_get_selection_bounds (layout->buffer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]