[lasem] debug: new way to debug intermediate surfaces (mask, filter and pattern).
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] debug: new way to debug intermediate surfaces (mask, filter and pattern).
- Date: Thu, 11 Oct 2012 19:59:32 +0000 (UTC)
commit 5c6b16894946c3bfa70f282694593b35d17d5e18
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu Oct 11 21:58:54 2012 +0200
debug: new way to debug intermediate surfaces (mask, filter and pattern).
docs/reference/lasem/lasem-sections.txt | 1 +
src/lsmdomview.c | 23 +++++++++++++++++++++++
src/lsmdomview.h | 9 ++++++---
src/lsmsvgview.c | 29 ++++++++++++++++++++++-------
src/lsmsvgview.h | 4 ++++
tests/lsmtest.c | 16 ++++++++++++++++
6 files changed, 72 insertions(+), 10 deletions(-)
---
diff --git a/docs/reference/lasem/lasem-sections.txt b/docs/reference/lasem/lasem-sections.txt
index 50cd032..c86915e 100644
--- a/docs/reference/lasem/lasem-sections.txt
+++ b/docs/reference/lasem/lasem-sections.txt
@@ -176,6 +176,7 @@ lsm_dom_view_set_viewport_pixels
lsm_dom_view_render
lsm_dom_view_get_size
lsm_dom_view_get_size_pixels
+lsm_dom_view_set_debug
<SUBSECTION Standard>
LsmDomViewClass
LSM_DOM_VIEW
diff --git a/src/lsmdomview.c b/src/lsmdomview.c
index f11bd98..c85708e 100644
--- a/src/lsmdomview.c
+++ b/src/lsmdomview.c
@@ -324,6 +324,29 @@ lsm_dom_view_set_document (LsmDomView *view, LsmDomDocument *document)
view->document = document;
}
+/**
+ * lsm_dom_view_set_debug:
+ * @view: a #LsmDomView
+ * @feature: name of the feature to debug
+ * @enable: wether to enable debugging
+ *
+ * Configure feature debug.
+ */
+
+void
+lsm_dom_view_set_debug (LsmDomView *view, const char *feature, gboolean enable)
+{
+ LsmDomViewClass *view_class;
+
+ g_return_if_fail (LSM_IS_DOM_VIEW (view));
+ g_return_if_fail (feature != NULL);
+
+
+ view_class = LSM_DOM_VIEW_GET_CLASS (view);
+ if (view_class->set_debug)
+ view_class->set_debug (view, feature, enable);
+}
+
static void
lsm_dom_view_init (LsmDomView *view)
{
diff --git a/src/lsmdomview.h b/src/lsmdomview.h
index d869f6a..f89a8ef 100644
--- a/src/lsmdomview.h
+++ b/src/lsmdomview.h
@@ -47,7 +47,7 @@ typedef struct _LsmDomViewClass LsmDomViewClass;
struct _LsmDomView {
GObject object;
- LsmDomDocument * document;
+ LsmDomDocument * document;
PangoFontDescription * font_description;
PangoLayout * pango_layout;
@@ -64,8 +64,9 @@ struct _LsmDomViewClass {
GType document_type;
- void (*measure) (LsmDomView *view, double *width, double *height, double *baseline);
- void (*render) (LsmDomView *view);
+ void (*measure) (LsmDomView *view, double *width, double *height, double *baseline);
+ void (*render) (LsmDomView *view);
+ void (*set_debug) (LsmDomView *view, const char *feature, gboolean enable);
};
GType lsm_dom_view_get_type (void);
@@ -84,6 +85,8 @@ void lsm_dom_view_get_size (LsmDomView *view, double *width, double *height, d
void lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned int *height,
unsigned int *baseline);
+void lsm_dom_view_set_debug (LsmDomView *view, const char *feature, gboolean enable);
+
void lsm_dom_view_set_document (LsmDomView *view, LsmDomDocument *document);
G_END_DECLS
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index e45af44..87e7ad2 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -808,15 +808,13 @@ _paint_url (LsmSvgView *view,
cairo = view->pattern_data->old_cairo;
if (view->pattern_data->pattern) {
-#if 0
- if (LSM_IS_SVG_PATTERN_ELEMENT (element)) {
+ if (view->debug_pattern && view->dom_view.cairo) {
char *filename;
- filename = g_strdup_printf ("pattern-%s.png", url);
+ filename = g_strdup_printf ("pattern-%s).png", url);
cairo_surface_write_to_png (cairo_get_target (view->dom_view.cairo), filename);
g_free (filename);
}
-#endif
cairo_set_source (cairo, view->pattern_data->pattern);
} else
@@ -1891,15 +1889,15 @@ lsm_svg_view_pop_mask (LsmSvgView *view)
}
cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_NONE);
-#if 0
- {
+
+ if (view->debug_mask && view->dom_view.cairo != NULL) {
char *filename;
filename = g_strdup_printf ("mask-%s.png", view->style->mask->value);
cairo_surface_write_to_png (cairo_get_target (view->dom_view.cairo), filename);
g_free (filename);
}
-#endif
+
cairo_mask (cairo, view->pattern_data->pattern);
} else {
cairo_paint (cairo);
@@ -2211,6 +2209,19 @@ lsm_svg_view_render (LsmDomView *view)
}
}
+static void
+lsm_svg_view_set_debug (LsmDomView *view, const char *feature, gboolean enable)
+{
+ LsmSvgView *svg_view = LSM_SVG_VIEW (view);
+
+ if (g_strcmp0 (feature, "filter") == 0)
+ svg_view->debug_filter = enable;
+ else if (g_strcmp0 (feature, "mask") == 0)
+ svg_view->debug_mask = enable;
+ else if (g_strcmp0 (feature, "pattern") == 0)
+ svg_view->debug_pattern = enable;
+}
+
LsmSvgView *
lsm_svg_view_new (LsmSvgDocument *document)
{
@@ -2226,6 +2237,9 @@ lsm_svg_view_new (LsmSvgDocument *document)
static void
lsm_svg_view_init (LsmSvgView *view)
{
+ view->debug_mask = FALSE;
+ view->debug_filter = FALSE;
+ view->debug_pattern = FALSE;
}
static void
@@ -2246,6 +2260,7 @@ lsm_svg_view_class_init (LsmSvgViewClass *view_class)
d_view_class->measure = lsm_svg_view_measure;
d_view_class->render = lsm_svg_view_render;
+ d_view_class->set_debug = lsm_svg_view_set_debug;
}
G_DEFINE_TYPE (LsmSvgView, lsm_svg_view, LSM_TYPE_DOM_VIEW)
diff --git a/src/lsmsvgview.h b/src/lsmsvgview.h
index 37e7091..20e20d5 100644
--- a/src/lsmsvgview.h
+++ b/src/lsmsvgview.h
@@ -74,6 +74,10 @@ struct _LsmSvgView {
double last_stop_offset;
GSList *filter_surfaces;
+
+ gboolean debug_filter;
+ gboolean debug_mask;
+ gboolean debug_pattern;
};
struct _LsmSvgViewClass {
diff --git a/tests/lsmtest.c b/tests/lsmtest.c
index dc473b4..d48a610 100644
--- a/tests/lsmtest.c
+++ b/tests/lsmtest.c
@@ -45,6 +45,9 @@ static char *option_debug_domains = NULL;
static char **option_input_filenames = NULL;
double option_ppi = 72.0;
static gboolean fatal_warning = FALSE;
+static gboolean debug_filter = FALSE;
+static gboolean debug_pattern = FALSE;
+static gboolean debug_mask = FALSE;
static const GOptionEntry entries[] =
{
@@ -56,6 +59,12 @@ static const GOptionEntry entries[] =
&option_debug_domains, "Debug domains", NULL },
{ "fatal-warning", 'f', 0, G_OPTION_ARG_NONE,
&fatal_warning, "Make warning fatal", NULL },
+ { "debug-filter", ' ' , 0, G_OPTION_ARG_NONE,
+ &debug_filter, "Debug filter surfaces", NULL },
+ { "debug-pattern", ' ' , 0, G_OPTION_ARG_NONE,
+ &debug_pattern, "Debug pattern surfaces", NULL },
+ { "debug-mask", ' ' , 0, G_OPTION_ARG_NONE,
+ &debug_mask, "Debug mask surfaces", NULL },
{ NULL }
};
@@ -137,6 +146,13 @@ lasem_test_render (char const *filename)
lsm_dom_view_set_viewport_pixels (view, &viewport);
lsm_dom_view_get_size_pixels (LSM_DOM_VIEW (view), &width, &height, NULL);
+ if (debug_mask)
+ lsm_dom_view_set_debug (view, "mask", TRUE);
+ if (debug_pattern)
+ lsm_dom_view_set_debug (view, "pattern", TRUE);
+ if (debug_filter)
+ lsm_dom_view_set_debug (view, "filter", TRUE);
+
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width + 2, height + 2);
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]