summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2009-01-02 11:39:51 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2009-01-02 11:39:51 +0000
commit00f93b05b70ef4e841608a4ddbd6db36474c6d1b (patch)
treea50bc1f23a1d022b1ceafd19aa369c95e2477d56
parent4898ac87e81e7c748147aff017368608d8c6c9bb (diff)
downloadpango-00f93b05b70ef4e841608a4ddbd6db36474c6d1b.tar.gz
Make sure we measure layout with the same surface type as the final
2009-01-02 Behdad Esfahbod <behdad@gnome.org> * 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
-rw-r--r--ChangeLog11
-rw-r--r--pango-view/viewer-main.c9
-rw-r--r--pango-view/viewer-pangocairo.c23
-rw-r--r--pango-view/viewer-pangoft2.c6
-rw-r--r--pango-view/viewer-pangox.c8
-rw-r--r--pango-view/viewer-pangoxft.c8
-rw-r--r--pango-view/viewer.h4
7 files changed, 36 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index fdf95256..a5a4457f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2009-01-02 Behdad Esfahbod <behdad@gnome.org>
+ * 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 <behdad@gnome.org>
+
* 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 8523ee38..2b664682 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 e3612c34..30259ec6 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 1bf114cc..2699b740 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_idx<bitmap->pitch * 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 dff77cbf..137319d9 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 14e8c355..198f9edc 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 4d1d836a..20fbdbe0 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 */