summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-24 21:05:38 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-24 21:05:38 -0300
commitf145098fcfc2d9290a5de2fa53525499eba70c2c (patch)
tree4450e823dd86b60b9ca01143e3771d2eb6ee85ae
parentd9c778ee5a6de62a8d00c85456cbfd14fc6fe965 (diff)
downloadeeshow-f145098fcfc2d9290a5de2fa53525499eba70c2c.tar.gz
eeshow-f145098fcfc2d9290a5de2fa53525499eba70c2c.tar.bz2
eeshow-f145098fcfc2d9290a5de2fa53525499eba70c2c.zip
gfx/cro.c: only use Pango if there's a ~ in the string
Since the main reason for switching to Pango is that we'll need its layout analysis capabilities to draw overlines, how about just not using Pango for strings that don't have such complications ? Time to first index is now 487 ms, almost as good as with Pango disabled. Note: a further optimization would be to check strings for special issues at the source, and avoid all the strchr-ing.
-rw-r--r--gfx/cro.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index d6ca1c6..78e0131 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -15,7 +15,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
-#include <stdint.h>
+#include <string.h>
#include <unistd.h>
#include <math.h>
@@ -289,7 +289,7 @@ static void cr_text_pango(void *ctx, int x, int y, const char *s, unsigned size,
static void cr_text(void *ctx, int x, int y, const char *s, unsigned size,
enum text_align align, int rot, unsigned color, unsigned layer)
{
- if (use_pango)
+ if (use_pango && strchr(s, '~'))
cr_text_pango(ctx, x, y, s, size, align, rot, color, layer);
else
cr_text_cairo(ctx, x, y, s, size, align, rot, color, layer);
@@ -366,10 +366,9 @@ static void setup_pango(struct cro_ctx *cc)
pango_font_description_from_string("Helvetica Bold");
cc->pango_layout = pango_cairo_create_layout(cc->cr);
// pango_font_description_free(cc->pango_desc);
- } else {
- cairo_select_font_face(cc->cr, "Helvetica",
- CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
}
+ cairo_select_font_face(cc->cr, "Helvetica",
+ CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
// @@@ to destroy pango_layout, g_object_unref(layout);
}