[gtk/path-work-rebased: 60/71] gtk-demo: Use gsk_path_builder_add_layout




commit 2430c55228974eb296bacfa4fd928a7d2b563628
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 27 01:00:29 2020 -0500

    gtk-demo: Use gsk_path_builder_add_layout
    
    We have an api now to hide the cairo use.

 demos/gtk-demo/path_fill.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/demos/gtk-demo/path_fill.c b/demos/gtk-demo/path_fill.c
index 6c14ce976d..b8b4f04291 100644
--- a/demos/gtk-demo/path_fill.c
+++ b/demos/gtk-demo/path_fill.c
@@ -189,31 +189,20 @@ create_hexagon (GtkWidget *widget)
 static GskPath *
 create_path_from_text (GtkWidget *widget)
 {
-  cairo_surface_t *surface;
-  cairo_t *cr;
-  cairo_path_t *path;
   PangoLayout *layout;
   PangoFontDescription *desc;
-  GskPath *result;
-
-  surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
-  cr = cairo_create (surface);
+  GskPathBuilder *builder;
 
   layout = gtk_widget_create_pango_layout (widget, "Pango power!\nPango power!\nPango power!");
   desc = pango_font_description_from_string ("sans bold 36");
   pango_layout_set_font_description (layout, desc);
   pango_font_description_free (desc);
 
-  pango_cairo_layout_path (cr, layout);
-  path = cairo_copy_path_flat (cr);
-  result = gsk_path_new_from_cairo (path);
+  builder = gsk_path_builder_new ();
 
-  cairo_path_destroy (path);
-  g_object_unref (layout);
-  cairo_destroy (cr);
-  cairo_surface_destroy (surface);
+  gsk_path_builder_add_layout (builder, layout);
 
-  return result;
+  return gsk_path_builder_free_to_path (builder);
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]