summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-01-02 13:03:02 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-01-02 13:03:02 +0000
commit1445c4016eec7e8f38a4ae35c389849203a623af (patch)
tree8702493b52001ea9f714f67a2b3dcfd207d04fc0
parent70c136fc29ff84220228e35c6ce26e007d7840d9 (diff)
Update for recent changes in cairo.
-rw-r--r--configure.in3
-rw-r--r--src/Makefile.am4
-rw-r--r--src/cairoscript.lang50
-rw-r--r--src/main.c30
-rw-r--r--src/sphinx.h2
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 @@
<keyword>radial</keyword>
<keyword>rgb</keyword>
<keyword>rgba</keyword>
- <keyword>scaled_font</keyword>
+ <keyword>scaled-font</keyword>
<keyword>surface</keyword>
</context>
<context id="path" style-ref="path">
@@ -114,41 +114,41 @@
<keyword>rectangle</keyword>
</context>
<context id="procedure" style-ref="procedure">
- <keyword>add_color_stop</keyword>
+ <keyword>add-color-stop</keyword>
<keyword>clip\+?</keyword>
<keyword>fill\+?</keyword>
<keyword>identity</keyword>
<keyword>mask</keyword>
<keyword>paint</keyword>
- <keyword>paint_with_alpha</keyword>
- <keyword>pop_group</keyword>
- <keyword>push_group</keyword>
+ <keyword>paint-with-alpha</keyword>
+ <keyword>pop-group</keyword>
+ <keyword>push-group</keyword>
<keyword>restore</keyword>
<keyword>save</keyword>
<keyword>scale</keyword>
- <keyword>set_antialias</keyword>
- <keyword>set_dash</keyword>
- <keyword>set_device_offset</keyword>
- <keyword>set_extend</keyword>
- <keyword>set_filter</keyword>
- <keyword>set_fill_rule</keyword>
- <keyword>set_font_face</keyword>
- <keyword>set_font_matrix</keyword>
- <keyword>set_line_cap</keyword>
- <keyword>set_line_join</keyword>
- <keyword>set_line_width</keyword>
- <keyword>set_miter_limit</keyword>
- <keyword>set_operator</keyword>
- <keyword>set_matrix</keyword>
- <keyword>set_scaled_font</keyword>
- <keyword>set_source</keyword>
- <keyword>set_source_image</keyword>
- <keyword>show_glyphs</keyword>
- <keyword>show_text_glyphs</keyword>
+ <keyword>set-antialias</keyword>
+ <keyword>set-dash</keyword>
+ <keyword>set-device-offset</keyword>
+ <keyword>set-extend</keyword>
+ <keyword>set-filter</keyword>
+ <keyword>set-fill-rule</keyword>
+ <keyword>set-font-face</keyword>
+ <keyword>set-font-matrix</keyword>
+ <keyword>set-line-cap</keyword>
+ <keyword>set-line-join</keyword>
+ <keyword>set-line-width</keyword>
+ <keyword>set-miter-limit</keyword>
+ <keyword>set-operator</keyword>
+ <keyword>set-matrix</keyword>
+ <keyword>set-scaled-font</keyword>
+ <keyword>set-source</keyword>
+ <keyword>set-source-image</keyword>
+ <keyword>show-glyphs</keyword>
+ <keyword>show-text-glyphs</keyword>
<keyword>stroke\+?</keyword>
<keyword>transform</keyword>
<keyword>translate</keyword>
- <keyword>reset_clip</keyword>
+ <keyword>reset-clip</keyword>
<keyword>rotate</keyword>
</context>
</include>
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;