From 1445c4016eec7e8f38a4ae35c389849203a623af Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 2 Jan 2009 13:03:02 +0000 Subject: Update for recent changes in cairo. --- configure.in | 3 ++- src/Makefile.am | 4 ++-- src/cairoscript.lang | 50 +++++++++++++++++++++++++------------------------- src/main.c | 30 +++++++++++++++++++++++++++++- src/sphinx.h | 2 ++ 5 files changed, 60 insertions(+), 29 deletions(-) diff --git a/configure.in b/configure.in index 72cc30e..f04bf25 100644 --- a/configure.in +++ b/configure.in @@ -22,7 +22,8 @@ AM_GLIB_GNU_GETTEXT GTK_VERSION=2.14.0 GCONF_VERSION=2.14.0 PKG_CHECK_MODULES(SPHINX, - cairo-script + dnl cairo-script-interpreter + cairo gconf-2.0 >= $GCONF_VERSION gtk+-2.0 >= $GTK_VERSION gtksourceview-2.0) diff --git a/src/Makefile.am b/src/Makefile.am index 4e98735..60a861e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,8 @@ sphinx_CPPFLAGS = \ -DSPHINX_SYSCONFDIR=\"$(sysconfdir)/\" \ $(AM_CPPFLAGS) -sphinx_CFLAGS = @SPHINX_CFLAGS@ -sphinx_LDADD = @SPHINX_LIBS@ +sphinx_CFLAGS = $(SPHINX_CFLAGS) +sphinx_LDADD = $(SPHINX_LIBS) -lcairo-script-interpreter pixmapdir = $(datadir)/pixmaps pixmap_DATA = \ diff --git a/src/cairoscript.lang b/src/cairoscript.lang index e6ae1f3..e2e78ec 100644 --- a/src/cairoscript.lang +++ b/src/cairoscript.lang @@ -97,7 +97,7 @@ radial rgb rgba - scaled_font + scaled-font surface @@ -114,41 +114,41 @@ rectangle - add_color_stop + add-color-stop clip\+? fill\+? identity mask paint - paint_with_alpha - pop_group - push_group + paint-with-alpha + pop-group + push-group restore save scale - set_antialias - set_dash - set_device_offset - set_extend - set_filter - set_fill_rule - set_font_face - set_font_matrix - set_line_cap - set_line_join - set_line_width - set_miter_limit - set_operator - set_matrix - set_scaled_font - set_source - set_source_image - show_glyphs - show_text_glyphs + set-antialias + set-dash + set-device-offset + set-extend + set-filter + set-fill-rule + set-font-face + set-font-matrix + set-line-cap + set-line-join + set-line-width + set-miter-limit + set-operator + set-matrix + set-scaled-font + set-source + set-source-image + show-glyphs + show-text-glyphs stroke\+? transform translate - reset_clip + reset-clip rotate diff --git a/src/main.c b/src/main.c index edf5572..92357fa 100644 --- a/src/main.c +++ b/src/main.c @@ -552,6 +552,7 @@ button_press_cb (GtkWidget *w, GdkEventButton *ev, sphinx_t *sphinx) static cairo_surface_t * _create_surface (void *closure, + cairo_content_t content, double width, double height) //csi_object_t *dictionary) { @@ -761,21 +762,44 @@ _destroy_surface (void *closure, GDK_THREADS_LEAVE (); } +static cairo_t * +_create_context (void *closure, + cairo_surface_t *surface) + //csi_object_t *dictionary) +{ + sphinx_t *sphinx = closure; + cairo_t *cr; + + cr = cairo_create (surface); + + GDK_THREADS_ENTER (); + + g_hash_table_insert (sphinx->contexts_ht, + cr, cairo_surface_reference (surface)); + + GDK_THREADS_LEAVE (); + + return cr; +} + static void _destroy_context (void *closure, void *cr) //csi_object_t *dictionary) { sphinx_t *sphinx = closure; + cairo_surface_t *surface; GDK_THREADS_ENTER (); + surface = g_hash_table_lookup (sphinx->contexts_ht, cr); if (sphinx->watch_contexts) { if (sphinx->view == NULL) sphinx->view = _create_surface_view (sphinx); - surface_view_set_surface (sphinx->view, cairo_get_target (cr)); + surface_view_set_surface (sphinx->view, surface); } + g_hash_table_remove (sphinx->contexts_ht, cr); if (sphinx->break_on_context_undef) sphinx_run_break (sphinx); @@ -900,12 +924,16 @@ sphinx_new (void) .closure = sphinx, .surface_create = _create_surface, .surface_destroy = _destroy_surface, + .context_create = _create_context, .context_destroy = _destroy_context, }; sphinx->csi = cairo_script_interpreter_create (); cairo_script_interpreter_install_hooks (sphinx->csi, &hooks); + sphinx->contexts_ht = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) cairo_surface_destroy); + sphinx->break_on_surface_undef = FALSE; sphinx->break_on_context_undef = FALSE; sphinx->watch_surfaces = FALSE; diff --git a/src/sphinx.h b/src/sphinx.h index 6dad015..668905e 100644 --- a/src/sphinx.h +++ b/src/sphinx.h @@ -56,6 +56,8 @@ typedef struct _sphinx { GtkTextIter run_end; guint run_continue; + GHashTable *contexts_ht; + gboolean break_on_surface_undef; gboolean break_on_context_undef; gboolean watch_surfaces; -- cgit v1.2.3