]> granicus.if.org Git - libass/commitdiff
Convert to high-level rasterizer parts to outlines
authorGrigori Goronzy <greg@blackbox>
Wed, 15 Jun 2011 00:04:18 +0000 (02:04 +0200)
committerGrigori Goronzy <greg@blackbox>
Wed, 15 Jun 2011 00:04:18 +0000 (02:04 +0200)
This covers rasterization, filtering and blending for one
render item.

libass/ass_bitmap.c
libass/ass_bitmap.h
libass/ass_render.c

index 2d3f0d5d800a2c31fd9f3b57de22bfa9fc1828ff..d8b4063a9d0fe1b1e27296917a08b670098bd1b8 100644 (file)
@@ -174,15 +174,14 @@ int check_glyph_area(ASS_Library *library, FT_Glyph glyph)
         return 0;
 }
 
-static Bitmap *glyph_to_bitmap_internal(ASS_Library *library,
-                                          FT_Glyph glyph, int bord)
+Bitmap *outline_to_bitmap(ASS_Library *library, FT_Library ftlib,
+                          FT_Outline *outline, int bord)
 {
     Bitmap *bm;
     int w, h;
     int error;
     FT_BBox bbox;
     FT_Bitmap bitmap;
-    FT_Outline *outline = &((FT_OutlineGlyph)glyph)->outline;
 
     FT_Outline_Get_CBox(outline, &bbox);
     // move glyph to origin (0, 0)
@@ -218,7 +217,7 @@ static Bitmap *glyph_to_bitmap_internal(ASS_Library *library,
     // render into target bitmap
     // XXX: this uses the FT_Library from the glyph. Instead a reference to the
     // FT_Library should be passed to this function (plus outline)
-    if ((error = FT_Outline_Get_Bitmap(glyph->library, outline, &bitmap))) {
+    if ((error = FT_Outline_Get_Bitmap(ftlib, outline, &bitmap))) {
         ass_msg(library, MSGL_WARN, "Failed to rasterize glyph: %d\n", error);
         ass_free_bitmap(bm);
         return NULL;
@@ -461,11 +460,11 @@ static void be_blur(unsigned char *buf, int w, int h)
     }
 }
 
-int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
-                    FT_Glyph glyph, FT_Glyph outline_glyph,
-                    Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
-                    int be, double blur_radius, FT_Vector shadow_offset,
-                    int border_style)
+int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur,
+                       FT_Library ftlib, FT_Outline *outline, FT_Outline *border,
+                       Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
+                       int be, double blur_radius, FT_Vector shadow_offset,
+                       int border_style)
 {
     blur_radius *= 2;
     int bbord = be > 0 ? sqrt(2 * be) : 0;
@@ -478,13 +477,13 @@ int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
 
     *bm_g = *bm_o = *bm_s = 0;
 
-    if (glyph)
-        *bm_g = glyph_to_bitmap_internal(library, glyph, bord);
+    if (outline)
+        *bm_g = outline_to_bitmap(library, ftlib, outline, bord);
     if (!*bm_g)
         return 1;
 
-    if (outline_glyph) {
-        *bm_o = glyph_to_bitmap_internal(library, outline_glyph, bord);
+    if (border) {
+        *bm_o = outline_to_bitmap(library, ftlib, border, bord);
         if (!*bm_o) {
             return 1;
         }
index 287b638289d835431f1564ea14f29a2ed3583a8e..71c333ffa2b483a9f9fb9c0492446dbbd6be322d 100644 (file)
@@ -35,6 +35,8 @@ typedef struct {
     unsigned char *buffer;      // w x h buffer
 } Bitmap;
 
+Bitmap *outline_to_bitmap(ASS_Library *library, FT_Library ftlib,
+                          FT_Outline *outline, int bord);
 /**
  * \brief perform glyph rendering
  * \param glyph original glyph
@@ -44,11 +46,11 @@ typedef struct {
  * \param bm_g out: pointer to the bitmap of glyph shadow is returned here
  * \param be 1 = produces blurred bitmaps, 0 = normal bitmaps
  */
-int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
-                    FT_Glyph glyph, FT_Glyph outline_glyph,
-                    Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
-                    int be, double blur_radius, FT_Vector shadow_offset,
-                    int border_style);
+int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur,
+                       FT_Library ftlib, FT_Outline *outline, FT_Outline *border,
+                       Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s,
+                       int be, double blur_radius, FT_Vector shadow_offset,
+                       int border_style);
 
 void ass_free_bitmap(Bitmap *bm);
 int check_glyph_area(ASS_Library *library, FT_Glyph glyph);
index 497d77e6967ad007aaa41f8257889a31347b9ac1..1d7f7a0597805e82c61e9d29d9c5f79701d6dacd 100644 (file)
@@ -1264,13 +1264,15 @@ get_bitmap_glyph(ASS_Renderer *render_priv, GlyphInfo *info)
                 FT_Outline_Translate(outl, key->advance.x, -key->advance.y);
             }
             // render glyph
-            error = glyph_to_bitmap(render_priv->library,
-                                    render_priv->synth_priv,
-                                    glyph, outline,
-                                    &info->bm, &info->bm_o,
-                                    &info->bm_s, info->be,
-                                    info->blur * render_priv->border_scale,
-                                    key->shadow_offset, key->border_style);
+            error = outline_to_bitmap3(render_priv->library,
+                                       render_priv->synth_priv,
+                                       render_priv->ftlibrary,
+                                       &((FT_OutlineGlyph)glyph)->outline,
+                                       &((FT_OutlineGlyph)outline)->outline,
+                                       &info->bm, &info->bm_o,
+                                       &info->bm_s, info->be,
+                                       info->blur * render_priv->border_scale,
+                                       key->shadow_offset, key->border_style);
             if (error)
                 info->symbol = 0;