aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-04-26 18:16:17 +0200
committerMattias Andrée <maandree@kth.se>2020-04-26 18:16:17 +0200
commit2476d335d935f08e6fbdaaeaeff83cd293dab52b (patch)
treeb726743c3502e1efc93c91c0e496ab53c9576a6b
parentPrepare for glyph caching support (diff)
downloadlibskrift-2476d335d935f08e6fbdaaeaeff83cd293dab52b.tar.gz
libskrift-2476d335d935f08e6fbdaaeaeff83cd293dab52b.tar.bz2
libskrift-2476d335d935f08e6fbdaaeaeff83cd293dab52b.tar.xz
Faster glyph merging when not using smoothing
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--libskrift_merge_glyphs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libskrift_merge_glyphs.c b/libskrift_merge_glyphs.c
index 76ddb6b..48b1e5a 100644
--- a/libskrift_merge_glyphs.c
+++ b/libskrift_merge_glyphs.c
@@ -11,9 +11,7 @@ libskrift_merge_glyphs(LIBSKRIFT_CONTEXT *ctx, struct libskrift_glyph *glyph1,
size_t width, height, r, c, size, psize;
size_t src_off, dest_off, src_linesize, dest_linesize;
- (void) ctx;
-
- psize = glyph1->size / ((size_t)glyph1->width * (size_t)glyph1->height);
+ psize = glyph1->size / ((size_t)glyph1->width * (size_t)glyph1->height);
x1a = glyph1->x;
x1b = glyph2->x;
@@ -56,9 +54,15 @@ libskrift_merge_glyphs(LIBSKRIFT_CONTEXT *ctx, struct libskrift_glyph *glyph1,
src_linesize = glyph2->width * psize;
dest_off = (size_t)(glyph2->y - y1) * dest_linesize;
dest_off += (size_t)(glyph2->x - x1) * psize;
- for (r = src_off = 0; r < glyph2->height; r++, dest_off += dest_linesize, src_off += src_linesize)
- for (c = 0; c < src_linesize; c++)
- (*glyphp)->image[dest_off + c] = MAX((*glyphp)->image[dest_off + c], glyph2->image[src_off + c]);
+ if (ctx->rendering.smoothing) {
+ for (r = src_off = 0; r < glyph2->height; r++, dest_off += dest_linesize, src_off += src_linesize)
+ for (c = 0; c < src_linesize; c++)
+ (*glyphp)->image[dest_off + c] = MAX((*glyphp)->image[dest_off + c], glyph2->image[src_off + c]);
+ } else {
+ for (r = src_off = 0; r < glyph2->height; r++, dest_off += dest_linesize, src_off += src_linesize)
+ for (c = 0; c < src_linesize; c++)
+ (*glyphp)->image[dest_off + c] |= glyph2->image[src_off + c];
+ }
return 0;
}