]> granicus.if.org Git - libass/commitdiff
Turn down subpixel accuracy to 1/8th pixel
authorGrigori Goronzy <greg@blackbox>
Tue, 7 Jul 2009 22:07:52 +0000 (00:07 +0200)
committerGrigori Goronzy <greg@blackbox>
Tue, 7 Jul 2009 22:07:52 +0000 (00:07 +0200)
Using the full accuracy range of 1/64th pixel seems unnecessary--1/8th
pixel is "good enough".  Mask out the three lowest bits to lower cache
and CPU usage; a short test shows that this almost halves the amount
of glyphs with different subpixel shifts being generated and cached.

libass/ass_render.c

index 19870a55f6dd80f9084ddf287b67e34e1df2237b..03173400131c73fa439378c7378d32bf8650e82b 100644 (file)
@@ -42,7 +42,8 @@
 #define MAX_LINES_INITIAL 64
 #define BLUR_MAX_RADIUS 100.0
 #define MAX_BE 100
-#define SUBPIXEL_MASK 63        // d6 bitmask for subpixel accuracy adjustment
+#define SUBPIXEL_MASK 63
+#define SUBPIXEL_ACCURACY 7    // d6 mask for subpixel accuracy adjustment
 
 static int last_render_id = 0;
 
@@ -2895,10 +2896,10 @@ ass_render_event(ass_renderer_t *render_priv, ass_event_t *event,
         glyph_info_t *g = text_info->glyphs + i;
         g->hash_key.advance.x =
             double_to_d6(device_x - (int) device_x +
-            d6_to_double(g->pos.x & SUBPIXEL_MASK));
+            d6_to_double(g->pos.x & SUBPIXEL_MASK)) & ~SUBPIXEL_ACCURACY;
         g->hash_key.advance.y = 
             double_to_d6(device_y - (int) device_y +
-            d6_to_double(g->pos.y & SUBPIXEL_MASK));
+            d6_to_double(g->pos.y & SUBPIXEL_MASK)) & ~SUBPIXEL_ACCURACY;
         get_bitmap_glyph(render_priv, text_info->glyphs + i);
     }