From 00f93b05b70ef4e841608a4ddbd6db36474c6d1b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 2 Jan 2009 11:39:51 +0000 Subject: [PATCH] Make sure we measure layout with the same surface type as the final 2009-01-02 Behdad Esfahbod * pango-view/viewer-main.c (main): * pango-view/viewer-pangocairo.c (pangocairo_view_render): * pango-view/viewer-pangoft2.c (pangoft2_view_render): * pango-view/viewer-pangox.c (pangox_view_render): * pango-view/viewer-pangoxft.c (pangoxft_view_render): * pango-view/viewer.h: Make sure we measure layout with the same surface type as the final target. Also reduces fonts loaded by the pangocairo backend. svn path=/trunk/; revision=2777 --- ChangeLog | 11 +++++++++++ pango-view/viewer-main.c | 9 ++++++--- pango-view/viewer-pangocairo.c | 23 ++++++----------------- pango-view/viewer-pangoft2.c | 6 +++--- pango-view/viewer-pangox.c | 8 ++++---- pango-view/viewer-pangoxft.c | 8 ++++---- pango-view/viewer.h | 4 ++-- 7 files changed, 36 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdf9525..a5a4457 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2009-01-02 Behdad Esfahbod + * pango-view/viewer-main.c (main): + * pango-view/viewer-pangocairo.c (pangocairo_view_render): + * pango-view/viewer-pangoft2.c (pangoft2_view_render): + * pango-view/viewer-pangox.c (pangox_view_render): + * pango-view/viewer-pangoxft.c (pangoxft_view_render): + * pango-view/viewer.h: + Make sure we measure layout with the same surface type as the + final target. Also reduces fonts loaded by the pangocairo backend. + +2009-01-02 Behdad Esfahbod + * pango/pangocairo-context.c (_pango_cairo_update_context): Completely ignore CTM translation offsets. diff --git a/pango-view/viewer-main.c b/pango-view/viewer-main.c index 8523ee3..2b66468 100644 --- a/pango-view/viewer-main.c +++ b/pango-view/viewer-main.c @@ -57,10 +57,13 @@ main (int argc, instance = view->create (view); context = view->get_context (instance); - do_output (context, NULL, NULL, NULL, NULL, &width, &height); + width = height = 1; + surface = view->create_surface (instance, width, height); + view->render (instance, surface, context, &width, &height, NULL); + view->destroy_surface (instance, surface); surface = view->create_surface (instance, width, height); for (run = 0; run < MAX(1,opt_runs); run++) - view->render (instance, surface, context, width, height, NULL); + view->render (instance, surface, context, &width, &height, NULL); if (opt_output) { @@ -123,7 +126,7 @@ main (int argc, if (!state) break; - view->render (instance, surface, context, width, height, state); + view->render (instance, surface, context, &width, &height, state); } if (view->destroy_window) diff --git a/pango-view/viewer-pangocairo.c b/pango-view/viewer-pangocairo.c index e3612c3..30259ec 100644 --- a/pango-view/viewer-pangocairo.c +++ b/pango-view/viewer-pangocairo.c @@ -309,27 +309,16 @@ static void pangocairo_view_render (gpointer instance G_GNUC_UNUSED, gpointer surface, PangoContext *context, - int width G_GNUC_UNUSED, - int height G_GNUC_UNUSED, + int *width, + int *height, gpointer state) { cairo_t *cr; CairoSurface *c_surface = (CairoSurface *) surface; - if (!surface) - { - cairo_surface_t *cs; - /* This is annoying ... we have to create a temporary surface just to - * get the extents of the text. - */ - /* image surface here is not good as it may have font options different - * from the target surface */ - cs = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1); - cr = cairo_create (cs); - cairo_surface_destroy (cs); - } - else - cr = cairo_create (c_surface->cairo); + g_assert (surface); + + cr = cairo_create (c_surface->cairo); transform_callback (context, NULL, cr, state); @@ -337,7 +326,7 @@ pangocairo_view_render (gpointer instance G_GNUC_UNUSED, cairo_paint (cr); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); - do_output (context, render_callback, transform_callback, cr, state, NULL, NULL); + do_output (context, render_callback, transform_callback, cr, state, width, height); cairo_destroy (cr); } diff --git a/pango-view/viewer-pangoft2.c b/pango-view/viewer-pangoft2.c index 1bf114c..2699b74 100644 --- a/pango-view/viewer-pangoft2.c +++ b/pango-view/viewer-pangoft2.c @@ -113,14 +113,14 @@ static void pangoft2_view_render (gpointer instance G_GNUC_UNUSED, gpointer surface, PangoContext *context, - int width G_GNUC_UNUSED, - int height G_GNUC_UNUSED, + int *width, + int *height, gpointer state) { int pix_idx; FT_Bitmap *bitmap = (FT_Bitmap *) surface; - do_output (context, render_callback, NULL, surface, state, NULL, NULL); + do_output (context, render_callback, NULL, surface, state, width, height); for (pix_idx=0; pix_idxpitch * bitmap->rows; pix_idx++) bitmap->buffer[pix_idx] = 255 - bitmap->buffer[pix_idx]; diff --git a/pango-view/viewer-pangox.c b/pango-view/viewer-pangox.c index dff77cb..137319d 100644 --- a/pango-view/viewer-pangox.c +++ b/pango-view/viewer-pangox.c @@ -79,8 +79,8 @@ static void pangox_view_render (gpointer instance, gpointer surface, PangoContext *context, - int width, - int height, + int *width, + int *height, gpointer state) { XViewer *x = (XViewer *) instance; @@ -91,14 +91,14 @@ pangox_view_render (gpointer instance, gc = XCreateGC (x->display, pixmap, 0, NULL); XSetForeground(x->display, gc, WhitePixel(x->display, x->screen)); - XFillRectangle (x->display, pixmap, gc, 0, 0, width, height); + XFillRectangle (x->display, pixmap, gc, 0, 0, *width, *height); x_context.x = x; x_context.drawable = pixmap; x_context.gc = gc; XSetForeground(x->display, gc, BlackPixel(x->display, x->screen)); - do_output (context, render_callback, NULL, &x_context, state, NULL, NULL); + do_output (context, render_callback, NULL, &x_context, state, width, height); XFlush(x->display); diff --git a/pango-view/viewer-pangoxft.c b/pango-view/viewer-pangoxft.c index 14e8c35..198f9ed 100644 --- a/pango-view/viewer-pangoxft.c +++ b/pango-view/viewer-pangoxft.c @@ -100,8 +100,8 @@ static void pangoxft_view_render (gpointer instance, gpointer surface, PangoContext *context, - int width, - int height, + int *width, + int *height, gpointer state) { XViewer *x = (XViewer *) instance; @@ -119,7 +119,7 @@ pangoxft_view_render (gpointer instance, color.color.green = 0xffff; color.color.alpha = 0xffff; - XftDrawRect (draw, &color, 0, 0, width, height); + XftDrawRect (draw, &color, 0, 0, *width, *height); color.color.red = 0x0; color.color.green = 0x0; @@ -129,7 +129,7 @@ pangoxft_view_render (gpointer instance, xft_context.draw = draw; xft_context.color = color; - do_output (context, render_callback, NULL, &xft_context, state, NULL, NULL); + do_output (context, render_callback, NULL, &xft_context, state, width, height); XftDrawDestroy (draw); } diff --git a/pango-view/viewer.h b/pango-view/viewer.h index 4d1d836..20fbdbe 100644 --- a/pango-view/viewer.h +++ b/pango-view/viewer.h @@ -50,8 +50,8 @@ struct _PangoViewer { void (*render) (gpointer instance, gpointer surface, PangoContext *context, - int width, - int height, + int *width, + int *height, gpointer state); /* The following can be NULL */ -- 2.7.4