[libgxps/wip/nacho/resources: 10/10] Add initial support for brush resources



commit 095a1139043b462aee8c91366d3838529012bff0
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Thu Jan 26 16:46:51 2017 +0100

    Add initial support for brush resources
    
    For now only the Fill tag in the Path is handled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742630

 libgxps/gxps-page.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/libgxps/gxps-page.c b/libgxps/gxps-page.c
index 914e255..5a5ffea 100644
--- a/libgxps/gxps-page.c
+++ b/libgxps/gxps-page.c
@@ -412,6 +412,12 @@ resource_start_element (GMarkupParseContext  *context,
                GXPSPath *path = (GXPSPath *)user_data;
 
                gxps_path_parser_push (context, path);
+       } else if (g_str_has_suffix (element_name, "Brush")) {
+               GXPSPath *path = (GXPSPath *)user_data;
+               GXPSBrush *brush;
+
+               brush = gxps_brush_new (path->ctx);
+               gxps_brush_parser_push (context, brush);
        }
 }
 
@@ -423,6 +429,12 @@ resource_end_element (GMarkupParseContext  *context,
 {
        if (strcmp (element_name, "Resource.PathGeometry") == 0) {
                g_markup_parse_context_pop (context);
+       } else if (g_str_has_suffix (element_name, "Brush")) {
+               GXPSPath *path = (GXPSPath *)user_data;
+               GXPSBrush *brush = g_markup_parse_context_pop (context);
+
+               path->fill_pattern = cairo_pattern_reference (brush->pattern);
+               gxps_brush_free (brush);
        }
 }
 
@@ -506,8 +518,8 @@ render_start_element (GMarkupParseContext  *context,
                        } else if (strcmp (names[i], "Clip") == 0) {
                                path->clip_data = g_strdup (values[i]);
                        } else if (strcmp (names[i], "Fill") == 0) {
-                               GXPS_DEBUG (g_message ("set_fill_pattern (solid)"));
-                                if (!gxps_brush_solid_color_parse (values[i], ctx->page->priv->zip, 1., 
&path->fill_pattern)) {
+                               if (!expand_resource (ctx->page, values[i], path) &&
+                                    !gxps_brush_solid_color_parse (values[i], ctx->page->priv->zip, 1., 
&path->fill_pattern)) {
                                        gxps_parse_error (context,
                                                          ctx->page->priv->source,
                                                          G_MARKUP_ERROR_INVALID_CONTENT,
@@ -515,6 +527,7 @@ render_start_element (GMarkupParseContext  *context,
                                        gxps_path_free (path);
                                        return;
                                }
+                               GXPS_DEBUG (g_message ("set_fill_pattern (solid)"));
                        } else if (strcmp (names[i], "Stroke") == 0) {
                                GXPS_DEBUG (g_message ("set_stroke_pattern (solid)"));
                                 if (!gxps_brush_solid_color_parse (values[i], ctx->page->priv->zip, 1., 
&path->stroke_pattern)) {


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