diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2013-01-03 23:40:02 -0600 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2013-01-03 23:51:43 -0600 |
commit | d64005ea687a7263dc070c1314a4f211a2994fc9 (patch) | |
tree | 0a7f529dc86edf8c270eb9f57391302b1639947c /tests/test-pangocairo-threads.c | |
parent | 1037c5dcb51cd0865360533da7e97638dda35f7f (diff) | |
download | pango-d64005ea687a7263dc070c1314a4f211a2994fc9.tar.gz |
Update test-pangocairo-threads to new threads API
Diffstat (limited to 'tests/test-pangocairo-threads.c')
-rw-r--r-- | tests/test-pangocairo-threads.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/tests/test-pangocairo-threads.c b/tests/test-pangocairo-threads.c index 29c6aa57..7d2b68a6 100644 --- a/tests/test-pangocairo-threads.c +++ b/tests/test-pangocairo-threads.c @@ -12,19 +12,19 @@ thread_func (gpointer data) int i; char *filename; - cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 500, 300); + cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 100, 100); cairo_t *cr = cairo_create (surface); PangoLayout *layout = pango_cairo_create_layout (cr); - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_paint (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - pango_layout_set_text (layout, text, -1); - pango_layout_set_width (layout, 500 * PANGO_SCALE); + pango_layout_set_width (layout, 100 * PANGO_SCALE); for (i = 0; i < num_iters; i++) { + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + /* force a relayout */ PangoWrapMode wrap = pango_layout_get_wrap (layout); wrap = wrap == PANGO_WRAP_WORD ? PANGO_WRAP_CHAR : PANGO_WRAP_WORD; @@ -40,19 +40,12 @@ thread_func (gpointer data) return 0; } -static void -join_thread (gpointer thread, gpointer self) -{ - if (thread != self) - g_thread_join (thread); -} - - int main (int argc, char **argv) { int num_threads = 2; int i; + GPtrArray *threads = g_ptr_array_new (); if (argc > 1) num_threads = atoi (argv[1]); @@ -62,13 +55,14 @@ main (int argc, char **argv) g_type_init (); g_thread_init (NULL); - /* force pango module initializations */ -/* thread_func (GINT_TO_POINTER (0)); */ - for (i = 0; i < num_threads; i++) - g_thread_create (thread_func, GINT_TO_POINTER (i+1), TRUE, NULL); + g_ptr_array_add (threads, + g_thread_new (g_strdup_printf ("%d", i + 1), + thread_func, + GINT_TO_POINTER (i+1))); - g_thread_foreach (join_thread, g_thread_self ()); + for (i = 0; i < num_threads; i++) + g_thread_join (g_ptr_array_index (threads, i)); return 0; } |