summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-06-15 02:04:18 +0200
committerGrigori Goronzy <greg@blackbox>2011-06-15 02:04:18 +0200
commit3a0055a7bd1d6378aece89db0d17cc0ac804a89b (patch)
treee2b94fced93425b57c6153ee7a54d6d5ab1466d6
parent2f9733ef09e6a6c57697c442e8a697728a25677c (diff)
downloadlibass-3a0055a7bd1d6378aece89db0d17cc0ac804a89b.tar.bz2
libass-3a0055a7bd1d6378aece89db0d17cc0ac804a89b.tar.xz
Convert to high-level rasterizer parts to outlines
This covers rasterization, filtering and blending for one render item.
-rw-r--r--libass/ass_bitmap.c25
-rw-r--r--libass/ass_bitmap.h12
-rw-r--r--libass/ass_render.c16
3 files changed, 28 insertions, 25 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index 2d3f0d5..d8b4063 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -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;
}
diff --git a/libass/ass_bitmap.h b/libass/ass_bitmap.h
index 287b638..71c333f 100644
--- a/libass/ass_bitmap.h
+++ b/libass/ass_bitmap.h
@@ -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);
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 497d77e..1d7f7a0 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -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;