Re: Floating point in pango



Hi,

On Mon, 2006-07-10 at 10:53 -0400, Behdad Esfahbod wrote:
> On Mon, 2006-07-10 at 08:46 -0400, Jorn Baayen wrote:
> > Hi,
> > 
> > Just FYI, GTK+ >= 2.8 uses pango-cairo to draw text, which apart from
> > using cairo to draw also calculates the position of each glyph using
> > floating point whereas this was done using fixed point previously. 
> 
> True.  That's because cairo's public API uses floating point.  Do you
> have any idea how Pango can do better here?

No :(

> > Pango-cairo alone appears to be responsible for an approximately 30%
> > slowdown when drawing text on ARM.
> 
> What do you exactly mean by 30% slowdown?  How was that measured?

Timing the drawing of text using GTK 2.6 vs GTK 2.8, by connecting two
signal handlers to the 'expose-event' of a GtkLabel, one before and one
after the default handler, and timing the difference. The difference is
about 30% higher using GTK 2.8. I attach the code used.
(All this on ARM)


Thanks,

Jorn

> 
> > Thanks,
> > 
> > Jorn
> 
> Cheers,
> 
-- 
OpenedHand Ltd.
http://o-hand.com/
#include <gtk/gtk.h>

static int n_draws = 0;
static gdouble total_seconds = 0.0;

static gboolean
expose_event1_cb (GtkWidget      *widget,
                  GdkEventExpose *event,
                  GTimer         *timer)
{
        g_timer_start (timer);

        return FALSE;
}

static gboolean
expose_event2_cb (GtkWidget      *widget,
                  GdkEventExpose *event,
                  GTimer         *timer)
{
        g_timer_stop (timer);

        n_draws++;
        total_seconds += g_timer_elapsed (timer, NULL);

        return FALSE;
}

static gboolean
idle (GtkWidget *widget)
{
        gtk_widget_queue_draw (widget);

        return TRUE;
}

int
main (int argc, char **argv)
{
        GtkWidget *window, *box, *label;
        GTimer *timer;

        gtk_init (&argc, &argv);

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        box = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (window), box);

        label = gtk_label_new ("This is a pretty long string with some accented chars: J��s");

        timer = g_timer_new ();
        g_signal_connect (label,
                          "expose-event",
                          G_CALLBACK (expose_event1_cb),
                          timer);
        g_signal_connect_after (label,
                                "expose-event",
                                G_CALLBACK (expose_event2_cb),
                                timer);
        gtk_box_pack_start_defaults (GTK_BOX (box), label);

        gtk_widget_show_all (window);

        g_idle_add ((GSourceFunc) idle, label);

        g_timeout_add (10000, (GSourceFunc) gtk_main_quit, NULL);

        gtk_main ();

        g_print ("Drawn label %d times. Average time spent drawing (in seconds): %lf\n", n_draws, total_seconds / n_draws);

        return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]